Hi guys,

 

I’m trying to extend the Interface IImage by a title and a caption. My plan was to use zope.app.file.interfaces.IImage as base interface and zope.app.file.Image as base class, but that doesn’t work. Every time I submit the add form, I get the following traceback:

[…]

  File "C:\Python24\Lib\site-packages\zope\tales\tales.py", line 696, in evaluate

    return _expression_(self)

  File "C:\Python24\Lib\site-packages\zope\tales\expressions.py", line 205, in __call__

    return self._eval(econtext)

  File "C:\Python24\Lib\site-packages\zope\tales\expressions.py", line 199, in _eval

    return ob()

  File "C:\Python24\Lib\site-packages\zope\app\form\browser\add.py", line 62, in update

    self.createAndAdd(data)

  File "C:\Python24\Lib\site-packages\zope\app\form\browser\add.py", line 120, in createAndAdd

    field.set(adapted, data[name])

  File "C:\Python24\Lib\site-packages\zope\schema\_bootstrapfields.py", line 183, in set

    setattr(object, self.__name__, value)

  File "C:\Python24\Lib\site-packages\zope\security\checker.py", line 488, in check_setattr

    self._checker2.check_setattr(object, name)

ForbiddenAttribute: ('contentType', <pr.image.image.CustomImage object at 0x02FB8CB0>)

 

What’s the problem? Why is contentType forbidden? “Data” and “contentType” are valid attributes of the base interface “zope.app.file.interfaces.IImage”.

 

I would appreciate every hint showing me why I’m off the mark. Thanks in advance,

 

Arne

 

PS: I’m working on Zope 3.3 and Python 2.4. The following lines show the interface, the class and the zcml-directives for the add form.

 

Interfaces.py:

from zope.app.file.interfaces import IImage

class ICustomImage(IImage):

  imagetitle = TextLine(

    title=_(u"Title"),

    description=_(u"The image title."),

    default=u"",

    required=False)

 

  imagecaption = Text(

    title=_(u"Caption"),

    description=_(u"The image caption. Will be displayed in the user view. "),

    default=u"",

    required=False)

 

image.py:

from zope.app.file import Image

from pr.image.interfaces import ICustomImage

class CustomImage(Image):

  implements(ICustomImage)

 

  title = u''

  description = u''

 

  def __init__(self, data='', title='', caption=''):

    super(Image, self).__init__(data)

    self.imagetitle = title

    self.imagecaption = caption

 

configure.zcml:

[…]

  <addform

      label="Add customized image"

      name="AddCustomImage.html"

      schema="pr.image.interfaces.ICustomImage"

      content_factory="pr.image.image.CustomImage"

      fields="contentType data imagetitle imagecaption"

      permission="zope.ManageContent"

      />

  <addMenuItem

      class="pr.image.image.CustomImage"

      title="Customized image"

      description="A customized image"

      permission="zope.ManageContent"

      view="AddCustomImage.html"

      />

[…]

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to