I have the following widgets.

class MyImageDisplayWidget(DisplayWidget):

   class_ = Image

   def __call__(self):
       mycontent = u"oops! no img"
       if self._renderedValueSet():
           mycontent = "<img src=\"data:image/gif;base64, " +
b64encode(self._data.data) + " \" />"
       return mycontent

MyImageListDisplayWidget = CustomWidgetFactory(SequenceDisplayWidget,
subwidget = MyImageDisplayWidget)

class MyImageWidget(FileWidget):

   class_ = Image

   def _toFieldValue(self, input):
       value = super(MyImageWidget, self)._toFieldValue(input)
       return self.class_(value)

MyImageListWidget = CustomWidgetFactory(ListSequenceWidget, subwidget =

I want to build a better input widget (MyImageWidget), so that we can do
the following:
   * If the field has no data, display a file input.
   * If the field has data, display the image.

I know that there are design shortcomings in this, but I need a simple
example (and I only use the files in lists anyway, so I can delete images).

Any pointers on how to go about this would be much appreciated; as always

Thanks and Regards,

Zope3-users mailing list

Reply via email to