[Zope-dev] Python Script

Cyril Elkaim cyril.elkaim@free.fr
Fri, 23 Feb 2001 12:51:51 +0100 (CET)


       Hi Steve,

In the zclass definition I have a bunch of Image objects together with the
following script.

SCRIPT s_center(width, height, image):

import string

result = None

for item in container.objectItems():
  if string.strip(item[0]) == image:
    image_width = int(item[1].getProperty("width"))
    image_height = int(item[1].getProperty("height"))

left = (int(width) - image_width) / 2
top = (int(height) - image_height) /2

result = "left:" + str(left) + "px; top:" + str(top) + "px"

return result

/END_SCRIPT

This script works fine if I test it inside the test tabs of the zclass. But
if I run it from an instance 'container.objectItems()' returns nothing. I 
understand why but my problem is how to get access of the images from
the instance.

What I need is something giving a reference to the zclass definition from
one of its instance. I think I can use the DOM model and walk through until
I find it but it should be better to have a direct access from the instance
itself, wrong?

Thanks,

Cyril