cybertools/storage/pzope
helmutm fbcbff7734 added package storage.pzope
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1541 fd906abe-77d9-0310-91a1-e0d9ade77398
2007-01-04 22:39:57 +00:00
..
__init__.py added package storage.pzope 2007-01-04 22:39:57 +00:00
manager.py added package storage.pzope 2007-01-04 22:39:57 +00:00
README.txt added package storage.pzope 2007-01-04 22:39:57 +00:00
tests.py added package storage.pzope 2007-01-04 22:39:57 +00:00

=========================
Zope-based Object Storage
=========================

  ($Id$)

  >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
  >>> site = placefulSetUp(True)

  >>> from zope import component
  >>> from zope.app.intid.interfaces import IIntIds
  >>> from cybertools.relation.tests import IntIdsStub
  >>> component.provideUtility(IntIdsStub(), IIntIds)

We first need a class from which we will create objects that later on
will be stored in and retrieved from the storage.

  >>> class Content(object):
  ...     title = 'demo'

  >>> c1 = Content()
  >>> c1.title
  'demo'
  >>> c1.title = 'changed'
  >>> c1.title
  'changed'

We can save the object in the storage by getting a storage adapter
from the corresponding factory in the `manager` module and calling
`save()` on it.

  >>> from cybertools.storage.pzope.manager import storages
  >>> persistent = storages(c1)
  >>> uid = persistent.save('c1')

For loading an object we get a storage adapter to the object's class and
call `load()` on it.

  >>> persistent = storages(Content)
  >>> c2 = persistent.load(uid)
  >>> c2.title
  'changed'


Fin de partie
=============

  >>> placefulTearDown()