PUT_factory and File object?
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
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@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
On 10. Aug 2006, at 13:52, Eric Fernandez wrote:
def PUT_factory( self, name, typ, body ):
ob = None
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?
Stefan -- Anything that, in happening, causes something else to happen, causes something else to happen. --Douglas Adams
Stefan H. Holek wrote:
On 10. Aug 2006, at 13:52, Eric Fernandez wrote:
def PUT_factory( self, name, typ, body ):
ob = None
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?
Stefan
-- Anything that, in happening, causes something else to happen, causes something else to happen. --Douglas Adams
So I guess http://www.plope.com/Books/2_7Edition/ExternalTools.stx#2-18 needs to be corrected? Eric
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
participants (3)
-
Dieter Maurer -
Eric Fernandez -
Stefan H. Holek