[Zope-dev] FileSystem based products & markup.
Casey Duncan
c.duncan@nlada.org
Thu, 14 Feb 2002 08:26:59 -0500
On Thursday 14 February 2002 08:13 am, Romain Slootmaekers allegedly wrote:
> Yo,
>
> We have a file system based product, and some dtml-methods are defined the
> usual way
>
> myMethod=DTMLFile('myMethod',globals())
>
> We want our webbies to be able to add some eye-candy. But how would they
> go about if they want to add some images ?
>
> Remember: THEY ARE WEBBIES, so it has to be really easy and simple and
> changeable, so no
>
> myImage=ImageFile(......)
>
> solutions are possible.
>
>
> Ideas appreciated
> Sloot.
FYI: This list is for messages concerning development of Zope itself, not
developing with Zope.
Anyway, to answer your question, If the classes that your product defines
support acquisition (the subclass Acquisition.Implicit or some other base
class that does, such as SimpleItem.Item) then you can put the Images in the
ZODB anywhere you like, so long as they can be acquired by the instances of
your product class(es).
Another idea would be to make your instances ObjectManagers (just subclass
OFS.ObjectManager.ObjectManager) and the "webbies" can put the images
directly in the instances. They would need to know what ids to use so that
the dtml could pick them up properly.
To make the dtml work without the images you can sprinkle in "missing"
attributes so they fail gracefully if the image is not found:
<dtml-var name="some_image" missing>
Yet another idea (if the images are global to all instances of the product)
would be to create a filesystem directory in the product (or anywhere on the
server readable from Zope) that the webbies can save their image files
directly into. You could then code the product so that it scans the directory
and loads each image using the ImageFile method. The id could be based on the
file name. Or, just make it pull them from the directory on the fly by
defining a "getImage" method or somesuch that takes a file name, and loads it
on demand. That way no code changes would be necessary to add new images to
the product.
hth,
/---------------------------------------------------\
Casey Duncan, Sr. Web Developer
National Legal Aid and Defender Association
c.duncan@nlada.org
\---------------------------------------------------/