[Zope3-Users] Fields for file and images

Johan Carlsson johanc at easypublisher.com
Thu Oct 20 13:29:52 EDT 2005


Johan Carlsson wrote:
> Hi all,
> I'm trying to figure out the easiest way to get fields holding Files or 
> Images in my content type class.
> 
> 
> I've tried the following:
> I've tried using the Object field specifying the 
> zope.app.file.interfaces.IFile as the schema and then
> implement a CustomWidgetFactory with zope.app.file.file.File
> as the factory.
> 
> This actually looks ok both in the AddView and the EditView
> but the updates fail (due to cPickle.UnpickleableError: Cannot pickle 
> <type 'zope.security._proxy._Proxy'> objects, which sounds like the
> File object needs to be removed from it's proxy somewhere in the chain?)

Ok, this error was as I suspected due to that security proxy was saved
instead of the object, I've temporarely solved this by implementing
the file attribute of the class as a property and use
removeSecurityProxy in the set method.

> Any thought on how to solve this problem (my approach or other approach)?

I've discovered that there are more things to wish for in the Object
file and also in the corresponding ObjectWidget (that handles the update
for the File fields).
Some of the things that ObjectWidget doesn't do is honer the ILocation
interface, submitting events and also some file upload specifics such as
getting the content-type from the submitted data (such as the FileUpload
view does for normal file objects).

This leads me to the assuption that I need to implement my own View
class (at the least) and even my own Field class.

Please correct me if I'm wrong and there is an easier way to make
a File/Image field on a content type class!

Regards,
Johan

-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM


-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM



More information about the Zope3-users mailing list