[Zope-dev] serialization with Ape
Christian Scholz
cs@comlounge.net
Wed, 11 Jun 2003 12:18:31 +0200
Hi list! :)
I am just playing around with Ape (very cool, btw :) and wondering
how it can be used from the outside, e.g. not controlled by transactions.
Main idea is to manually copy parts of the ZODB to the filesystem (from
a product).
I first tried the transaction based process, as I found it in
some tests:
# init (createMapper imported from fsmapper)
root_mapper, conns = createMapper(fspath)
conn=conns['fs']
resource = StaticResource(root_mapper)
storage = ApeStorage(resource, conns)
db = ApeDB(storage, resource)
get_transaction().begin()
# test object to store
object = getattr(self,'standard_template.pt')
c=db.open()
app=c.root()['Application']
id=object.getId()
app._setObject(id,object.aq_base,set_owner=0)
get_transaction().commit()
db.close()
which actually stores it but does not seem to me that clean because of
all the transaction stuff. I would here then recursively run through
all the objects and do that inside one transaction.
I then detected the fascades in io.py which I tried to use (dunno if they're
thought to be used for such a purpose actually ;-):
root_mapper, conns = createMapper(fspath)
ei=ExportImport(root_mapper,conns)
ei.exportObject(object)
Unfortunately this results in an exception
Type: MappingError
Error Value: Path keychains require a name
So can maybe somebody point me to the easiest way to serialize an object
using the fsmapper (Shane? ;-) ?
I am also interested in reading a serialized object from the fs again
and writing it to the fs. Also I wonder if I need to delete objects which
have been modified before another export or if there's a possibility to
just change it).
(and the best would be of course some simple methods for reading/writing
a whole directory recursively. I don't know if something like this is already
in there somehow or how it works internally.. seems all a bit magic to me ;-)
So thanks in advance if anybody can help me :)
cheers,
Christian
--
COM.lounge http://comlounge.net/
communication & design info@comlounge.net