From 625b2156e388a92d57fa446c931bbf410f5a4e29 Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 06:15:48 +0100 Subject: [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 --- save_carefully.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 save_carefully.py (limited to 'save_carefully.py') 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 -- cgit v1.2.3