Example #1
0
    def __init__(self, *args, **config):
        super(database, self).__init__(*args, **config)

        default_db = config.get("dbtype", "anydbm")
        if not default_db.startswith("."):
            default_db = '.' + default_db

        self._db_path = os.path.join(
            self.location,
            fs_template.gen_label(self.location, self.label) + default_db)
        self.__db = None
        try:
            self.__db = anydbm_module.open(self._db_path, "w", self._perms)

        except anydbm_module.error:
            # XXX handle this at some point
            try:
                self._ensure_dirs()
                self._ensure_dirs(self._db_path)
                self._ensure_access(self._db_path)
            except (OSError, IOError), e:
                raise cache_errors.InitializationError(self.__class__, e)

            # try again if failed
            try:
                if self.__db == None:
                    self.__db = anydbm_module.open(self._db_path, "c",
                                                   self._perms)
            except andbm_module.error, e:
                raise cache_errors.InitializationError(self.__class__, e)
Example #2
0
	def _dbconnect(self, config):
		self._dbpath = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+".sqldb")
		try:
			self.db = sqlite_module.connect(self._dbpath, mode=self._perms, autocommit=False)
			if not self._ensure_access(self._dbpath):
				raise cache_errors.InitializationError(self.__class__, "can't ensure perms on %s" % self._dbpath)
			self.con = self.db.cursor()
		except self._BaseError, e:
			raise cache_errors.InitializationError(self.__class__, e)
Example #3
0
	def __init__(self, *args, **config):
		super(database,self).__init__(*args, **config)

		self._db_path = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+".cdb")
		self.__db = None
		try:
			self.__db = cdb_module.init(self._db_path)

		except cdb_module.error:
			try:
				self._ensure_dirs()
				self._ensure_dirs(self._db_path)
				self._ensure_access(self._db_path)
			except (OSError, IOError), e:
				raise cache_errors.InitializationError(self.__class__, e)

			try:
				cm = cdb_module.cdbmake(self._db_path, self._db_path+".tmp")
				cm.finish()
				self._ensure_access(self._db_path)
				self.__db = cdb_module.init(self._db_path)
			except cdb_module.error, e:
				raise cache_errors.InitializationError(self.__class__, e)
Example #4
0
    def __init__(self, label, auxdbkeys, **config):
        super(database, self).__init__(label, auxdbkeys, **config)

        default_db = config.get("dbtype", "anydbm")
        if not default_db.startswith("."):
            default_db = '.' + default_db

        self._db_path = os.path.join(
            self._base,
            fs_template.gen_label(self._base, self.label) + default_db)
        print "opening self._db_path=", self._db_path
        self.__db = None
        try:
            self.__db = anydbm_module.open(self._db_path, "w", self._perms)
            try:
                self._ensure_dirs()
                self._ensure_dirs(self._db_path)
                self._ensure_access(self._db_path)

            except (OSError, IOError), e:
                raise cache_errors.InitializationError(self.__clas__, e)
            # try again if failed
            if self.__db == None:
                self.__db = anydbm_module.open(self._db_path, "c", self._perms)