[Zope] Cataloging PageTemplates

Casey Duncan casey at zope.com
Wed Dec 10 11:21:33 EST 2003


On Tue, 09 Dec 2003 17:27:09 -0700
Mark Gibson <mark at kaivo.com> wrote:

> What is the simplest way of cataloging rendered page templates in a 
> ZCatalog?

Are these normal page templates or a subclass?

> Would first need to render the page template then strip html tags ( 
> stripogram? ).

Stripping HTML tags wouldn't be necessary if you use and HTML aware splitter in your TextIndex.
 
> It would be nice if PageTemplate would reindex iteself when it's 
> changed.  And when adding a new PageTemplate, if it would index itself 
> in the catalog.

Page templates normally aren't considered content. Telling when a page template is "changed" is not really possible because of this. "Changed" to me means that the rendered HTML is different. The rendered HTML of a page template is different for every object the template is used with.

I think you want to use something different than a basic page template. You want a document that can contain ZPT markup. This would not be a template, but a "dynamic document". If the output never changed except when the document itself was edited, then you could catalog the object automagically.

Things like dynamic documents are not the standard rhythm anymore in Zope. Which is why there is no ZPT equivilant to DTML documents included with Zope. The rhythm is to have static content objects (like files, stx docs, custom objects) which have ZPTs applied to them as views. You would not catalog the content objects, not the page templates.

Ironically (and much to some people's chagrin) Zope3 does include a notion of a content object that contains markup. So I guess overall the message is mixed.

Anyhow I think your best bet is to subclass ZopePageTemplate and CatalogPathAware and add a SearchableText method to your subclass that renders the ZPT for cataloging. Actually, if all the content is actually in the document (and not included from others) then you could probably skip the rendering part and just return the source.

hth,

-Casey



More information about the Zope mailing list