diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-07-03 05:31:49 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-07-03 05:31:49 +0100 |
commit | 8446047ab246b186f0404a1f8acbf719a6355a78 (patch) | |
tree | b5b9a1b32c82383a1f6088bd4c4b97bacf933875 /save_carefully.py | |
parent | dc19150eba28de83e06c47d6235c07309f92b36d (diff) | |
download | troggle-8446047ab246b186f0404a1f8acbf719a6355a78.tar.gz troggle-8446047ab246b186f0404a1f8acbf719a6355a78.tar.bz2 troggle-8446047ab246b186f0404a1f8acbf719a6355a78.zip |
[svn] Brief code cleanup.
Diffstat (limited to 'save_carefully.py')
-rw-r--r-- | save_carefully.py | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/save_carefully.py b/save_carefully.py deleted file mode 100644 index bacd91d..0000000 --- a/save_carefully.py +++ /dev/null @@ -1,29 +0,0 @@ -import logging
-
-def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
- """Looks up instance using lookupAttribs 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.
-
- """
-
- instance, created=objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
-
- if not created and not instance.new_since_parsing:
- for k, v in nonLookupAttribs.items(): #overwrite the existing attributes from the logbook text (except date and title)
- setattr(instance, k, v)
- instance.save()
-
- if created:
- logging.info(unicode(instance)+u' was just added to the database for the first time. \n')
-
- if not created and instance.new_since_parsing:
- logging.info(unicode(instance)+" has been modified using Troggle, so the current script left it as is. \n")
-
- if not created and not instance.new_since_parsing:
- logging.info(unicode(instance)+" existed in the database unchanged since last parse. It was overwritten by the current script. \n")
- return (instance, created)
\ No newline at end of file |