Commit 0e8dd91b authored by Kirill Smelkov's avatar Kirill Smelkov

lib/zodb: Add support for opening neo:// and zeo:// databases

Done via manual hacky way for now. The clean solution would be to reuse
e.g. repoze.zodbconn[1] or zodburi[2] and teach them to support NEO.

But for now we can't -- those eggs depend on ZODB, and we still use
ZODB3 for maintaining compatibility with both ZODB3.10 and ZODB4.

/cc @jm

[1] https://pypi.python.org/pypi/repoze.zodbconn
[2] https://pypi.python.org/pypi/zodburi
parent 72685306
......@@ -20,9 +20,33 @@ from ZODB.FileStorage import FileStorage
from ZODB import DB
# open db storage by uri
def dbstoropen(uri):
# TODO better use repoze.zodbconn or zodburi
# ( but they require ZODB, instead of ZODB3, and thus we cannot use
# them together with ZODB 3.10 which we still support )
if uri.startswith('neo://'):
# XXX hacky, only 1 master supported
from neo.client.Storage import Storage
name, master = uri[6:].split('@', 1) # neo://db@master -> db, master
stor = Storage(master_nodes=master, name=name)
elif uri.startswith('zeo://'):
# XXX hacky
from ZEO.ClientStorage import ClientStorage
host, port = uri[6:].split(':',1) # zeo://host:port -> host, port
port = int(port)
stor = ClientStorage((host, port))
else:
stor = FileStorage(uri)
return stor
# open stor/db/connection and return root obj
def dbopen(path):
stor = FileStorage(path)
def dbopen(uri):
stor = dbstoropen(uri)
db = DB(stor)
conn = db.open()
root = conn.root()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment