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


Python ClientStorage.close方法代码示例

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


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

示例1: main

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [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 close [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 close [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: remoteZODB

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
class remoteZODB(object):

    def __init__(self, server, port):
        server_and_port = (server, port)
        self.storage = ClientStorage(server_and_port, storage='data',
                                     read_only=True, wait=False, )
        self.db = DB(self.storage)
        self.connection = self.db.open()
        self.dbroot = self.connection.root()

    def close(self):
        self.connection.close()
        self.db.close()
        self.storage.close()
开发者ID:maerteijn,项目名称:maerteijn,代码行数:16,代码来源:check_zodb_written.py

示例5: checkVolatileCacheWithImmediateLastTransaction

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
    def checkVolatileCacheWithImmediateLastTransaction(self):
        # Earlier, a ClientStorage would not have the last transaction id
        # available right after successful connection, this is required now.
        addr = self._storage._addr
        storage2 = ClientStorage(addr)
        self.assert_(storage2.is_connected())
        self.assertEquals(None, storage2.lastTransaction())
        storage2.close()

        self._dostore()
        storage3 = ClientStorage(addr)
        self.assert_(storage3.is_connected())
        self.assertEquals(8, len(storage3.lastTransaction()))
        self.assertNotEquals(ZODB.utils.z64, storage3.lastTransaction())
        storage3.close()
开发者ID:grodniewicz,项目名称:oship,代码行数:17,代码来源:testZEO.py

示例6: DB

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
    class DB(BaseDB):
        def __init__(self, server=SERVER, port=PORT):
            self.storage = ClientStorage((server, port,))
            self.db = ZDB(self.storage)
            self.connection = self.db.open()
            self.dbroot = self.connection.root()


        # KISS policy
        # let the lookup raise its own exception on a key lookup problem, etc
        def get(self, key):
            return self.dbroot[key]


        def put(self, key, data):
            self.dbroot[key] = data

        def update(self, key, data):
            if isinstance(data, Persistent):
                data._p_changed = True
            else:
                self.dbroot[key] = data

        def delete(self, key):
            if key in self.dbroot:
                del self.dbroot[key]
            

        def commit(self):
            transaction.commit()


        def abort(self):
            transaction.abort()

        def contains(self, key):
            return key in self.dbroot



        def close(self):
            self.connection.close()
            self.db.close()
            self.storage.close()
开发者ID:HVF,项目名称:Python-OAuth-2.0-Provider,代码行数:46,代码来源:DB.py

示例7: checkZEOInvalidation

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
 def checkZEOInvalidation(self):
     addr = self._storage._addr
     storage2 = ClientStorage(addr, wait=1, min_disconnect_poll=0.1)
     try:
         oid = self._storage.new_oid()
         ob = MinPO('first')
         revid1 = self._dostore(oid, data=ob)
         data, serial = storage2.load(oid, '')
         self.assertEqual(zodb_unpickle(data), MinPO('first'))
         self.assertEqual(serial, revid1)
         revid2 = self._dostore(oid, data=MinPO('second'), revid=revid1)
         for n in range(3):
             # Let the server and client talk for a moment.
             # Is there a better way to do this?
             asyncore.poll(0.1)
         data, serial = storage2.load(oid, '')
         self.assertEqual(zodb_unpickle(data), MinPO('second'),
                          'Invalidation message was not sent!')
         self.assertEqual(serial, revid2)
     finally:
         storage2.close()
开发者ID:wpjunior,项目名称:proled,代码行数:23,代码来源:testZEO.py

示例8: check_server

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
def check_server(addr, storage, write):
    t0 = time.time()
    if ZEO_VERSION == 2:
        # TODO:  should do retries w/ exponential backoff.
        cs = ClientStorage(addr, storage=storage, wait=0,
                           read_only=(not write))
    else:
        cs = ClientStorage(addr, storage=storage, debug=1,
                           wait_for_server_on_startup=1)
    # _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().

    if write:
        db = ZODB.DB(cs)
        cn = db.open()
        root = cn.root()
        try:
            # We store the data in a special `monitor' dict under the root,
            # where other tools may also store such heartbeat and bookkeeping
            # type data.
            monitor = root.get('monitor')
            if monitor is None:
                monitor = root['monitor'] = PersistentMapping()
            obj = monitor['zeoup'] = monitor.get('zeoup', MinPO(0))
            obj.value += 1
            transaction.commit()
        except ConflictError:
            pass
        cn.close()
        db.close()
    else:
        data, serial = cs.load("\0\0\0\0\0\0\0\0", "")
        cs.close()
    t1 = time.time()
    print "Elapsed time: %.2f" % (t1 - t0)
开发者ID:wpjunior,项目名称:proled,代码行数:39,代码来源:zeoup.py

示例9: checkZEOInvalidation

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
    def checkZEOInvalidation(self):
        addr = self._storage._addr
        storage2 = ClientStorage(addr, wait=1, min_disconnect_poll=0.1)
        try:
            oid = self._storage.new_oid()
            ob = MinPO("first")
            revid1 = self._dostore(oid, data=ob)
            data, serial = storage2.load(oid, "")
            self.assertEqual(zodb_unpickle(data), MinPO("first"))
            self.assertEqual(serial, revid1)
            revid2 = self._dostore(oid, data=MinPO("second"), revid=revid1)

            # Now, storage 2 should eventually get the new data. It
            # will take some time, although hopefully not much.
            # We'll poll till we get it and whine if we time out:
            for n in range(30):
                time.sleep(0.1)
                data, serial = storage2.load(oid, "")
                if serial == revid2 and zodb_unpickle(data) == MinPO("second"):
                    break
            else:
                raise AssertionError("Invalidation message was not sent!")
        finally:
            storage2.close()
开发者ID:grodniewicz,项目名称:oship,代码行数:26,代码来源:testZEO.py

示例10: _main

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [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

示例11: GenericTests

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
class GenericTests(
    # Base class for all ZODB tests
    StorageTestBase.StorageTestBase,
    # ZODB test mixin classes (in the same order as imported)
    BasicStorage.BasicStorage,
    PackableStorage.PackableStorage,
    Synchronization.SynchronizedStorage,
    MTStorage.MTStorage,
    ReadOnlyStorage.ReadOnlyStorage,
    # ZEO test mixin classes (in the same order as imported)
    CommitLockTests.CommitLockVoteTests,
    ThreadTests.ThreadTests,
    # Locally defined (see above)
    MiscZEOTests,
):

    """Combine tests from various origins in one class."""

    shared_blob_dir = False
    blob_cache_dir = None

    def setUp(self):
        StorageTestBase.StorageTestBase.setUp(self)
        logger.info("setUp() %s", self.id())
        port = get_port(self)
        zconf = forker.ZEOConfig(("", port))
        zport, adminaddr, pid, path = forker.start_zeo_server(self.getConfig(), zconf, port)
        self._pids = [pid]
        self._servers = [adminaddr]
        self._conf_path = path
        if not self.blob_cache_dir:
            # This is the blob cache for ClientStorage
            self.blob_cache_dir = tempfile.mkdtemp("blob_cache", dir=os.path.abspath(os.getcwd()))
        self._storage = ClientStorage(
            zport,
            "1",
            cache_size=20000000,
            min_disconnect_poll=0.5,
            wait=1,
            wait_timeout=60,
            blob_dir=self.blob_cache_dir,
            shared_blob_dir=self.shared_blob_dir,
        )
        self._storage.registerDB(DummyDB())

    def tearDown(self):
        self._storage.close()
        for server in self._servers:
            forker.shutdown_zeo_server(server)
        if hasattr(os, "waitpid"):
            # Not in Windows Python until 2.3
            for pid in self._pids:
                os.waitpid(pid, 0)
        StorageTestBase.StorageTestBase.tearDown(self)

    def runTest(self):
        try:
            super(GenericTests, self).runTest()
        except:
            self._failed = True
            raise
        else:
            self._failed = False

    def open(self, read_only=0):
        # Needed to support ReadOnlyStorage tests.  Ought to be a
        # cleaner way.
        addr = self._storage._addr
        self._storage.close()
        self._storage = ClientStorage(addr, read_only=read_only, wait=1)

    def checkWriteMethods(self):
        # ReadOnlyStorage defines checkWriteMethods.  The decision
        # about where to raise the read-only error was changed after
        # Zope 2.5 was released.  So this test needs to detect Zope
        # of the 2.5 vintage and skip the test.

        # The __version__ attribute was not present in Zope 2.5.
        if hasattr(ZODB, "__version__"):
            ReadOnlyStorage.ReadOnlyStorage.checkWriteMethods(self)

    def checkSortKey(self):
        key = "%s:%s" % (self._storage._storage, self._storage._server_addr)
        self.assertEqual(self._storage.sortKey(), key)
开发者ID:grodniewicz,项目名称:oship,代码行数:86,代码来源:testZEO.py

示例12: close

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
 def close(self):
     ClientStorage.close(self)
     zope.testing.setupstack.tearDown(self)
开发者ID:grodniewicz,项目名称:oship,代码行数:5,代码来源:testZEO.py

示例13: pack2

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [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

示例14: GenericTests

# 需要导入模块: from ZEO.ClientStorage import ClientStorage [as 别名]
# 或者: from ZEO.ClientStorage.ClientStorage import close [as 别名]
class GenericTests(
    # Base class for all ZODB tests
    StorageTestBase.StorageTestBase,
    # ZODB test mixin classes (in the same order as imported)
    BasicStorage.BasicStorage,
    PackableStorage.PackableStorage,
    Synchronization.SynchronizedStorage,
    MTStorage.MTStorage,
    ReadOnlyStorage.ReadOnlyStorage,
    # ZEO test mixin classes (in the same order as imported)
    CommitLockTests.CommitLockVoteTests,
    ThreadTests.ThreadTests,
    # Locally defined (see above)
    MiscZEOTests
    ):

    """Combine tests from various origins in one class."""

    def setUp(self):
        logger.info("setUp() %s", self.id())
        port = get_port()
        zconf = forker.ZEOConfig(('', port))
        zport, adminaddr, pid, path = forker.start_zeo_server(self.getConfig(),
                                                              zconf, port)
        self._pids = [pid]
        self._servers = [adminaddr]
        self._conf_path = path
        self._storage = ClientStorage(zport, '1', cache_size=20000000,
                                      min_disconnect_poll=0.5, wait=1,
                                      wait_timeout=60)
        self._storage.registerDB(DummyDB(), None)

    def tearDown(self):
        self._storage.close()
        os.remove(self._conf_path)
        for server in self._servers:
            forker.shutdown_zeo_server(server)
        if hasattr(os, 'waitpid'):
            # Not in Windows Python until 2.3
            for pid in self._pids:
                os.waitpid(pid, 0)

    def open(self, read_only=0):
        # Needed to support ReadOnlyStorage tests.  Ought to be a
        # cleaner way.
        addr = self._storage._addr
        self._storage.close()
        self._storage = ClientStorage(addr, read_only=read_only, wait=1)

    def checkWriteMethods(self):
        # ReadOnlyStorage defines checkWriteMethods.  The decision
        # about where to raise the read-only error was changed after
        # Zope 2.5 was released.  So this test needs to detect Zope
        # of the 2.5 vintage and skip the test.

        # The __version__ attribute was not present in Zope 2.5.
        if hasattr(ZODB, "__version__"):
            ReadOnlyStorage.ReadOnlyStorage.checkWriteMethods(self)

    def checkSortKey(self):
        key = '%s:%s' % (self._storage._storage, self._storage._server_addr)
        self.assertEqual(self._storage.sortKey(), key)
开发者ID:wpjunior,项目名称:proled,代码行数:64,代码来源:testZEO.py


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