[Zope-dev] serialization with Ape
Christian Scholz
cs@comlounge.net
Wed, 11 Jun 2003 16:30:42 +0200
Hi!
I actually now have a (as it seems) working version of my first
approach, just using _setObject() etc. which even works recursively.
Has this some drawbacks except it looks a bit like a hack due to the
call of commit()?
I also have the deserialization working and basically it's just a
copying between two ZODBs I'd say.
On Wed, Jun 11, 2003 at 10:12:46AM -0400, Shane Hathaway wrote:
> Christian Scholz wrote:
> > 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)
>
> This is *exactly* the purpose ExportImport is meant for, but it's quite
> new and unfinished. I'm glad you found it, although it's only in CVS,
> not in the released version of Ape.
Well, I am looking a bit on the repository and was reading
log messages ;-)
> > 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? ;-) ?
>
> You're on the right track. I wonder what went wrong.
I looked into that a bit and in core/io.py line 316 you do
return kgen.makeKeychain(event, None, 1)
so name is None here as it seems. I just dunno if it's a special case
because I was doing something wrong or not ;-)
> > 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).
>
> Ape will assign new OIDs on import, so you don't have to delete objects
> first.
Well, at least with my first approach I need to do that because I just
do a folder._setObject() and this fails then of course.
> > (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 ;-)
>
> Again, ExportImport is designed to do this.
Will it also do it recursively? I found out that when I do it via
folder._setObject() it will also serialize all content which is quite
nice :)
What is actually the result of an export? Where in the fs is it stored then?
Is the whole path to the object in ZODB is taken ?
But thanks for the answer and thanks for Ape! :)
-- christian
--
COM.lounge http://comlounge.net/
communication & design info@comlounge.net