Example #1
0
    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()
Example #2
0
 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()
Example #3
0
    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)
Example #4
0
    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))
Example #5
0
    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)))))
Example #6
0
 def iterdirty(self):
     '''Ordered iterator over dirty elements.'''
     return iter(chain(itervalues(self._new), itervalues(self._modified)))
Example #7
0
    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)))
Example #8
0
    def modified(self):
        '''The set of all modified instances within this ``Session``. This
instances will.'''
        return tuple(itervalues(self._modified))
Example #9
0
    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)))))
Example #10
0
 def iterdirty(self):
     '''Ordered iterator over dirty elements.'''
     return iter(chain(itervalues(self._new), itervalues(self._modified)))
Example #11
0
 def dirty(self):
     '''set of all changed instances in the session'''
     return frozenset(chain(*tuple((sm.dirty for sm\
                                     in itervalues(self._models)))))
Example #12
0
    def deleted(self):
        '''The set of all instances marked as 'deleted' within this
:class:`Session`.'''
        return frozenset(itervalues(self._deleted))
Example #13
0
    def loaded(self):
        '''The set of all unmodified, but not deleted, instances within this
:class:`Session`.'''
        return frozenset(itervalues(self._loaded))
Example #14
0
 def modified(self):
     "The set of all modified instances within this ``Session``"
     return frozenset(itervalues(self._modified))
Example #15
0
    def modified(self):
        '''The set of all modified instances within this ``Session``. This
instances will.'''
        return tuple(itervalues(self._modified))
Example #16
0
    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)))
Example #17
0
    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))