[Zope] index_html always seems to exist

Peter Bengtsson mail@peterbe.com
Tue, 27 May 2003 13:58:24 +0100


At 08:28 2003-05-27 +0200, martin f krafft wrote:
>also sprach Peter Bengtsson <mail@peterbe.com> [2003.05.27.0145 +0200]:
> > file = 'index_html'
> > base = getattr(context, 'aq_base', context)
> > if not hasattr(base, file):
>
>doesn't work in over-the-web scripts since aq_base is not
>accessible.

That's right. Sorry.
The create an External Method that you can use for all kinds of things.

def hasattr_itself(self, object, lookingfor):
     base = getattr(object, 'aq_base', object)
     return hasattr(base, lookingfor)

Then if you create this as an External Method with Id hasattr_itself you 
can use it in Python Scripts like this:

file = 'index_html'
if not context.hasattr_itself(context, file):
     ...





>--
>martin;              (greetings from the heart of the sun.)
>   \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
>
>keyserver problems? http://keyserver.kjsl.com/~jharris/keyserver.html
>get my key here: http://madduck.net/me/gpg/publickey
>
>all of you that believe in telekinetics, raise my hand!