[Zope] ZCatalog and acquired objects

Michel Pelletier michel@digicool.com
Tue, 20 Jul 1999 04:04:12 -0400


Itai Tavor wrote:
> 
> Hi,
> 
> ZCatalog traverses the object hierarchy and indexes the content of
> objects, right? So (it seems to me that) objects that display content
> acquired from other objects won't be indexed correctly. For example,
> I got this situation:
> 
> folder:
>     show (DTML Method)
>     1 (TinyTable)
>     2 (TinyTable)
>     3 (TinyTable)
>     4 (TinyTable)
> 
> 'show' displays the content of a TinyTable when called with
> 'folder/1/show'. Indexing 'show' with ZCatalog is useless because it
> doesn't contain any interesting data if it doesn't acquire a
> TinyTable. Indexing the TinyTables themselves is also useless because
> a find will then link to the TinyTable object, but I need to link to
> 'show'.
> 
> So, is this true, or am I missing something? Is there a way to get around this?
> 

Yep it's true.  But the question is, what attributes of an object do you
really want to index?  Mass indexing (traversing all your objects
looking for a collection of attributes) is often not as useful as it
seems, often you don't want to index the contents of a DTML Method, but
you DO want to index the contents of a DTML Document.  Or maybe you do
want methods?  Or maybe you only want certain properties of a tiny
table?

This is why the ZCatalog can be used programaticly from DTML.  Often
with a bit more effort you can construct an application that catalogs
it's own objects in a sane way that makes much mroe sense to you than
just a vast object sweep.  This works reather well with ZClasses; you
can define your own Zope objects and modify their constructors so that
they catalog and uncatalog themselves.  Also, you can create as many
specialized catalogs as you want.

This gets down to a pretty fundemental Zope question (and dynamic
systems in general) 'What is content?'.  The Catalog brings this
question to light most especially.  I suspect other cataloging systems
are fairly limited in that they let you index text, maybe some object
meta data; but the ZCatalog is a bit more low level, and thus more
flexible.  You can configure both what you want for meta data and what
you want to index independantly, and object attributes can be methods,
lists, objects, etc...  This means that whenyou do mass indexing, you
might sweep up more than you really want.  ZCatalog adds another
dimension to application design, not only should you organize your site
to take advantage of folder structure and acquision, but also
cataloging.

Note that in your example, you can also create an external method that
renders your show method in the context of a tiny table passed as a
parameter and returns the data you want to index.  Then you can just,
for example, index all folders looking for the attribute
'externalmethodname'.

> -- "Every day, once a day, give yourself a present"  - Dale Cooper --

Hey a peak freak!

-Michel


List PS:  Yes I really do get up at 4am to answer list email.