[Zope] PUT_factory and File object?

Dieter Maurer dieter at handshake.de
Thu Aug 10 14:06:36 EDT 2006


Eric Fernandez wrote at 2006-8-10 12:52 +0100:
> ...
>from OFS.Image import File
>
>def PUT_factory( self, name, typ, body ):
>    if typ.startswith('text'):
>        ob = File(name, '', body, content_type=typ)
>    return ob
>
>
>However, I cannot upload jpg files anymore... What am I doing wrong there?

... because you create an object only when "typ" is of the "text*"
variety. Otherwise, you will get an exception because you use
an object not yet assigned to ("ob").

Have a look at the standard PUT_factory. It is
"webdav.NullResource.NullResource._default_PUT_factory".
Copy it its body to your function and modify it as appropriate.



-- 
Dieter


More information about the Zope mailing list