[Zope] Re: Attribute Error with Container

Mark Nenadov mark@freelance-developer.com
22 Apr 2003 14:18:27 +0000


Maik,

Thanks for your help. I appreciate it.

I've read a bit about context vs. container and I think I understand it
well now.

Apparently I was also missing something else too.. I needed to change
"context.SensoryProperties.taste" to
"context.propertysheets.SensoryProperties.taste" and now it works as
expected.

~Mark

On Tue, 2003-04-22 at 17:29, Maik Jablonski wrote:
> Mark Nenadov wrote:
> > Hello all,
> > 
> > I'm trying to make a Python script that checks the value of ZClass
> > property (within a property sheet).
> > 
> > What I am doing is very similar to the example implementation of
> > "isHungry" in "The Zope Book".
> > 
> > However, I am getting an error (error type: Attribute Error, and error
> > value: SensoryProperties), when I try something equivalent to the
> > following:
> > 
> > if (container.SensoryProperties.taste == "good"):
> >   return 1
> > else:
> >   return 0
> > 
> > Does anyone have a clue what this might be? I assume that since
> > "container" is a bound name I don't need to do anything special to
> > "enable" it.
> 
> Hi,
> 
> have a look at the bindings-tab of a PythonScript to understand what 
> these "magical" bindings mean.
> 
> container = objectmanager in which your PythonScript lives.
> 
> But you should use context:
> 
> context = the object which your PythonScript is called on.
> 
> if (context.SensoryProperties.taste == "good"):
>     return 1
> else:
>     return 0
> 
> 
> Cheers, Maik
>