def __init__(self, namespace, dbmmodule=None, data_dir=None, dbm_dir=None, lock_dir=None, digest_filenames=True, **kwargs): self.digest_filenames = digest_filenames if not dbm_dir and not data_dir: raise MissingCacheParameter("data_dir or dbm_dir is required") elif dbm_dir: self.dbm_dir = dbm_dir else: self.dbm_dir = data_dir + "/container_dbm" util.verify_directory(self.dbm_dir) if not lock_dir and not data_dir: raise MissingCacheParameter("data_dir or lock_dir is required") elif lock_dir: self.lock_dir = lock_dir else: self.lock_dir = data_dir + "/container_dbm_lock" util.verify_directory(self.lock_dir) self.dbmmodule = dbmmodule or anydbm self.dbm = None OpenResourceNamespaceManager.__init__(self, namespace) self.file = util.encoded_path(root= self.dbm_dir, identifiers=[self.namespace], extension='.dbm', digest_filenames=self.digest_filenames) debug("data file %s", self.file) self._checkfile()
def __init__(self, namespace, data_dir=None, file_dir=None, lock_dir=None, digest_filenames=True, **kwargs): self.digest_filenames = digest_filenames if not file_dir and not data_dir: raise MissingCacheParameter("data_dir or file_dir is required") elif file_dir: self.file_dir = file_dir else: self.file_dir = data_dir + "/container_file" util.verify_directory(self.file_dir) if not lock_dir and not data_dir: raise MissingCacheParameter("data_dir or lock_dir is required") elif lock_dir: self.lock_dir = lock_dir else: self.lock_dir = data_dir + "/container_file_lock" util.verify_directory(self.lock_dir) OpenResourceNamespaceManager.__init__(self, namespace) self.file = util.encoded_path(root=self.file_dir, identifiers=[self.namespace], extension='.cache', digest_filenames=self.digest_filenames) self.hash = {} debug("data file %s", self.file)
def __init__(self, namespace, data_dir = None, file_dir = None, lock_dir = None, digest_filenames = True, **kwargs): NamespaceManager.__init__(self, namespace, **kwargs) if file_dir is not None: self.file_dir = file_dir elif data_dir is None: raise MissingCacheParameter("data_dir or file_dir is required") else: self.file_dir = data_dir + "/container_file" if lock_dir is not None: self.lock_dir = lock_dir elif data_dir is None: raise MissingCacheParameter("data_dir or lock_dir is required") else: self.lock_dir = data_dir + "/container_file_lock" util.verify_directory(self.file_dir) util.verify_directory(self.lock_dir) self.lock = Synchronizer(identifier=self.namespace, use_files=True, lock_dir=self.lock_dir, digest_filenames=digest_filenames) self.file = util.encoded_path(root=self.file_dir, identifiers=[self.namespace], digest=digest_filenames, extension='.cache') self.hash = {} self.debug("data file %s" % self.file)
def test_beaker_cache(): func = BeakerCacheController.index cache_name = '%s.%s' % (func.__module__, func.__name__) path = encoded_path(data_dir + "/container_dbm", [cache_name], extension=".dbm", digest_filenames=True) cache_key = '[][]' wsgiapp = make_app() app = paste.fixture.TestApp(wsgiapp) response = app.get('/', extra_environ={'resource': "XYZ"}) assert response.status == 200 assert response.body == "200 OK" with closing(dbm.open(path)) as db: assert cache_key in db storedtime, expiretime, value = pickle.loads(db[cache_key]) assert value["status"] == 200 assert value["content"] == "200 OK" response = app.get('/', status=404) assert response.status == 404 with closing(dbm.open(path)) as db: assert cache_key not in db
def __init__(self, identifier, lock_dir): super(FileSynchronizer, self).__init__() self._filedescriptor = util.ThreadLocal() if lock_dir is None: lock_dir = tempfile.gettempdir() else: lock_dir = lock_dir self.filename = util.encoded_path(lock_dir, [identifier], extension='.lock')
def __init__(self, identifier, lock_dir, digest_filenames): self.state = SyncState() if lock_dir is None: lock_dir = tempfile.gettempdir() else: lock_dir = lock_dir self.filename = util.encoded_path(lock_dir, [identifier], extension=".lock", digest=digest_filenames) self.opened = False self.filedesc = None
def __init__(self, identifier, lock_dir): super(FileSynchronizer, self).__init__() self._filedescriptor = util.ThreadLocal() if lock_dir is None: lock_dir = tempfile.gettempdir() else: lock_dir = lock_dir self.filename = util.encoded_path( lock_dir, [identifier], extension='.lock' )
def __init__(self, identifier, lock_dir, digest_filenames): self.state = SyncState() if lock_dir is None: lock_dir = tempfile.gettempdir() else: lock_dir = lock_dir self.filename = util.encoded_path(lock_dir, [identifier], extension='.lock', digest=digest_filenames) self.opened = False self.filedesc = None
def __init__(self, namespace, dbmmodule=None, data_dir=None, dbm_dir=None, lock_dir=None, digest_filenames=True, **kwargs): NamespaceManager.__init__(self, namespace, **kwargs) if dbm_dir is not None: self.dbm_dir = dbm_dir elif data_dir is None: raise MissingCacheParameter("data_dir or dbm_dir is required") else: self.dbm_dir = data_dir + "/container_dbm" if lock_dir is not None: self.lock_dir = lock_dir elif data_dir is None: raise MissingCacheParameter("data_dir or lock_dir is required") else: self.lock_dir = data_dir + "/container_dbm_lock" if dbmmodule is None: import anydbm self.dbmmodule = anydbm else: self.dbmmodule = dbmmodule util.verify_directory(self.dbm_dir) util.verify_directory(self.lock_dir) self.dbm = None self.lock = Synchronizer(identifier=self.namespace, use_files=True, lock_dir=self.lock_dir, digest_filenames=digest_filenames) self.file = util.encoded_path(root=self.dbm_dir, identifiers=[self.namespace], digest=digest_filenames, extension='.dbm') self.debug("data file %s" % self.file) self._checkfile()
def __init__(self, namespace, dbmmodule = None, data_dir = None, dbm_dir = None, lock_dir = None, digest_filenames = True, **kwargs): NamespaceManager.__init__(self, namespace, **kwargs) if dbm_dir is not None: self.dbm_dir = dbm_dir elif data_dir is None: raise MissingCacheParameter("data_dir or dbm_dir is required") else: self.dbm_dir = data_dir + "/container_dbm" if lock_dir is not None: self.lock_dir = lock_dir elif data_dir is None: raise MissingCacheParameter("data_dir or lock_dir is required") else: self.lock_dir = data_dir + "/container_dbm_lock" if dbmmodule is None: import anydbm self.dbmmodule = anydbm else: self.dbmmodule = dbmmodule util.verify_directory(self.dbm_dir) util.verify_directory(self.lock_dir) self.dbm = None self.lock = Synchronizer(identifier=self.namespace, use_files=True, lock_dir=self.lock_dir, digest_filenames=digest_filenames) self.file = util.encoded_path(root= self.dbm_dir, identifiers=[self.namespace], digest=digest_filenames, extension='.dbm') self.debug("data file %s" % self.file) self._checkfile()
def __init__(self, namespace, data_dir=None, file_dir=None, lock_dir=None, digest_filenames=True, **kwargs): NamespaceManager.__init__(self, namespace, **kwargs) if file_dir is not None: self.file_dir = file_dir elif data_dir is None: raise MissingCacheParameter("data_dir or file_dir is required") else: self.file_dir = data_dir + "/container_file" if lock_dir is not None: self.lock_dir = lock_dir elif data_dir is None: raise MissingCacheParameter("data_dir or lock_dir is required") else: self.lock_dir = data_dir + "/container_file_lock" util.verify_directory(self.file_dir) util.verify_directory(self.lock_dir) self.lock = Synchronizer(identifier=self.namespace, use_files=True, lock_dir=self.lock_dir, digest_filenames=digest_filenames) self.file = util.encoded_path(root=self.file_dir, identifiers=[self.namespace], digest=digest_filenames, extension='.cache') self.hash = {} self.debug("data file %s" % self.file)