コード例 #1
0
ファイル: session.py プロジェクト: kuno/python-stdnet
    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()
コード例 #2
0
ファイル: struct.py プロジェクト: kuno/python-stdnet
 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()
コード例 #3
0
ファイル: struct.py プロジェクト: kuno/python-stdnet
    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)
コード例 #4
0
ファイル: session.py プロジェクト: AlecTaylor/python-stdnet
    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))
コード例 #5
0
ファイル: session.py プロジェクト: AlecTaylor/python-stdnet
    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)))))
コード例 #6
0
ファイル: session.py プロジェクト: AlecTaylor/python-stdnet
 def iterdirty(self):
     '''Ordered iterator over dirty elements.'''
     return iter(chain(itervalues(self._new), itervalues(self._modified)))
コード例 #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)))
コード例 #8
0
    def modified(self):
        '''The set of all modified instances within this ``Session``. This
instances will.'''
        return tuple(itervalues(self._modified))
コード例 #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)))))
コード例 #10
0
 def iterdirty(self):
     '''Ordered iterator over dirty elements.'''
     return iter(chain(itervalues(self._new), itervalues(self._modified)))
コード例 #11
0
ファイル: session.py プロジェクト: abulte/python-stdnet
 def dirty(self):
     '''set of all changed instances in the session'''
     return frozenset(chain(*tuple((sm.dirty for sm\
                                     in itervalues(self._models)))))
コード例 #12
0
ファイル: session.py プロジェクト: abulte/python-stdnet
    def deleted(self):
        '''The set of all instances marked as 'deleted' within this
:class:`Session`.'''
        return frozenset(itervalues(self._deleted))
コード例 #13
0
ファイル: session.py プロジェクト: abulte/python-stdnet
    def loaded(self):
        '''The set of all unmodified, but not deleted, instances within this
:class:`Session`.'''
        return frozenset(itervalues(self._loaded))
コード例 #14
0
ファイル: session.py プロジェクト: abulte/python-stdnet
 def modified(self):
     "The set of all modified instances within this ``Session``"
     return frozenset(itervalues(self._modified))
コード例 #15
0
ファイル: session.py プロジェクト: AlecTaylor/python-stdnet
    def modified(self):
        '''The set of all modified instances within this ``Session``. This
instances will.'''
        return tuple(itervalues(self._modified))
コード例 #16
0
ファイル: session.py プロジェクト: AlecTaylor/python-stdnet
    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)))
コード例 #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))