[Zope] DTML syntax
Kevin Dangoor
kid@kendermedia.com
Thu, 26 Aug 1999 10:48:24 -0400
-----Original Message-----
From: Michel Pelletier <michel@digicool.com>
To: Tim Wilson <wilson@chemsun.chem.umn.edu>
Cc: Zope Listserv <zope@zope.org>
Date: Thursday, August 26, 1999 1:17 AM
Subject: Re: [Zope] DTML syntax
>You're application can be much simpler. Just design a ZClass that
>represents the object, whether it be a PDF file with meta data or
>whatever, as what you want it to be. A how-to on this will be
>forthcoming. In the meantime, I believe the KM news author is working
>with ZClasses, perhaps she/he can relate the experience?
I'm that KM news guy...
This is a good subject for a how-to. My original suggestion was to just use
the Catalog Find command, because this is a very easy way to get started.
However, it would take more effort to convert those File objects to a
CatalogAware ZClass later, so maybe starting out with a ZClass is the way to
go. Unless you think that 2.1 or 2.2 will feature CatalogAware File objects.
Here is some fodder for the how-to (let me know if any of it is wrong,
because I'd love if some of these things were more automatic :)
Creating a CatalogAware ZClass
With relatively little effort, a ZClass can be set up to automatically
add,
delete and update itself from a Catalog. This is a very powerful feature
because it allows the user to easily search your content and allows you
to produce different views of your objects.
This document expects a basic knowledge of ZClasses and
describes the additional actions necessary to make a
fully-CatalogAware ZClass.
Constructing the ZClass
When creating the ZClass, you need to select CatalogAware as the
*first* base class. So, if you are creating a folderish ZClass,
you would select CatalogAware first, and then select ObjectManager.
Adding Objects to the Catalog
Once you have inherited from CatalogAware, new objects will
automatically be added to the Catalog. However, it is not
uncommon to modify properties from within your ZClass_add
method in the section::
<!--#with "MyZClass.createInObjectManager(REQUEST['id'], REQUEST)"-->
<!--#comment-->
You can ad code that modifies the new instance here.
For example, if you have a property sheet that you want to update
from form values, you can call it here:
<!--#call "propertysheets.Basic.manage_editProperties(
REQUEST)"-->
<!--#/comment-->
<!--#/with-->
If you do modify the properties, you'll need to reindex the object so that
the changes show up in the Catalog. Your code would look something
like this::
<!--#with "MyZClass.createInObjectManager(REQUEST['id'], REQUEST)"-->
<!--#call "propertysheets.Basic.manage_editProperties(
REQUEST)"-->
<dtml-call reindex_object>
<!--#/with-->
Changing the Objects
If you use a standard propertysheet management screen, your changes
do not get automatically propogated to the Catalog. You'll need to create
your own editing method which changes the properties and then calls
reindex_object.
Deleting the Objects
You don't need to do anything special to have your objects removed
from the Catalog upon deletion.
That's It!
Any properties that your ZClass instances have will automatically
show up in the Catalog, and the Catalog will stay up to date
with changes!
Kevin