diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-11-03 16:54:29 +0200 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-11-03 16:54:29 +0200 |
commit | fc60bde3ec6248bc4a53b84e89f105229ca6a5c3 (patch) | |
tree | a581e9263c7e46c50dbc91d162b24d436ea9c685 /core/utils.py | |
parent | c7cb8ece2eb8f7c711f5fce4c2f53b319011955d (diff) | |
download | troggle-fc60bde3ec6248bc4a53b84e89f105229ca6a5c3.tar.gz troggle-fc60bde3ec6248bc4a53b84e89f105229ca6a5c3.tar.bz2 troggle-fc60bde3ec6248bc4a53b84e89f105229ca6a5c3.zip |
comments and tidy
Diffstat (limited to 'core/utils.py')
-rw-r--r-- | core/utils.py | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/core/utils.py b/core/utils.py index c62dedb..b46e341 100644 --- a/core/utils.py +++ b/core/utils.py @@ -159,8 +159,6 @@ def write_and_commit(files, message): try: with open(filepath, mode, **kwargs) as f: print(f"WRITING {cwd}---{filename} ") - # as the wsgi process www-data, we have group write-access but are not owner, so cannot chmod. - # os.chmod(filepath, 0o664) # set file permissions to rw-rw-r-- f.write(content) except PermissionError: raise WriteAndCommitError( @@ -278,61 +276,6 @@ def writetrogglefile(filepath, filecontent): # not catching and re-raising any exceptions yet, inc. the stderr etc.,. We should do that. -# def save_carefully(objectType, coUniqueAttribs={}, otherAttribs={}): - # """Looks up instance using coUniqueAttribs and carries out the following: - # -if instance does not exist in DB: add instance to DB, return (new instance, True) - # -if instance exists in DB and was modified using Troggle: do nothing, return (existing instance, False) - # -if instance exists in DB and was not modified using Troggle: overwrite instance, return (instance, False) - - # The checking is accomplished using Django's get_or_create and the new_since_parsing boolean field - # defined in core.models.TroggleModel. - - # We are not using new_since_parsing - it is a fossil from Aaron Curtis's design in 2006. So it is always false. - - # NOTE: this takes twice as long as simply creating a new object with the given values. - - # As of Jan.2023 this function is not used anywhere in troggle. - - # """ - # try: - # instance, created = objectType.objects.get_or_create(defaults=otherAttribs, **coUniqueAttribs) - # except: - # print(" !! - FAIL in SAVE CAREFULLY ===================", objectType) - # print(" !! - -- objects.get_or_create()") - # print(f" !! - coUniqueAttribs:{coUniqueAttribs}\n !! - otherAttribs:{otherAttribs}") - # raise - # if not created and not instance.new_since_parsing: - # for k, v in list( - # otherAttribs.items() - # ): # overwrite the existing attributes from the logbook text (except date and title) - # setattr(instance, k, v) - # try: - # instance.save() - # except: - # print(" !! - SAVE CAREFULLY ===================", objectType) - # print(" !! - -- instance.save()") - # print(f" !! - coUniqueAttribs:{coUniqueAttribs}\n !! - otherAttribs:{otherAttribs}") - # raise - # try: - # str(instance) - # except: - # pass - # if created: - # logging.info(str(instance) + " was just added to the database for the first time. \n") - - # if not created and instance.new_since_parsing: - # logging.info( - # str(instance) + " has been modified using Troggle since parsing, so the current script left it as is. \n" - # ) - - # if not created and not instance.new_since_parsing: - # logging.info( - # " instance:<" - # + str(instance) - # + "> existed in the database unchanged since last parse. It have been overwritten." - # ) - # return (instance, created) - """The following is a Bard converted version of Radosts's MIT copyrighted Javascript on 2023-10-27 with hand-editing. |