Commit f785ac07 authored by Kirill Smelkov's avatar Kirill Smelkov

lib/zodb: Use zodbtools/zodburi to open databases, if available

This allows e.g. to open `neo://cluster@master?compress=false` - in
other words with using options, which our current simplified opening
code does not support.

Keep old dbstoropen around as the fallback to work when
zodbtools/zodburi are not available, since we still want to try to
support ZODB 3.10.
parent c3cc8a99
......@@ -26,9 +26,19 @@ import gc
# 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 we can - use zodbtools to open via zodburi
try:
import zodbtools.util
except ImportError:
return _dbstoropen(uri)
return zodbtools.util.storageFromURL(uri)
# simplified fallback to open a storage by URI when zodbtools/zodburi are not available.
# ( they require ZODB, instead of ZODB3, and thus we cannot use
# them together with ZODB 3.10 which we still support )
def _dbstoropen(uri):
if uri.startswith('neo://'):
# XXX hacky, only 1 master supported
from neo.client.Storage import Storage
......
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