Hello,

I have a custum content type "SightFolder" with a field "img" of "image" type. I would like to use some PIL transformations on the image saved in the image field, so I have added a method into the content type class. But all my attempts fail.

I import PIL as:

from PIL import Image

A field is defined as:

    ImageField(
        name='img',
        widget=ImageField._properties['widget'](
            label="Map",
        ),
        searchable=0,
        required=0,
        storage=AnnotationStorage(),
    ),

A method in the class is defined as:

    security.declarePublic('Rotate')
    def Rotate(self, img):
       out = img.rotate(45)
       return out

And I try to call it from a template as:

<span tal:replace="structure python:context.Rotate(context.img).tag()"></span>

But i generates the following error:

Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
   - __traceback_info__: context.Rotate(context.img).tag()
  Module PythonExpr, line 1, in <expression>
  Module Products.Sightseeing.SightFolder, line 142, in Rotate
AttributeError: rotate

Do you have any idea what is wrong? Is there any better way how to input an image from a field into a method?

Thanks a lot for any help in advance.

Jan




_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to