[Zope3-dev] Object Serialization Brainstorm
Casey Duncan
c.duncan@nlada.org
Fri, 21 Dec 2001 14:48:53 -0500
On Friday 21 December 2001 01:50 pm, Lennart Regebro allegedly wrote:
> From: "Casey Duncan" <c.duncan@nlada.org>
>
> > The key question is: Is it possible to design the system such that any
> > object visible in the ZMI could be arbitrarily (and automatically)
> > transformed or serialized into externally usable XML?
>
> Automatically? I can't see how. Even the example you give is not
> possible to do automatically, but require the object to know how to
> transform themselves itself into XML. How would you otherwise know that the
> data attribute is to be tranformed into a file with an encoding?
Actually you'd be surprised what you can do with introspection. Most data is
just stored using simple types, so it can be handled, and object
class/instance structures can be examined at run-time. Do an export of Zope
objects in XML format to see what I mean. The problem with the export is that
it is organized from the ZODB point of view, which isn't really that useful
for anyting but packing and shipping data in and out of the ZODB.
Worst case, if introspection of the class structure fails, you can just stuff
the pickled data as the value, but that has limited usefulness. That is where
allowing a class or even an interface (or both) to define serialization
overrides could come in handy. Hopefully the system could be designed such
that you would only need to do it in special cases, or where reorganizing the
data a special way is beneficial.
I think it can be done. I also think it is ambitious. I don't propose that
Zope 3 has to implement this, what I do propose is that we maybe think of
ways to implement Zope 3 now that will make this easier to implement later.
/---------------------------------------------------\
Casey Duncan, Sr. Web Developer
National Legal Aid and Defender Association
c.duncan@nlada.org
\---------------------------------------------------/