create File object from Python Script?
O.k., I'm stumped. I've been looking over old messages and source code, but I haven't come to enlightenment on creating a File from a string. I can only create one from an uploaded file. I thought maybe I was on to something with using StringIO, but that's not allowed. I'd greatly appreciate a pointer to anything that might get me started. Thank you. --kyler
On Tue, 21 Aug 2001 15:57:47 -0500 you wrote:
O.k., I'm stumped. I've been looking over old messages and source code, but I haven't come to enlightenment on creating a File from a string. I can only create one from an uploaded file.
It's amazing what airing problems in public can do. I decided to wipe out everything I was doing and start over. I dug into OFS/Image.py again and decided that surely "file" could be a string. So I just hardcoded a string into manage_addFile(). It worked! It appears that my problem was not with manage_addFile(), but with what I thought was a string. I think I've got a handle on it. Sorry for the disruption. --kyler
Hi Kyler, Here's the DTML that creates the file object with a time based serial id: <dtml-call "REQUEST.set('ts', ZopeTime())"> <dtml-call "REQUEST.set('id',_.str(_.int(ts)))"> <dtml-call "manage_addFile(id='pwp'+REQUEST['id']+'.fdf', title=REQUEST['USER_NAME']+'_'+REQUEST['PROJ_NAME']+' FDF File', file=getFDF(REQUEST.form))"> Note that "getFDF()" is an External Method in this case, but all it does is return a string. You can replace it with a string literal or a Python Script that returns a string, etc, Hope that helps. Eric.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Kyler B. Laird Sent: Tuesday, August 21, 2001 1:58 PM To: zope@zope.org Subject: [Zope] create File object from Python Script?
O.k., I'm stumped. I've been looking over old messages and source code, but I haven't come to enlightenment on creating a File from a string. I can only create one from an uploaded file.
I thought maybe I was on to something with using StringIO, but that's not allowed.
I'd greatly appreciate a pointer to anything that might get me started.
Thank you.
--kyler
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Oops, just noticed the subject line... Ahem... My code creates the file in DTML, not a Python Script. Sorry! Well, maybe that's enough to get you started(?) - Eric.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Kyler B. Laird Sent: Tuesday, August 21, 2001 1:58 PM To: zope@zope.org Subject: [Zope] create File object from Python Script?
O.k., I'm stumped. I've been looking over old messages and source code, but I haven't come to enlightenment on creating a File from a string. I can only create one from an uploaded file.
I thought maybe I was on to something with using StringIO, but that's not allowed.
I'd greatly appreciate a pointer to anything that might get me started.
Thank you.
--kyler
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Eric Walstad -
Kyler B. Laird