----- Original Message -----
From: "Itamar Shtull-Trauring" <[EMAIL PROTECTED]>
To: "Kevin Dangoor" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, June 07, 2000 3:44 AM
Subject: Re: [Zope-dev] Getting to container from a method called by the
> Kevin Dangoor wrote:
> > I'm trying to check if the container from which the user selected a
> > product from the add menu has an "acl_users" folder. When the user
> > the option from the add menu, they get a form. When they submit the
> > the method (a PythonMethod) does this:
> > folder=self.Destination()
> > if hasattr(folder, 'acl_users'):
> > ...do something...
> > else:
> > ...complain...
> > Even though I know the folder has an acl_users (and having this function
> > return folder.objectIds() proves it), the above code will always
> > Is there a problem with using hasattr in this context?
> Well, first of all, because of acquisition, if there's a acl_users at the
> top level this will always return true.
I didn't think hasattr() used acquisition... I thought hasattr would tell
you if something is within that object itself.
> Next, PythonMethods have trouble
> with hasattr AFAIK - so instead do:
I didn't realize this.
> if 'acl_users' in folder.objectIds():
> ...do something...
Yep. I thought of that one, too. I figured hasattr might be more efficient
in large folders. In this particular context, that little bit of efficiency
is not important and your example would work fine.
Thanks for the tip.
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -