Commit 15fc774e authored by Jim Fulton's avatar Jim Fulton

Added a new convenience function, ZEO.DB, for creating databases

using ZEO Client Storages.  Just call ZEO.DB with the same arguments
you would otherwise pass to ZEO.ClientStorage.ClientStorage::

import ZEO
  db = ZEO.DB(('some_host', 8200))
parent 00fc83c2
...@@ -28,6 +28,13 @@ New Features ...@@ -28,6 +28,13 @@ New Features
New Features New Features
------------ ------------
- There's a new convenience function, ZEO.DB, for creating databases
using ZEO Client Storages. Just call ZEO.DB with the same arguments
you would otherwise pass to ZEO.ClientStorage.ClientStorage::
import ZEO
db = ZEO.DB(('some_host', 8200))
- Object saves are a little faster - Object saves are a little faster
3.9.0a4 (2008-11-06) 3.9.0a4 (2008-11-06)
......
...@@ -20,3 +20,9 @@ ZEO is now part of ZODB; ZODB's home on the web is ...@@ -20,3 +20,9 @@ ZEO is now part of ZODB; ZODB's home on the web is
http://www.zope.org/Wikis/ZODB http://www.zope.org/Wikis/ZODB
""" """
def DB(*args, **kw):
import ZEO.ClientStorage, ZODB
return ZODB.DB(ZEO.ClientStorage.ClientStorage(*args, **kw))
...@@ -34,23 +34,16 @@ Then we'll start 2 others that use this one: ...@@ -34,23 +34,16 @@ Then we'll start 2 others that use this one:
Now, let's create some client storages that connect to these: Now, let's create some client storages that connect to these:
>>> import ZEO.ClientStorage >>> import ZEO, transaction
>>> cs1 = ZEO.ClientStorage.ClientStorage(('localhost', port1), '1')
>>> cs2 = ZEO.ClientStorage.ClientStorage(('localhost', port2), '1')
And some databases and connections around these: >>> db1 = ZEO.DB(('localhost', port1), '1')
>>> from ZODB.DB import DB
>>> import transaction
>>> db1 = DB(cs1)
>>> tm1 = transaction.TransactionManager() >>> tm1 = transaction.TransactionManager()
>>> c1 = db1.open(transaction_manager=tm1) >>> c1 = db1.open(transaction_manager=tm1)
>>> r1 = c1.root() >>> r1 = c1.root()
>>> r1 >>> r1
{} {}
>>> db2 = DB(cs2) >>> db2 = ZEO.DB(('localhost', port2), '1')
>>> tm2 = transaction.TransactionManager() >>> tm2 = transaction.TransactionManager()
>>> c2 = db2.open(transaction_manager=tm2) >>> c2 = db2.open(transaction_manager=tm2)
>>> r2 = c2.root() >>> r2 = c2.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