diff options
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/dynamic.py | 26 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/evaluator.py | 12 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/exc.py | 22 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/identity.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/scoping.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/sync.py | 12 |
6 files changed, 41 insertions, 41 deletions
diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py index c2f4aff02..d2cb0ab05 100644 --- a/lib/sqlalchemy/orm/dynamic.py +++ b/lib/sqlalchemy/orm/dynamic.py @@ -14,7 +14,7 @@ basic add/delete mutation. from .. import log, util from ..sql import operators from . import ( - attributes, object_session, util as orm_util, strategies, + attributes, object_session, util as orm_util, strategies, object_mapper, exc as orm_exc, collections ) from .query import Query @@ -60,7 +60,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl): else: return self.query_class(self, state) - def get_collection(self, state, dict_, user_data=None, + def get_collection(self, state, dict_, user_data=None, passive=attributes.PASSIVE_NO_INITIALIZE): if not passive & attributes.SQL_OK: return self._get_collection_history(state, @@ -94,7 +94,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl): if self.key not in state.committed_state: state.committed_state[self.key] = CollectionHistory(self, state) - state._modified_event(dict_, + state._modified_event(dict_, self, attributes.NEVER_SET) @@ -104,7 +104,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl): return state.committed_state[self.key] def set(self, state, dict_, value, initiator, - passive=attributes.PASSIVE_OFF, + passive=attributes.PASSIVE_OFF, check_old=None, pop=False): if initiator and initiator.parent_token is self.parent_token: return @@ -141,8 +141,8 @@ class DynamicAttributeImpl(attributes.AttributeImpl): def get_all_pending(self, state, dict_): c = self._get_collection_history(state, attributes.PASSIVE_NO_INITIALIZE) return [ - (attributes.instance_state(x), x) - for x in + (attributes.instance_state(x), x) + for x in c.added_items + c.unchanged_items + c.deleted_items ] @@ -159,12 +159,12 @@ class DynamicAttributeImpl(attributes.AttributeImpl): else: return c - def append(self, state, dict_, value, initiator, + def append(self, state, dict_, value, initiator, passive=attributes.PASSIVE_OFF): if initiator is not self: self.fire_append_event(state, dict_, value, initiator) - def remove(self, state, dict_, value, initiator, + def remove(self, state, dict_, value, initiator, passive=attributes.PASSIVE_OFF): if initiator is not self: self.fire_remove_event(state, dict_, value, initiator) @@ -203,9 +203,9 @@ class AppenderMixin(object): mapper = object_mapper(instance) prop = mapper._props[self.attr.key] self._criterion = prop.compare( - operators.eq, - instance, - value_is_parent=True, + operators.eq, + instance, + value_is_parent=True, alias_secondary=False) if self.attr.order_by: @@ -279,12 +279,12 @@ class AppenderMixin(object): def append(self, item): self.attr.append( - attributes.instance_state(self.instance), + attributes.instance_state(self.instance), attributes.instance_dict(self.instance), item, None) def remove(self, item): self.attr.remove( - attributes.instance_state(self.instance), + attributes.instance_state(self.instance), attributes.instance_dict(self.instance), item, None) diff --git a/lib/sqlalchemy/orm/evaluator.py b/lib/sqlalchemy/orm/evaluator.py index 5de514da8..0bc635db6 100644 --- a/lib/sqlalchemy/orm/evaluator.py +++ b/lib/sqlalchemy/orm/evaluator.py @@ -11,10 +11,10 @@ class UnevaluatableError(Exception): pass _straight_ops = set(getattr(operators, op) - for op in ('add', 'mul', 'sub', + for op in ('add', 'mul', 'sub', # Py2K 'div', - # end Py2K + # end Py2K 'mod', 'truediv', 'lt', 'le', 'ne', 'gt', 'ge', 'eq')) @@ -71,13 +71,13 @@ class EvaluatorCompiler(object): return True else: raise UnevaluatableError( - "Cannot evaluate clauselist with operator %s" % + "Cannot evaluate clauselist with operator %s" % clause.operator) return evaluate def visit_binary(self, clause): - eval_left,eval_right = map(self.process, + eval_left,eval_right = map(self.process, [clause.left, clause.right]) operator = clause.operator if operator is operators.is_: @@ -95,7 +95,7 @@ class EvaluatorCompiler(object): return operator(eval_left(obj), eval_right(obj)) else: raise UnevaluatableError( - "Cannot evaluate %s with operator %s" % + "Cannot evaluate %s with operator %s" % (type(clause).__name__, clause.operator)) return evaluate @@ -109,7 +109,7 @@ class EvaluatorCompiler(object): return not value return evaluate raise UnevaluatableError( - "Cannot evaluate %s with operator %s" % + "Cannot evaluate %s with operator %s" % (type(clause).__name__, clause.operator)) def visit_bindparam(self, clause): diff --git a/lib/sqlalchemy/orm/exc.py b/lib/sqlalchemy/orm/exc.py index d42dd42a7..783434504 100644 --- a/lib/sqlalchemy/orm/exc.py +++ b/lib/sqlalchemy/orm/exc.py @@ -18,13 +18,13 @@ class StaleDataError(sa_exc.SQLAlchemyError): Conditions which cause this to happen include: * A flush may have attempted to update or delete rows - and an unexpected number of rows were matched during - the UPDATE or DELETE statement. Note that when + and an unexpected number of rows were matched during + the UPDATE or DELETE statement. Note that when version_id_col is used, rows in UPDATE or DELETE statements are also matched against the current known version identifier. - * A mapped object with version_id_col was refreshed, + * A mapped object with version_id_col was refreshed, and the version number coming back from the database does not match that of the object itself. @@ -52,7 +52,7 @@ class ObjectDereferencedError(sa_exc.SQLAlchemyError): """An operation cannot complete due to an object being garbage collected.""" class DetachedInstanceError(sa_exc.SQLAlchemyError): - """An attempt to access unloaded attributes on a + """An attempt to access unloaded attributes on a mapped instance that is detached.""" class UnmappedInstanceError(UnmappedError): @@ -91,21 +91,21 @@ class UnmappedClassError(UnmappedError): class ObjectDeletedError(sa_exc.InvalidRequestError): """A refresh operation failed to retrieve the database row corresponding to an object's known primary key identity. - - A refresh operation proceeds when an expired attribute is + + A refresh operation proceeds when an expired attribute is accessed on an object, or when :meth:`.Query.get` is used to retrieve an object which is, upon retrieval, detected as expired. A SELECT is emitted for the target row based on primary key; if no row is returned, this exception is raised. - - The true meaning of this exception is simply that + + The true meaning of this exception is simply that no row exists for the primary key identifier associated - with a persistent object. The row may have been + with a persistent object. The row may have been deleted, or in some cases the primary key updated to a new value, outside of the ORM's management of the target - object. - + object. + """ def __init__(self, state, msg=None): if not msg: diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py index 4ba54b2f0..6fd184350 100644 --- a/lib/sqlalchemy/orm/identity.py +++ b/lib/sqlalchemy/orm/identity.py @@ -117,7 +117,7 @@ class WeakInstanceDict(IdentityMap): o = existing_state._is_really_none() if o is not None: raise AssertionError("A conflicting state is already " - "present in the identity map for key %r" + "present in the identity map for key %r" % (key, )) else: return diff --git a/lib/sqlalchemy/orm/scoping.py b/lib/sqlalchemy/orm/scoping.py index 940ae1db9..649ab7b87 100644 --- a/lib/sqlalchemy/orm/scoping.py +++ b/lib/sqlalchemy/orm/scoping.py @@ -15,10 +15,10 @@ __all__ = ['ScopedSession'] class ScopedSession(object): """Provides thread-local management of Sessions. - + Typical invocation is via the :func:`.scoped_session` function:: - + Session = scoped_session(sessionmaker()) The internal registry is accessible, @@ -70,7 +70,7 @@ class ScopedSession(object): self.session_factory.configure(**kwargs) def query_property(self, query_cls=None): - """return a class property which produces a `Query` object + """return a class property which produces a `Query` object against the class when called. e.g.:: @@ -121,7 +121,7 @@ def makeprop(name): def get(self): return getattr(self.registry(), name) return property(get, set) -for prop in ('bind', 'dirty', 'deleted', 'new', 'identity_map', +for prop in ('bind', 'dirty', 'deleted', 'new', 'identity_map', 'is_active', 'autoflush', 'no_autoflush'): setattr(ScopedSession, prop, makeprop(prop)) diff --git a/lib/sqlalchemy/orm/sync.py b/lib/sqlalchemy/orm/sync.py index 6f1e6c166..2b2f6d092 100644 --- a/lib/sqlalchemy/orm/sync.py +++ b/lib/sqlalchemy/orm/sync.py @@ -4,14 +4,14 @@ # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -"""private module containing functions used for copying data +"""private module containing functions used for copying data between instances based on join conditions. """ from . import exc, util as orm_util, attributes -def populate(source, source_mapper, dest, dest_mapper, +def populate(source, source_mapper, dest, dest_mapper, synchronize_pairs, uowcommit, flag_cascaded_pks): source_dict = source.dict dest_dict = dest.dict @@ -20,7 +20,7 @@ def populate(source, source_mapper, dest, dest_mapper, try: # inline of source_mapper._get_state_attr_by_column prop = source_mapper._columntoproperty[l] - value = source.manager[prop.key].impl.get(source, source_dict, + value = source.manager[prop.key].impl.get(source, source_dict, attributes.PASSIVE_OFF) except exc.UnmappedColumnError: _raise_col_to_prop(False, source_mapper, l, dest_mapper, r) @@ -47,7 +47,7 @@ def clear(dest, dest_mapper, synchronize_pairs): if r.primary_key: raise AssertionError( "Dependency rule tried to blank-out primary key " - "column '%s' on instance '%s'" % + "column '%s' on instance '%s'" % (r, orm_util.state_str(dest)) ) try: @@ -75,7 +75,7 @@ def populate_dict(source, source_mapper, dict_, synchronize_pairs): dict_[r.key] = value def source_modified(uowcommit, source, source_mapper, synchronize_pairs): - """return true if the source object has changes from an old to a + """return true if the source object has changes from an old to a new value on the given synchronize pairs """ @@ -84,7 +84,7 @@ def source_modified(uowcommit, source, source_mapper, synchronize_pairs): prop = source_mapper._columntoproperty[l] except exc.UnmappedColumnError: _raise_col_to_prop(False, source_mapper, l, None, r) - history = uowcommit.get_attribute_history(source, prop.key, + history = uowcommit.get_attribute_history(source, prop.key, attributes.PASSIVE_NO_INITIALIZE) return bool(history.deleted) else: |
