Hi, my folderish ZClass Product already contains an index_html document. I would like to provide users with a possibility to create a local index_html document in their instance of the product. but if I create a local index_html, I get a key error: "already in use". Is this a general ZClass problem? Is there a solution? regards, Heiko -- heiko.stoermer@innominate.de innominate AG networkingpeople fon: +49.30.308806-0 fax: -77 web: http://innominate.de
Heiko Stoermer wrote:
Hi,
my folderish ZClass Product already contains an index_html document. I would like to provide users with a possibility to create a local index_html document in their instance of the product. but if I create a local index_html, I get a key error: "already in use". Is this a general ZClass problem?
Hm, I would say it's a feature. In this way you can't override (and possibly break) your invisible ZClass index_html by accident.
Is there a solution?
Yes. The simplest is to change the index_html in you ZClass to something else (like default or something) and adjust the View method (under the view tab) of the ZClass accordingly. This way your users could add an index_html without clashing, but it won't show automatically. So the default method in your ZClass should look something like: <dtml-var standard_html_header> <dtml-if index_html> <dtml-var index_html> <dtml-else> your default content </dtml-if> . . . THis is untested, but I think it should work. If not, at least conditional content is the way to go. Rik
Heiko Stoermer wrote:
Hi,
my folderish ZClass Product already contains an index_html document. I would like to provide users with a possibility to create a local index_html document in their instance of the product. but if I create a local index_html, I get a key error: "already in use". Is this a general ZClass problem?
No, it is by design. ObjectManagers do not allow you to create an object contained in them that allready uses that id, *or is allready an attribute (like a method) of that ObjectManager*. Your ZClass does not 'contain' a method object. Rather, the method object is a method of your ZClass. The method managment view *looks* like the container managment view, but it is a different beast. methods in the ZClass Methods view will become attributes of your ZClass instances, *not* children in a containment relationshipsub-objects. When you try and create a sub-object of your object it gives you an error because your objects (an instance of your ZClass) allready has an attribute (a method) by that name.
Is there a solution?
Have your ZClass's index_html method defer it's action until run-time: <dtml-if FrontPage> <dtml-var FrontPage> <dtml-else> <dtml-var myObscureDefaultContent> </dtml-if> Make 'myObscureDefaultContent' a method of your ZClass, this is what is your index_html method of the ZClass now. If the user creates a new method in the ObjectManager called 'FrontPage', it will be displayed instead. -Michel
regards, Heiko
-- heiko.stoermer@innominate.de innominate AG networkingpeople fon: +49.30.308806-0 fax: -77 web: http://innominate.de
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
participants (3)
-
Michel Pelletier -
news-list.zope.dev@innominate.de -
Rik Hoekstra