def empty(self): '''Check if the transaction contains query data or not. If there is no query data the transaction does not perform any operation in the database.''' for c in itervalues(self._cachepipes): if c.pipe: return False return self.emptypipe()
def clear(cls, ids): if ids: for id in ids: s = self._structs.pop(id,None) if s: try: s.delete() except ConnectionError: pass else: for s in itervalues(cls._structs): try: s.delete() except ConnectionError: pass cls._structs.clear()
def values(self, keys = None): '''Generator overvalues. If keys is not supplied, it is a generator over value items. No transaction involved in this function.''' if self.cache: if self.keys: cache = self.cache.get for key in keys: yield cache(key) else: for item in itervalues(self.cache): yield item else: kloads = self.pickler.loads vloads = self.value_pickler.loads if keys: dumps = self.pickler.dumps keys = [dumps(k) for k in keys] for item in self._items(self.backend.cursor(),keys): yield vloads(item) else: for key,val in self._items(self.backend.cursor(),keys): yield vloads(val)
def new(self): '''The set of all new instances within this ``SessionModel``. This instances will be inserted in the database.''' return tuple(itervalues(self._new))
def dirty(self): '''The set of instances in this :class:`Session` which have been modified.''' return frozenset(chain(*tuple((sm.dirty for sm in itervalues(self._models)))))
def iterdirty(self): '''Ordered iterator over dirty elements.''' return iter(chain(itervalues(self._new), itervalues(self._modified)))
def deleted(self): '''The set of all instance pks marked as `deleted` within this :class:`Session`.''' return tuple((p.pkvalue() for p in itervalues(self._deleted)))
def modified(self): '''The set of all modified instances within this ``Session``. This instances will.''' return tuple(itervalues(self._modified))
def dirty(self): '''The set of instances in this :class:`Session` which have been modified.''' return frozenset( chain(*tuple((sm.dirty for sm in itervalues(self._models)))))
def iterdirty(self): '''Ordered iterator over dirty elements.''' return iter(chain(itervalues(self._new), itervalues(self._modified)))
def dirty(self): '''set of all changed instances in the session''' return frozenset(chain(*tuple((sm.dirty for sm\ in itervalues(self._models)))))
def deleted(self): '''The set of all instances marked as 'deleted' within this :class:`Session`.''' return frozenset(itervalues(self._deleted))
def loaded(self): '''The set of all unmodified, but not deleted, instances within this :class:`Session`.''' return frozenset(itervalues(self._loaded))
def modified(self): "The set of all modified instances within this ``Session``" return frozenset(itervalues(self._modified))
def modified(self): '''The set of all modified instances within this ``Session``. This instances will.''' return tuple(itervalues(self._modified))
def deleted(self): '''The set of all instance pks marked as `deleted` within this :class:`Session`.''' return tuple((p.pkvalue() for p in itervalues(self._deleted)))
def new(self): '''The set of all new instances within this ``SessionModel``. This instances will be inserted in the database.''' return tuple(itervalues(self._new))