I apologise if this is a newbie question, but I can't seem to find anything in the documentation about this.
The way Zope seems to want to organise things is so that folders roughly
equate to classes.
That is, if I have B inside A, then B inherits its
behaviour from A.
B acquire part of its behavior from A. But acquisition is not only by containment, it's also by context.
All of B's siblings are the same sort of object.
Why do you have this strange idea ?
However, this means that I have to seperate all my various types of object by kind, regardless of whether they're related.
Not at all. The most obvious think to do is to put your objects where they belongs - that is, use the ZODB hierarchie like you'd use a plain filesystem for a static site.
Let's say I have a site that talks about flowers. I have two main kinds of object: images of flowers, which support methods for scaling etc, and descriptions of flowers, which support methods for rendering in various interesting ways. I have to arrange things like this:
/ Text HistoryOfTheDaisy MoreInformationAboutDaisies HowToGeneticallyEngineerRoses MyFavouriteRoseStories Images WildDaisy DomesticatedDaisy MutatedDaisyFromBeyondTimeAndSpace FakePictureOfABlackRose
This works, but is a bit icky. I have my daisies mixed in with my roses.
It would be far more convenient for organisational purposes if I arranged things like this:
/ Daisy Text HistoryOfTheDaisy MoreInformationAboutDaisies Images WildDaisy DomesticatedDaisy MutatedDaisyFromBeyondTimeAndSpace Rose Text HowToGeneticallyEngineerRoses MyFavouriteRoseStories Images MutatedDaisyFromBeyondTimeAndSpace FakePictureOfABlackRose
But to make this work, I need to duplicate all the code in each 'Text' and 'Images' folder...
Nope. The most obvious thing to do is : put that code in your root folder. Now everyone will acquire it, and you'll be a happy webmaster. (unless of course there are name clashes somewhere !-)
Is it possible to tell Zope that methods for a particular kind of object
should be found at a particular location, regardless of the containment
0/ Put all your code in the root folder and use acquisition by containment. Q&D, but proven to work.
1/ add (in the root folder, or anywhere on top of your Flowers) a folder for each 'type of object', put the 'methods' in, and use acquisition by context:
text_methods dothis dothat
image_methods: dosomething dosomethingelse
Then calls like: Rose/Text/MyFavouriteRoseStories/text_methods/do_this
Should work. But I would not do it (at least for your exemple).
2/ Write a product for your object types. Here it could be a Flower object, extending Folder so you can put texts and images in, and having all the code needed for your texts and images.
Is this in fact possible, or do I need to start tinkering with custom products?
Anyway, you *should* write your own Products - and for this kind of things, it's pretty easy.
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce