[Zope] PUT_factory and File object?
Eric Fernandez
egf05 at doc.ic.ac.uk
Thu Aug 10 07:52:34 EDT 2006
Eric Fernandez wrote:
> Hi,
>
> I am trying to upload text files as File objects instead of DTML
> documents to avoid HTML escaping.
> What is the type of the File object in Zope ? The example in the Zope
> book are ZopePageTemplate and PythonScript objects,, but I just want a
> File object. This does not work:
>
> def PUT_factory( self, name, typ, body ):
> if typ.startswith('text'):
> ob = File(name, body)
> return ob
>
> Which is the correct syntax? Where can I find the list of available
> objects in Zope and their attributes?
> Thank you,
> Eric
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
I found this syntax which seems to work correctly for text files:
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?
Eric
More information about the Zope
mailing list