[Zope-dev] Image Archive Project (phase 2)

Michael R. Bernstein webmaven@lvcm.com
Mon, 09 Apr 2001 21:38:42 -0700


Ok, I now have the following setup:

ArchiveImages (Specialist)
 defaultRack
  traversal (SkinScript)
 traversal_method (Python Script)
 Renderings (Specialist)
  defaultRack

The SkinScript in ArchiveImages/defaultRack simply points
__bobo_traverse__ to traversal_method.

traversal_method, in turn, checks to see if it is being
called with one of a short list of known methods of the
ArchiveImage ZClass, otherwise it returns an object in the
Renderings Specialist.

Which object, you ask? The objects in Renderings are
instances of RackImage (a class that subclasses Image and
DataSkin). Currently, I have hardwired behaviour that
instantiates a RackImage in Renderings when you create an
ArchiveImage. Assuming that the ArchiveImage is created with
an id of '001', then the RackImage is created with an id of
'001_original'.

So when the traversal_method is presented with a path of
'/ArchiveImage/001/original' it returns the object from
'/ArchiveImage/Renderings/001_original'. Thus the
ArchiveImage ZClass appears to have an 'original' attribute
that returns an image.

Here is the traversal_method Python Script:

 import string

 if name in ['index_html', 'editInstanceForm',
'editInstance']:
     return getattr(context, name)
 else:
     rendering = string.join([context.id, name],'_')
     return container.Renderings.getItem(rendering)


Ok, so what's next? Somehow, ArchiveImages must be made
aware of what Renderings they have.

The ArchiveImage Specialist needs a getRenderingIds() Python
Script, which in turn calls
container.Renderings.getRenderingIdsFor().

Now I'm stuck. How do I select all the Renderings that have
(for example) '001' in their id, and return just the second
portion of the id (such as 'original' or 'thumbnail')? What
do I need to put into the getRenderingIds and
getRenderingIdsFor Python Scripts?

TIA,

Michael Bernstein.

P.S. The (currently hardwired) Renderings instantiation code
will be delegated later to another Specialist,
RenderingDisplays.