<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Tom &amp; all,<br>
<br>
First of all, thanks for the help. Its much appreciated :) I understand
what you're suggesting, but I needed a way to do it without traversal.
For what I'm trying to do, the interface and implementation of the zope
objects need to be as simple as possible - anything fancy needs to be
(if possible) outside the interface/implementation (like in a widget)<br>
<br>
I attached what I ended up doing for the widget and the form. Its
nothing radical, and very crude, but it works.<br>
<br>
(The supdoc attribute in the form is defined as <br>
<pre wrap="">supDoc = List(title=_(u"Supporting Docs List"), value_type=Object(IImage, __name__='ImgItem', title=_(u"Image")))
<span class="moz-txt-citetags">&gt; </span>
<span class="moz-txt-citetags">&gt; </span></pre>
anyway, hope this helps anyone who gets stuck on this sort of thing.<br>
<br>
Again, thanks.<br>
Adam<br>
<br>
Tom Dossis wrote:
<blockquote cite="mid45828658.4090105@yoma.com.au" type="cite">
  <pre wrap="">Adam Summers wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi Tom &amp; Widget Afficionados.

Thanks for the help so far.

My problem is now this:

    From this code (which Tom supplied), how do I code the logic (in
bold)      

    def _toFieldValue(self, input):
        data = super(ImageWidget, self)._toFieldValue(input)
        if data is not None:
            img = Image(data)
            notify(ObjectCreatedEvent(img))
            return img
        *else: #data is None, ie. the File input field was left blank and we don't want to 
            #replace the current value of the Image Widget with an empty value.
            currentImg = the Image object which the field is being rendered for
            return currentImg 

*

I can't rely on

            field = self.context

            image = field.get(field.context)


logic to find the data, because my schema can contain:

class Iclaim(IContained):

        """Claim"""

        supDoc = List(title=_(u"Supporting Docs List"), value_type=Object(IImage, __name__='ImgItem', title=_(u"Image")))

        img = Object(IImage, title=_(u"Single img"), required=False)


    And hence, the self.context.context points to the claim object, not
the list inside when rendering supDoc
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Hi Adam,
You can rely on:

  field = self.context
  image = field.get(field.context)

because the widget is for an attribute object of type IImage.

Your supDoc attribute object is a List Type - not an IImage.
In this case you'd need another widget - for a list of IImage.

I wouldn't been too keen to tackle the html work effort and would
probably look at an alternative along the lines of...

class IImageList(IContainer):
  contains(zope.app.image.interfaces.IImage)

class IClaim(IContained):
  supDoc=Object(schema=IImageList)

Make supDoc traversable, then you wouldn't need the custom widget here
because you can store Images directly in supDoc view with the
browser:containerView's.
  </pre>
</blockquote>
<br>
</body>
</html>