[Zope] Problems with acquisition in PythonScript objects

Dieter Maurer dieter@handshake.de
Tue, 6 Mar 2001 21:00:07 +0100 (CET)


=?iso-8859-1?q?J=E9r=F4me=20Loisel?= writes:
 > I have object foo (an image) in my root folder. I have bar, a PythonScript 
 > which calls foo's absolute_url() method. bar works as expected when viewing 
 > it from the root folder, but never from subfolders. I get attribute errors: 
 > foo does not exist.
 > 
 > context['foo'].absolute_url()
Acquisition does only work for attribute(!) access ("getattr")
and not subscription.
Try:

	context.foo.absolute_url()

or

	getattr(context,'foo').absolute_url()

 > _['foo'].absolute_url()
 > _.getitem('foo').absolute_url()
Are you sure the namespace variable is bound?
In many case, you will get an empty namespace.
If your namespace is not empty, then the code above should work.


Dieter