[Zope] ZClass direct variable access

Phill Hugo phill@fortune-cookie.com
Mon, 19 Mar 2001 15:44:52 +0000


Casey Duncan wrote:
> 
> Phill Hugo wrote:
> >
> > Is there a way to access property sheet variables from a zclass method
> > without knowing which property sheet it is contained within.
> >
> > For example, Class A has two prop sheets, S1 and S2 and Var1 is in S2.
> >
> > I can do container.propertysheets.get('S2').getProperty('Var1')
> >
> > or (if I has subclassed ObjectManager)... container['Var1']
> >
> > The latter form I prefer since it doesn't require knowledge of which
> > sheet I'm really using but it only works if the zclass is based on
> > ObjectManager. In other cases it raises an exception (AttributeError,
> > __getitem__)
> >
> > Any ideas or should this be added to the collector (I've a feeling a
> > basic __getitem__ should be included in ZObject for this type of thing).
> >
> > Phill
> >
> 
> You can't just do a "S2.Var1" to access the property?

Sorry, I should have made this more clear. The name of the variable
"Var1" is itself a variable I'm passing. It requires dereferencing
before I can use it.

The example above (container['Var1']) should read container[Var1]

Phill