Merge from Kelketek's clone. Added fixes to migrations of Tags. Issues with ContentTypes meaning that this revision is not possible to start.

This commit is contained in:
Griatch 2013-10-17 23:44:52 +02:00
commit acdea41a67
19 changed files with 601 additions and 468 deletions

View file

@ -196,7 +196,7 @@ def pack_dbobj(item):
# build the internal representation as a tuple ("__packed_dbobj__", key, creation_time, id)
return natural_key and ('__packed_dbobj__', natural_key, _TO_DATESTRING(obj), _GA(obj, "id")) or item
def _unpack_dbobj(item):
def unpack_dbobj(item):
"""
Check and convert internal representations back to Django database models.
The fact that item is a packed dbobj should be checked before this call.
@ -209,7 +209,9 @@ def _unpack_dbobj(item):
except ObjectDoesNotExist:
return None
# even if we got back a match, check the sanity of the date (some databases may 're-use' the id)
return _TO_DATESTRING(obj.dbobj) == item[2] and obj or None
try: dbobj = obj.dbobj
except AttributeError: dbobj = obj
return _TO_DATESTRING(dbobj) == item[2] and obj or None
#
# Access methods
@ -267,7 +269,7 @@ def from_pickle(data, db_obj=None):
return item
elif _IS_PACKED_DBOBJ(item):
# this must be checked before tuple
return _unpack_dbobj(item)
return unpack_dbobj(item)
elif dtype == tuple:
return tuple(process_item(val) for val in item)
elif dtype == dict:
@ -289,7 +291,7 @@ def from_pickle(data, db_obj=None):
return item
elif _IS_PACKED_DBOBJ(item):
# this must be checked before tuple
return _unpack_dbobj(item)
return unpack_dbobj(item)
elif dtype == tuple:
return tuple(process_tree(val) for val in item)
elif dtype == list:

View file

@ -729,10 +729,10 @@ def mod_import(module):
def all_from_module(module):
"""
Return all global-level variables from a module
Return all global-level variables from a module as a dict
"""
mod = mod_import(module)
return [val for key, val in mod.__dict__.items() if not (key.startswith("_") or ismodule(val))]
return dict((key, val) for key, val in mod.__dict__.items() if not (key.startswith("_") or ismodule(val)))
def variable_from_module(module, variable=None, default=None):
"""