if objects:
util.warn_deprecated(
"The 'objects' argument to session.flush() is deprecated; "
- "Please do not add objects to the session which should not yet be persisted.")
+ "Please do not add objects to the session which should not "
+ "yet be persisted.")
if self._flushing:
raise sa_exc.InvalidRequestError("Session is already flushing")
["any parent '%s' instance "
"via that classes' '%s' attribute" %
(cls.__name__, key)
- for (key, cls) in chain(*(m.delete_orphans for m in _state_mapper(state).iterate_to_root()))])
+ for (key, cls) in chain(*(
+ m.delete_orphans for m in _state_mapper(state).iterate_to_root()
+ ))
+ ])
raise exc.FlushError(
"Instance %s is an unsaved, pending instance and is an "
"orphan (is not attached to %s)" % (
return self.obj()
def modified_event(self, dict_, attr, should_copy, previous, passive=PASSIVE_OFF):
- needs_committed = attr.key not in self.committed_state
-
- if needs_committed:
+ if attr.key not in self.committed_state:
if previous is NEVER_SET:
if passive:
if attr.key in dict_:
if should_copy and previous not in (None, NO_VALUE, NEVER_SET):
previous = attr.copy(previous)
- if needs_committed:
- self.committed_state[attr.key] = previous
+ self.committed_state[attr.key] = previous
if not self.modified:
instance_dict = self._instance_dict()
if instance_dict:
instance_dict._modified.add(self)
- self.modified = True
- if self._strong_obj is None:
self._strong_obj = self.obj()
+ self.modified = True
+
def commit(self, dict_, keys):
"""Commit attributes.
self.remove(item)
return item
+ def union(self, other):
+ return RandomSet(set.union(self, other))
+
+ def difference(self, other):
+ return RandomSet(set.difference(self, other))
+
+ def intersection(self, other):
+ return RandomSet(set.intersection(self, other))
+
+ def copy(self):
+ return RandomSet(self)
\ No newline at end of file
dict.__repr__(self))
class frozendict(dict):
+ @property
def _blocked_attribute(obj):
raise AttributeError, "A frozendict cannot be modified."
- _blocked_attribute = property(_blocked_attribute)
__delitem__ = __setitem__ = clear = _blocked_attribute
pop = popitem = setdefault = update = _blocked_attribute
SA_Metadata.create_all(engine)
-@profiling.profiled('large_flush', always=True, sort=['cumulative'])
+@profiling.profiled('large_flush', always=True, sort=['file'])
def generate_error():
q = Q()
for j in range(100): #at 306 the error does not pop out (depending on recursion depth)