示例#1
0
 def __init__(self, name, blob_dir, shared=False, extrafsoptions=""):
     if shared:
         server_blob_dir = blob_dir
     else:
         server_blob_dir = "server-" + blob_dir
     self.globs = {}
     port = forker.get_port2(self)
     addr, admin, pid, config = forker.start_zeo_server(
         """
         <blobstorage>
             blob-dir %s
             <filestorage>
                path %s
                %s
             </filestorage>
         </blobstorage>
         """
         % (server_blob_dir, name + ".fs", extrafsoptions),
         port=port,
     )
     os.remove(config)
     zope.testing.setupstack.register(self, os.waitpid, pid, 0)
     zope.testing.setupstack.register(self, forker.shutdown_zeo_server, admin)
     if shared:
         ClientStorage.__init__(self, addr, blob_dir=blob_dir, shared_blob_dir=True)
     else:
         ClientStorage.__init__(self, addr, blob_dir=blob_dir)
示例#2
0
    def __init__(self, addr, storage='1', cache_size=20 * MB,
                 name='', client=None, debug=0, var=None,
                 min_disconnect_poll=5, max_disconnect_poll=300,
                 wait_for_server_on_startup=None, # deprecated alias for wait
                 wait=None, wait_timeout=None,
                 read_only=0, read_only_fallback=0,
                 username='', password='', realm=None):


        # swap out the ClientCache with QonClientCache if desired.
        self.ClientCacheClass = ClientCache
        if qon.local.CACHE_INSTRUMENTATION:
            self.ClientCacheClass = QonClientCache
            
        ClientStorage.__init__(self, addr, storage, cache_size, \
                               name, client, debug, var, \
                               min_disconnect_poll, max_disconnect_poll, \
                               wait_for_server_on_startup, \
                               wait, wait_timeout, \
                               read_only, read_only_fallback, \
                               username, password, realm)

        # fix the cache_size bug that we manually patched previously.
        # once ZEO's code is fixed, we can remove everything after
        #  this line of code in this routine.
        if self._cache:
            self._cache.close()
            del self._cache

        # Decide whether to use non-temporary files
        if client is not None:
            dir = var or os.getcwd()
            cache_path = os.path.join(dir, "%s-%s.zec" % (client, storage))
        else:
            cache_path = None

        # create the cache            
        self._cache = self.ClientCacheClass(cache_path, size=cache_size) # this here is that actual cache_size fix
        self._cache.open()