How to avoid the inheritance of DTMLDocuments?
Hi everyone, I've run into a problem. I originally thought that only DTMLMethods would be inherited over the directory structure, i.e. a index_html method in the root folder would be available in the subfolders. But now I have the following problem that also DTMLDocuments are inherited! This destroys a bit my application logic, as outlined below: The customers have there own subfolder on the Zope Server where they can upload their HTML (!) documents. In the Zope root folder I have the following DTMLMethod index_html which is supposed to be inherited to the customer's subfolder: <dtml-if index.html><dtml-var index.html><dtml-elif index.htm><dtml-var index.htm><dtml-else><dtml-var header>The <dtml-var "title_or_id()"> site is not yet available.<dtml-var footer></dtml-if> The problem is however that the index.htm DTMLDocument (!) is also inherited to the customer's subfolder so that the "The site is not yet available" part is never executed :-( Is there a switch to avoid the inheritance of DTMLDocuments to a specific folder (i.e. in my case there's /pool/empl1, /pool/empl2 etc.) that i could set in the /pool folder in my case? Thanks again for your help and support, Philipp
You misunderstand the (very subtle) difference between Documents and Methods: methods are behaviours, and thus can't have their own data. They have to use the data of the object that contains them. Non-methods can contain their own data, since they are full objects. (DTML Methods may look like they contain data, but the text in the DTML body is really just specification for the behaviour it implements.) But they're all objects, and objects in Zope are acquired in the usual manner. Unless there happens to be a NonAcquirableObject (LocalObject perhaps?) out there, and I've never seen one. It might be handy to have, for cases like this.
Is there a switch to avoid the inheritance of DTMLDocuments to a specific folder (i.e. in my case
there's /pool/empl1, /pool/empl2 etc.) that i could set in the /pool folder in my case?
Not really, but sort of. There's a couple ways to fight acquisition: <dtml-with aq_explicit only> <dtml-var index.html> </dtml-with> should give you only the index.html contained in that object (if it exists.) You can also explicitly get a parent (or child in a dtml-in loop) and check whether or not a property is the same with something like <dtml-if "PARENTS[-1].thing != thing"><dtml-var thing></dtml-if> or in a loop <dtml-let parentproperty=property> <dtml-in objects> <dtml-if "property != parentproperty"> <dtml-var property> </dtml-if </dtml-in> </dtml-let> but it's not pretty. --jcc (a mess, see?)
participants (2)
-
J. Cameron Cooper -
Philipp Robbel