[Zope] context of a for loop

Edward Muller edwardam@interlix.com
06 Mar 2003 23:33:31 -0600


Do all of the objects returned by getattr(context, item) have a
.editMetadata method. Or perhaps security is 'getting in the way' (i.e.
do you have rights to .editMetadata)

On Wed, 2003-03-05 at 19:12, Fearless Froggie wrote:
> Hi,
> 
> When you are going through a for loop, are you in the
> context of that for loop variable? Can you drop out of
> that for loop context and into the context of the
> script?
> 
> Example:
> 
> If I loop through a list of id's with a for loop and
> do something to each of these objects, I get a "You
> are not allowed to access editMetadata in this
> context". Here's the code (here I'm just changing the
> title of each of my items in my list 'id' to 'bob'): 
> 
> for item in id:
>    item_object = getattr(context, item)
>    item_object.editMetadata(title='bob')
> 
> But if I do these changes directly, it works fine:
> 
> item_object = getattr(context, id[0])
> item_object.editMetadata(title='bob')
> 
> So I'm guessing that the for loops puts me into
> another context. How do I get into the context of the
> object I want to edit? I've tried
> "context.item_object.editMetadata(title='bob')" and
> "container.item_object.editMetadata(title='bob')", but
> they didn't work either.
> 
> My script in all these cases is my custom skins
> directory.
> 
> Many thanks for any ideas on this. (And thank you once
> again for all the great ideas I've received for my
> past emails :)
> 
> Rita.
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
-- 
Edward Muller

Interlix - President

Web Hosting - PC Service & Support
Custom Programming - Network Service & Support

Phone: 417-862-0573
 Cell: 417-844-2435
  Fax: 417-862-0572

http://www.interlix.com