[Zope] Avoid or supress heredity

Peter Bengtsson mail@peterbe.com
Tue, 29 May 2001 11:36:33 +0200


Use <dtml-with "PARENTS[0]" only>
or something like that.
Just as long as you keep the 'only' argument.
This turns of aquisistion for a while.

To do it in Python you are obliged to do it in an External Method (not a
Python Script).
Dieter Maur contributed with this hack.
def hasattr_itself(object,attribute):
  """return true iff *object* itself has attribute *attribute*."""
  base= getattr(object,'aq_base',object)
  return hasattr(base,attribute)

But maybe it's worth trying first.
In a Python Script:
if hasattr(context.folder2.aq_explicit, 'default_en'):
Note the .aq_explicit

Peter
----- Original Message -----
From: "Martin Stötzel" <martin@stoetzel.com>
To: <zope@zope.org>
Sent: Tuesday, May 29, 2001 10:17 AM
Subject: [Zope] Avoid or supress heredity


> Hi all,
>
> I have been trying and trying - but I could not find out:
> The problem is that I want to check if a certain file (method) exists in a
> folder, and if not, display another method.
>
> I am talking about a 'default_en' which should be displayed if it is in a
> folder
> and a 'default' which exists in each folder and should be displayed
> otherwise.
>
> To make this clear:
>
> root:
> default
> default_en
>  + folder1
>     - default
>  + folder2
>     - default
>     - default_en
>
> OK, everything works, exept in folder1. I check if a 'default_en' is
there,
> otherwise display 'default'. But what happens is that because of heredity
> the 'default_en' from the root is found and displayed.
>
> The code is simple:
>
>     <dtml-if "'default_en' in objectIds('DTML Method')">
>         <dtml-var default_en>
>     <dtml-else>
>         <dtml-var default>
>     </dtml-if>
>
> Does anybody know how I could display the 'default' in folder1? (I mean,
> with the functionality I want)
>
> Thanks. Martin
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )