[ZPT] object acquisition via python scripts

Jon Bowlas me at jonbowlas.com
Fri Jul 22 10:59:20 EDT 2005


I'm not sure if the subject line accurately describes what I'm trying to do,
anyway let me try and explain.

I have a set of folders like this:

Site root object
	|----	Attributes object
	|----	Layout ZPT
	|----	get_attobject (python script)
	|----	get_attributes (python script)
	|----	Folder object A
			|-----Attributes object
	|----	Folder object B

My 'get_attobject' script is called from my 'Layout zpt' using this code:
<div tal:define="attobject here/get_attobject"></div>

And my get_attobject script contains the following code:

	attobjects = context.objectValues('Attributes object')
	if attobjects:
    		return attobjects[0]
	return None
Then my get_attributes script uses the attobjects value returned from the
get_attobject script to output the values of the 'Attributes object'. Now
this all works fine in the 'Site root object' and in 'Folder object A' but
when I get to 'Folder object B' there is nothing returned since I have no
'Attributes object' present. 

But what I'd like to do in this situation is use acquisition to retrieve the
values from the parent 'Attributes object' located in the site root. So
could someone please explain how I could achieve this?

Hope someone can help me, many thanks. If any more information is required
please ask.


More information about the ZPT mailing list