Update SQLAlchemy
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# orm/state.py
|
||||
# Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file>
|
||||
# Copyright (C) 2005-2013 the SQLAlchemy authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
@@ -124,7 +124,7 @@ class InstanceState(object):
|
||||
return []
|
||||
elif hasattr(impl, 'get_collection'):
|
||||
return [
|
||||
(attributes.instance_state(o), o) for o in
|
||||
(attributes.instance_state(o), o) for o in
|
||||
impl.get_collection(self, dict_, x, passive=passive)
|
||||
]
|
||||
else:
|
||||
@@ -134,10 +134,10 @@ class InstanceState(object):
|
||||
d = {'instance':self.obj()}
|
||||
d.update(
|
||||
(k, self.__dict__[k]) for k in (
|
||||
'committed_state', 'pending', 'modified', 'expired',
|
||||
'committed_state', 'pending', 'modified', 'expired',
|
||||
'callables', 'key', 'parents', 'load_options', 'mutable_dict',
|
||||
'class_',
|
||||
) if k in self.__dict__
|
||||
) if k in self.__dict__
|
||||
)
|
||||
if self.load_path:
|
||||
d['load_path'] = interfaces.serialize_path(self.load_path)
|
||||
@@ -181,26 +181,26 @@ class InstanceState(object):
|
||||
self.__dict__.update([
|
||||
(k, state[k]) for k in (
|
||||
'key', 'load_options', 'mutable_dict'
|
||||
) if k in state
|
||||
) if k in state
|
||||
])
|
||||
|
||||
if 'load_path' in state:
|
||||
self.load_path = interfaces.deserialize_path(state['load_path'])
|
||||
|
||||
# setup _sa_instance_state ahead of time so that
|
||||
# setup _sa_instance_state ahead of time so that
|
||||
# unpickle events can access the object normally.
|
||||
# see [ticket:2362]
|
||||
manager.setup_instance(inst, self)
|
||||
manager.dispatch.unpickle(self, state)
|
||||
|
||||
def initialize(self, key):
|
||||
"""Set this attribute to an empty value or collection,
|
||||
"""Set this attribute to an empty value or collection,
|
||||
based on the AttributeImpl in use."""
|
||||
|
||||
self.manager.get_impl(key).initialize(self, self.dict)
|
||||
|
||||
def reset(self, dict_, key):
|
||||
"""Remove the given attribute and any
|
||||
"""Remove the given attribute and any
|
||||
callables associated with it."""
|
||||
|
||||
dict_.pop(key, None)
|
||||
@@ -284,7 +284,7 @@ class InstanceState(object):
|
||||
|
||||
self.manager.deferred_scalar_loader(self, toload)
|
||||
|
||||
# if the loader failed, or this
|
||||
# if the loader failed, or this
|
||||
# instance state didn't have an identity,
|
||||
# the attributes still might be in the callables
|
||||
# dict. ensure they are removed.
|
||||
@@ -321,7 +321,7 @@ class InstanceState(object):
|
||||
@property
|
||||
def expired_attributes(self):
|
||||
"""Return the set of keys which are 'expired' to be loaded by
|
||||
the manager's deferred scalar loader, assuming no pending
|
||||
the manager's deferred scalar loader, assuming no pending
|
||||
changes.
|
||||
|
||||
see also the ``unmodified`` collection which is intersected
|
||||
@@ -348,7 +348,7 @@ class InstanceState(object):
|
||||
|
||||
self.committed_state[attr.key] = previous
|
||||
|
||||
# the "or not self.modified" is defensive at
|
||||
# the "or not self.modified" is defensive at
|
||||
# this point. The assertion below is expected
|
||||
# to be True:
|
||||
# assert self._strong_obj is None or self.modified
|
||||
@@ -363,9 +363,9 @@ class InstanceState(object):
|
||||
raise orm_exc.ObjectDereferencedError(
|
||||
"Can't emit change event for attribute '%s' - "
|
||||
"parent object of type %s has been garbage "
|
||||
"collected."
|
||||
"collected."
|
||||
% (
|
||||
self.manager[attr.key],
|
||||
self.manager[attr.key],
|
||||
orm_util.state_class_str(self)
|
||||
))
|
||||
self.modified = True
|
||||
@@ -433,7 +433,7 @@ class InstanceState(object):
|
||||
self._strong_obj = None
|
||||
|
||||
class MutableAttrInstanceState(InstanceState):
|
||||
"""InstanceState implementation for objects that reference 'mutable'
|
||||
"""InstanceState implementation for objects that reference 'mutable'
|
||||
attributes.
|
||||
|
||||
Has a more involved "cleanup" handler that checks mutable attributes
|
||||
@@ -491,7 +491,7 @@ class MutableAttrInstanceState(InstanceState):
|
||||
|
||||
This would be called in the extremely rare
|
||||
race condition that the weakref returned None but
|
||||
the cleanup handler had not yet established the
|
||||
the cleanup handler had not yet established the
|
||||
__resurrect callable as its replacement.
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user