added package storage.pzope
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1542 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
fbcbff7734
commit
51a0a212ef
1 changed files with 10 additions and 5 deletions
|
@ -7,10 +7,14 @@ Zope-based Object Storage
|
||||||
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
||||||
>>> site = placefulSetUp(True)
|
>>> site = placefulSetUp(True)
|
||||||
|
|
||||||
|
As the Zope-based storage keeps track of the objects using unique ids
|
||||||
|
we need a utility that provides these. For testing we use a dummy
|
||||||
|
implementation; the real stuff is in zope.app.intids and there must
|
||||||
|
be a corresponding utility in the root site folder of your Zope.
|
||||||
|
|
||||||
>>> from zope import component
|
>>> from zope import component
|
||||||
>>> from zope.app.intid.interfaces import IIntIds
|
|
||||||
>>> from cybertools.relation.tests import IntIdsStub
|
>>> from cybertools.relation.tests import IntIdsStub
|
||||||
>>> component.provideUtility(IntIdsStub(), IIntIds)
|
>>> component.provideUtility(IntIdsStub())
|
||||||
|
|
||||||
We first need a class from which we will create objects that later on
|
We first need a class from which we will create objects that later on
|
||||||
will be stored in and retrieved from the storage.
|
will be stored in and retrieved from the storage.
|
||||||
|
@ -31,13 +35,14 @@ from the corresponding factory in the `manager` module and calling
|
||||||
|
|
||||||
>>> from cybertools.storage.pzope.manager import storages
|
>>> from cybertools.storage.pzope.manager import storages
|
||||||
>>> persistent = storages(c1)
|
>>> persistent = storages(c1)
|
||||||
>>> uid = persistent.save('c1')
|
>>> c1Uid = persistent.save('c1')
|
||||||
|
|
||||||
For loading an object we get a storage adapter to the object's class and
|
For loading an object we get a storage adapter to the object's class and
|
||||||
call `load()` on it.
|
call `load()` on it, providing the UID we had got back when saving the
|
||||||
|
object.
|
||||||
|
|
||||||
>>> persistent = storages(Content)
|
>>> persistent = storages(Content)
|
||||||
>>> c2 = persistent.load(uid)
|
>>> c2 = persistent.load(c1Uid)
|
||||||
>>> c2.title
|
>>> c2.title
|
||||||
'changed'
|
'changed'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue