Fixed cache and metaclass irregularities as well as the location and contents caches.

This commit is contained in:
Griatch 2013-09-22 21:48:08 +02:00
parent 0a394929b7
commit 642ae2faf9
4 changed files with 38 additions and 45 deletions

View file

@ -95,7 +95,6 @@ def field_pre_save(sender, instance=None, update_fields=None, raw=False, **kwarg
"""
if raw:
return
#print "field_pre_save:", instance, update_fields# if hasattr(instance, "db_key") else instance, update_fields
if update_fields:
# this is a list of strings at this point. We want field objects
update_fields = (_GA(_GA(instance, "_meta"), "get_field_by_name")(field)[0] for field in update_fields)
@ -104,12 +103,10 @@ def field_pre_save(sender, instance=None, update_fields=None, raw=False, **kwarg
update_fields = _GA(_GA(instance, "_meta"), "fields")
for field in update_fields:
fieldname = field.name
new_value = field.value_from_object(instance)
new_value = _GA(instance, fieldname)#field.value_from_object(instance)
# try to see if there is a handler on object that should be triggered when saving.
handlername = "_at_%s_save" % fieldname
handler = _GA(instance, handlername) if handlername in _GA(instance, '__dict__') else None
#if handlername == "_at_db_location_save":
# print "handler:", handlername, handler, _GA(sender, '__dict__').keys()
handler = _GA(instance, handlername) if handlername in _GA(sender, '__dict__') else None
if callable(handler):
#hid = hashid(instance, "-%s" % fieldname)
try: