当前位置: 首页>>代码示例>>Python>>正文


Python ClientStorage.pack方法代码示例

本文整理汇总了Python中ZEO.ClientStorage.ClientStorage.pack方法的典型用法代码示例。如果您正苦于以下问题:Python ClientStorage.pack方法的具体用法?Python ClientStorage.pack怎么用?Python ClientStorage.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZEO.ClientStorage.ClientStorage的用法示例。


在下文中一共展示了ClientStorage.pack方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]
def main(host, port, unix=None, days=1, username=None, password=None,
         realm=None, blob_dir=None, storage='1'):
    if unix is not None:
        addr = unix
    else:
        if host is None:
            host = socket.gethostname()
        addr = host, int(port)

    wait = True
    cs = None
    try:
        if HAS_BLOB:
            cs = ClientStorage(
                addr, storage=storage, wait=wait, read_only=True,
                username=username, password=password, realm=realm,
                blob_dir=blob_dir
            )
        else:
            cs = ClientStorage(
                addr, storage=storage, wait=wait, read_only=True,
                username=username, password=password, realm=realm
            )
        cs.pack(wait=wait, days=int(days))
    finally:
        if cs is not None:
            cs.close()
开发者ID:ale-rt,项目名称:plone.recipe.zope2zeoserver,代码行数:29,代码来源:pack.py

示例2: _main

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]
def _main(host, port, unix=None, days=1, username=None, password=None,
         realm=None, blob_dir=None, storage='1', shared_blob_dir=True):
    if unix is not None:
        addr = unix
    else:
        if host is None:
            host = socket.gethostname()
        addr = host, int(port)

    if blob_dir:
        blob_dir = os.path.abspath(blob_dir)

    # We do not want to wait until a zeoserver is up and running; it
    # should already be running.
    wait = False
    cs = None
    try:
        cs = ClientStorage(
            addr, storage=storage, wait=wait, read_only=True,
            username=username, password=password, realm=realm,
            blob_dir=blob_dir, shared_blob_dir=shared_blob_dir,
        )
        try:
            cs.pack(wait=wait, days=int(days))
        except ClientDisconnected:
            logger = logging.getLogger(__name__)
            logger.error("Could not connect to zeoserver. Please make sure it "
                         "is running.")
            sys.exit(1)
    finally:
        if cs is not None:
            cs.close()
开发者ID:RohitKumar13,项目名称:plone.recipe.zeoserver,代码行数:34,代码来源:pack.py

示例3: pack

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]
def pack(addr, storage, days, wait):
    cs = ClientStorage(addr, storage=storage, wait_for_server_on_startup=wait)
    if wait:
        # _startup() is an artifact of the way ZEO 1.0 works.  The
        # ClientStorage doesn't get fully initialized until registerDB()
        # is called.  The only thing we care about, though, is that
        # registerDB() calls _startup().
        cs._startup()
    else:
        connect(cs)
    cs.invalidator = None
    cs.pack(wait=1, days=days)
    cs.close()
开发者ID:OS2World,项目名称:APP-SERVER-Zope,代码行数:15,代码来源:zeopack.py

示例4: _main

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]
def _main(host, port, unix=None, days=1, username=None, password=None,
         realm=None, blob_dir=None, storage='1', shared_blob_dir=True):
    if unix is not None:
        addr = unix
    else:
        if host is None:
            host = socket.gethostname()
        addr = host, int(port)

    if blob_dir:
        blob_dir = os.path.abspath(blob_dir)

    wait = True
    cs = None
    try:
        cs = ClientStorage(
            addr, storage=storage, wait=wait, read_only=True,
            username=username, password=password, realm=realm,
            blob_dir=blob_dir, shared_blob_dir=shared_blob_dir,
        )
        cs.pack(wait=wait, days=int(days))
    finally:
        if cs is not None:
            cs.close()
开发者ID:isotoma,项目名称:isotoma.recipe.zeo,代码行数:26,代码来源:pack.py

示例5: Shelf

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]

#.........这里部分代码省略.........
        self._delConnObject()

    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):
        """
开发者ID:Ictp,项目名称:indico,代码行数:70,代码来源:manager.py

示例6: pack2

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]
def pack2(addr, storage, days):
    cs = ClientStorage(addr, storage=storage, wait=1, read_only=1)
    cs.pack(wait=1, days=days)
    cs.close()
开发者ID:VishrutMehta,项目名称:indico,代码行数:6,代码来源:zeopack.py

示例7: int

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [as 别名]
host = 'IP OR HOST'
port = PORT NUMBER
addr = host, int(port)
wait = True
days = 7

# Log initialize
logger = logging.getLogger('Instance Pack')
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(logpath)
fh.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)


cs = ClientStorage(addr,storage='1',wait=wait,read_only=True,username=None,password=None,realm=None)
logger.info('Pack initialize \n ---------------------------------')

cs.pack(wait=wait, days=int(days))

noSecurityManager()

transaction.savepoint(1)
transaction.commit()
app._p_jar.sync()

logger.info('Pack finally \n ---------------------------------')
开发者ID:adam139,项目名称:snippet,代码行数:32,代码来源:ZeoPackInstance.py

示例8: Shelf

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import pack [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
开发者ID:davidmorrison,项目名称:indico,代码行数:104,代码来源:db.py


注:本文中的ZEO.ClientStorage.ClientStorage.pack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。