James Allwyn wrote:
I too have been getting "UnpickleableError" while playing with ObjectWidgets.

Hi James,
What I ended up doing was to move the removeSecurityProxy from the Content Type Class to the Browser View (where I think it belongs).
(In my case this would be an overriden version of ObjectWidget)

The method applyChanges was override ang changed to include the removeSecurityProxy. (see below)

For your example you would have to create a PersonWidget and a PageWidget (copy the applyChanges from ObjectWidget and change
so the security is removed before saving).
(The classes might end-up looking the same, som maybe you only
need one?)

But I'm now suspecting the real problem is due to a misconfiguration
in ZCML. I'll let you know what I find out.


class FileWidget(ObjectWidget):

    def applyChanges(self, content):

        field = self.context

        # create our new object value
        value = field.query(content, None)
        if value is None:
            # TODO: ObjectCreatedEvent here would be nice
            value = self.factory()

        # apply sub changes, see if there *are* any changes
        # TODO: ObjectModifiedEvent here would be nice
        changes = applyWidgetsChanges(self, field.schema, target=value,

        # if there's changes, then store the new value on the content
        if changes:
            form = self.request.form
            filename = getattr(form["field.file.data"], "filename", None)
            contenttype = form.get("field.file.contentType")
            if filename:
                if not contenttype:
contenttype = content_types.guess_content_type(filename)[0]

            #descriptor = objectevent.Attributes(IFile, "contentType")
            #descriptor.attributes += "data"
            #event = objectevent.ObjectModifiedEvent(file, descriptor)

            field.set(content, file)

        return changes

fw = CustomWidgetFactory(FileWidget, File )

Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: [EMAIL PROTECTED]

Zope3-users mailing list

Reply via email to