本文整理汇总了Python中ZEO.ClientStorage.ClientStorage.getSize方法的典型用法代码示例。如果您正苦于以下问题:Python ClientStorage.getSize方法的具体用法?Python ClientStorage.getSize怎么用?Python ClientStorage.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZEO.ClientStorage.ClientStorage
的用法示例。
在下文中一共展示了ClientStorage.getSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Shelf
# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import getSize [as 别名]
#.........这里部分代码省略.........
def getDBConnection(self):
return self._getConnObject()
def isConnected(self):
return hasattr(self._conn, 'conn') and self._conn.conn is not None
def getDBConnCache(self):
conn = self._getConnObject()
return conn._cache
def getDBClassFactory(self):
return self._db.classFactory
def commit(self, sub=False):
import StringIO
import transaction._transaction
transaction._transaction.StringIO = StringIO.StringIO
if (sub):
transaction.savepoint()
else:
transaction.commit()
def commitZODBOld(self, sub=False):
transaction.commit(sub)
def abort(self):
transaction.abort()
def sync(self):
self._getConnObject().sync()
def pack(self, days=1):
self._storage.pack(days=days)
def undoInfo(self, stepNumber=0):
# One step is made of 1000 transactions. First step is 0 and returns
# transactions 0 to 999.
return self._db.undoInfo(stepNumber*1000, (stepNumber+1)*1000)
def undo(self, trans_id):
self._db.undo(trans_id)
def getDBSize(self):
"""Return an approximate size of the database, in bytes."""
return self._storage.getSize()
def loadObject(self, oid, version):
return self._storage.load(oid, version)
def storeObject(self, oid, serial, data, version, trans):
return self._storage.store(oid, serial, data, version, trans)
def tpcBegin(self, trans):
self._storage.tpc_begin(trans)
def tpcVote(self, trans):
self._storage.tpc_vote(trans)
def tpcFinish(self, trans):
self._storage.tpc_finish(trans)
@contextmanager
def transaction(self, sync=False):
"""
context manager (`with`)
"""
if sync:
self.sync()
yield self.getDBConnection()
self.commit()
@contextmanager
def global_connection(self, commit=False):
"""Helper if you NEED a connection and don't know if one is available or not.
Useful e.g. in flask code that runs outside a request"""
if self.isConnected():
yield
else:
self.startRequest()
try:
yield
finally:
self.endRequest(commit)
# ZODB version check
try:
zodbPkg = pkg_resources.require('ZODB3')[0]
zodbVersion = zodbPkg.parsed_version
zodbVersion = (int(zodbVersion[0]), int(zodbVersion[1]))
except pkg_resources.DistributionNotFound:
# Very old versions, in which ZODB didn't register
# with pkg_resources
import ZODB
zodbVersion = ZODB.__version__.split('.')
if int(zodbVersion[0]) < 3:
raise Exception("ZODB 3 required! %s found" % zodbPkg.version)
elif int(zodbVersion[1]) < 7:
commit = commitZODBOld
示例2: Shelf
# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import getSize [as 别名]
#.........这里部分代码省略.........
def endRequest( self, commit=True ):
"""Closes the DB and commits changes.
"""
if commit:
self.commit()
else:
self.abort()
#modification vendredi 010907
# try:
# self._conn.close()
# self._conn=None
# except:
# pass
self._getConnObject().close()
self._delConnObject()
def getDBConnection( self ):
conn = self._getConnObject()
if conn == None:
raise Exception( _("request not started"))
return conn
def isConnected( self ):
if self._getConnObject() == None:
return False
else:
return True
def getDBConnCache(self):
conn = self._getConnObject()
if conn == None:
raise Exception( _("request not started"))
return conn._cache
def getDBClassFactory(self):
return self._db.classFactory
def commit(self, sub=False):
if (sub):
transaction.savepoint()
else:
transaction.commit()
def commitZODBOld(self, sub=False):
transaction.commit(sub)
def abort(self):
transaction.abort()
def sync(self):
self._getConnObject().sync()
def pack( self, days=1 ):
self._storage.pack(days=days)
def undoInfo(self, stepNumber=0):
# One step is made of 1000 transactions. First step is 0 and returns
# transactions 0 to 999.
return self._db.undoInfo(stepNumber*1000, (stepNumber+1)*1000)
def undo(self, trans_id):
self._db.undo(trans_id)
def getDBSize( self ):
"""Return an approximate size of the database, in bytes."""
return self._storage.getSize()
def loadObject(self, oid, version):
return self._storage.load(oid, version)
def storeObject(self, oid, serial, data, version, trans):
return self._storage.store(oid, serial, data, version, trans)
def tpcBegin(self, trans):
self._storage.tpc_begin(trans)
def tpcVote(self, trans):
self._storage.tpc_vote(trans)
def tpcFinish(self, trans):
self._storage.tpc_finish(trans)
# ZODB version check
try:
zodbPkg = pkg_resources.require('ZODB3')[0]
zodbVersion = zodbPkg.parsed_version
zodbVersion = (int(zodbVersion[0]), int(zodbVersion[1]))
except pkg_resources.DistributionNotFound:
# Very old versions, in which ZODB didn't register
# with pkg_resources
import ZODB
zodbVersion = ZODB.__version__.split('.')
if int(zodbVersion[0]) < 3:
raise Exception("ZODB 3 required! %s found" % zodbPkg.version)
elif int(zodbVersion[1]) < 7:
commit = commitZODBOld