[Zope] Storing documents and metadata (associated XML fragment)

Casey Duncan casey@zope.com
Tue, 28 May 2002 10:42:08 -0400


On Tuesday 28 May 2002 05:15 am, Lars von Wedel wrote:
> Hello,
>=20
> I want to store some kind of library of arbitrary files (similar
> to the file library example in the distribution). Further, I'd like
> to store an associated XML fragment (metadata) with the document. This
> XML fragment should be accessible externally, via XML-RPC for example.

There are several ways to approach this problem. Let me start by stating =
that=20
XML is a representation of data, and it might not be your best option to=20
simply store XML in Zope. Unless you enjoy (or have tools that enjoy) edi=
ting=20
the XML directly. If you do, then you might argue for it.

For more control and flexibility I might suggest storing the metadata as=20
properties of the object and creating a "view", using a page template or =
DTML=20
method that generates the XML from the properties. Now the disadvantage t=
o=20
this is that the XML will essentially be read only.

For read-write access to XML data in Zope I would suggest looking at=20
ParsedXML.
=20
> What is the best way to store such things in Zope? Would I store=20
> Metadata in separate files along with the original files? Or should
> I extend the File with a string member to hold metadata (may be large,
> though)?

How large is large? The disadvantage of Zope properties is that they are=20
loaded into memory whenever the object is. File data OTOH is not loaded u=
ntil=20
it is accessed and only in blocks.

If you are talking about megabytes (or hundreds of kb) of XML attached to=
 a=20
single object, separate file objects would probably be a good idea. You c=
ould=20
make the content object folderish so that it can contain several files, o=
ne=20
for the content and one (or more) for the metadata.

If you do have tons of XML to attach to a document, you'll also need to=20
consider how you are going to work with it. Parsing such giants would be =
an=20
expensive operation, so you would want to do it as seldom as possible.

-Casey