summaryrefslogtreecommitdiffstats
path: root/save_carefully.py
diff options
context:
space:
mode:
authorsubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 06:15:48 +0100
committersubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 06:15:48 +0100
commit625b2156e388a92d57fa446c931bbf410f5a4e29 (patch)
tree8866421569ba567be82b58a45d90e142c46e5c0a /save_carefully.py
parent1a36856b407684a9d48f04e170a160b3c04aa706 (diff)
downloadtroggle-625b2156e388a92d57fa446c931bbf410f5a4e29.tar.gz
troggle-625b2156e388a92d57fa446c931bbf410f5a4e29.tar.bz2
troggle-625b2156e388a92d57fa446c931bbf410f5a4e29.zip
[svn] Weeks of local changes.
- Import is now non-destructive - Parsers write output to a log file (path be specified in settings) - databaseReset.py content been divided into separate functions which can be called for varying levels of deletion and importing - control panel (view, template, urlpattern) added for deleting and importing - Logins and signup fixed - CaveArea model updated, view, hierarchical url patterns, and beginning of template added - New site style Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8324 by cucc @ 5/3/2009 5:56 AM
Diffstat (limited to 'save_carefully.py')
-rw-r--r--save_carefully.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/save_carefully.py b/save_carefully.py
new file mode 100644
index 0000000..1631618
--- /dev/null
+++ b/save_carefully.py
@@ -0,0 +1,10 @@
+def save(objectType, lookupAttribs={}, nonLookupAttribs={}):
+
+ 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()
+
+ return instance \ No newline at end of file