def __init__(self, request, **kw): log.debug("shelve graphdb init") GraphDataBase.__init__(self, request, **kw) gddir = os.path.join(request.cfg.data_dir, 'graphdata') if not os.path.isdir(gddir): os.mkdir(gddir) self.graphshelve = os.path.join(gddir, 'graphdata.shelve') self.use_sq_dict = getattr(request.cfg, 'use_sq_dict', False) if self.use_sq_dict: import sq_dict self.shelveopen = sq_dict.shelve else: self.shelveopen = shelve.open # XXX (falsely) assumes shelve.open creates file with same name; # it happens to work with the bsddb backend. if not os.path.exists(self.graphshelve): db = self.shelveopen(self.graphshelve, 'c') db.close() self.db = None self.cache = dict() self.out = dict() lock_path = os.path.join(gddir, "graphdata-lock") self._lock_timeout = getattr(request.cfg, 'graphdata_lock_timeout', None) self._readlock = _Lock(lock_path, exclusive=False) self._writelock = _Lock(lock_path, exclusive=True)
def __init__(self, request): GraphDataBase.__init__(self, request) self.sock_path = os.path.join(request.cfg.data_dir, 'graphserver.sock') self.sock = socket(AF_UNIX, SOCK_STREAM) self.sock.connect(self.sock_path) if 1: self.conn_file = self.sock.makefile("r+") else: self.conn_file = os.fdopen(os.dup(self.sock), "r+", 1)
def __init__(self, request): GraphDataBase.__init__(self, request) self.sock_path = os.path.join(request.cfg.data_dir, "graphserver.sock") self.sock = socket(AF_UNIX, SOCK_STREAM) self.sock.connect(self.sock_path) if 1: self.conn_file = self.sock.makefile("r+") else: self.conn_file = os.fdopen(os.dup(self.sock), "r+", 1)
def __init__(self, request, dbname="gwiki", couchurl=None): log.debug("couchdb graphdb init") GraphDataBase.__init__(self, request) self.dbname = dbname if couchurl: self.couch_server = couchdb.Server(couchurl) else: self.couch_server = couchdb.Server() self.make_pagemeta_class() # we could really use db connection recycling/pooling... self.init_db() # use write cache/bulk update workaround for rehash slowness, # unsafe otherwise self.doing_rehash = False self.modified_pages = {}