Hello, I'm having trouble getting two features to work together. I spent the best part of a day trying to find uploaded POST data. I've seen lots of references to a BODY attribute, but my request objects don't seem to have one. Using REQUEST.stdin does seem to work, but only on ExternalMethods, not PythonScripts. What is the correct way to access POST data, and can it be done in PythonScripts? Being forced to use ExternalMethods, then, I found I was unable to use traverse_subpath, even with "##bind subpath=traverse_subpath" in my external script. For a given object, /foo/bar (where bar is an external method), a request to /foo/bar/123 would cause Zope to be unable to publish the object. Is it possible to use these two features together? (Preferably in a PythonScript rather than an ExternalMethod.) If not, it looks like I'll have to resort to using external methods and site access rules. Zope version is 2.7.2. Thanks, Dan. -- Dan Ellis <dan.ellis@northlindsey.ac.uk> Computer Officer, North Lindsey College 01724 294024 (ext. 4024 internally) Microsoft Certified Professional
Hi, Am Fr, den 17.09.2004 schrieb Dan Ellis um 10:34:
Hello,
I'm having trouble getting two features to work together. I spent the best part of a day trying to find uploaded POST data. I've seen lots of references to a BODY attribute, but my request objects don't seem to have one. Using REQUEST.stdin does seem to work, but only on ExternalMethods, not PythonScripts. What is the correct way to access POST data, and can it be done in PythonScripts?
POST data? When you are sending forms you get all form elements nicely parsed into variables, accessible thru request. This includes fileopload, where the variable you get behaves like a python file object open for read. No need to work on raw stream data here. Regards Tino Wildenhain
Dan Ellis wrote:
Hello,
I'm having trouble getting two features to work together. I spent the best part of a day trying to find uploaded POST data. I've seen lots of references to a BODY attribute, but my request objects don't seem to have one. Using REQUEST.stdin does seem to work, but only on ExternalMethods, not PythonScripts. What is the correct way to access POST data, and can it be done in PythonScripts?
Being forced to use ExternalMethods, then, I found I was unable to use traverse_subpath, even with "##bind subpath=traverse_subpath" in my external script. For a given object, /foo/bar (where bar is an external method), a request to /foo/bar/123 would cause Zope to be unable to publish the object.
Is it possible to use these two features together? (Preferably in a PythonScript rather than an ExternalMethod.) If not, it looks like I'll have to resort to using external methods and site access rules.
Zope version is 2.7.2.
Make sure that your form uses 'multipart/form-encoded' (sp?) for the encoding of the form; otherwise, the file upload widget will send only the filename. Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
On Fri, Sep 17, 2004 at 09:34:12AM +0100, Dan Ellis wrote:
Being forced to use ExternalMethods, then, I found I was unable to use traverse_subpath, even with "##bind subpath=traverse_subpath" in my external script. For a given object, /foo/bar (where bar is an external method), a request to /foo/bar/123 would cause Zope to be unable to publish the object.
The ##bind magic is specific to Script (Python). In an external method, it's just treated as a comment. However, you can easily duplicate its functionality in an External Method or product code. Something like: request = self.REQUEST subpath = request.get('traverse_subpath', '') ... -- Paul Winkler http://www.slinkp.com
Paul Winkler wrote:
request = self.REQUEST subpath = request.get('traverse_subpath', '')
Hmm. That's not working for me. If I request /externalmethod, which for testing purposes returns self.REQUEST.get('traverse_subpath', None), then I get None back. If I request /externalmethod/test I get a "Cannot locate object" error from Zope. Just to reiterate: I'm trying to write a Python script which can both handle a POSTed file (*not* from an HTML form) and utilise extra subpath information. I don't much mind whether this is a PythonScript or an ExternalMethod (although I'd prefer the former). If Zope can't do both of these together, I don't see how it can be used for RESTful development. Dan. -- Dan Ellis <dan.ellis@northlindsey.ac.uk> Computer Officer, North Lindsey College 01724 294024 (ext. 4024 internally) Microsoft Certified Professional
Okay, I seem to have found a solution that works. I use a PythonScript object which just does: return container.myexternalmethod(container.REQUEST) This is okay, in that I get request.traverse_subpath, request.stdin and can use an external Python editor. It's very non-obvious, tho! Dan. -- Dan Ellis <dan.ellis@northlindsey.ac.uk> Computer Officer, North Lindsey College 01724 294024 (ext. 4024 internally) Microsoft Certified Professional
participants (4)
-
Dan Ellis -
Paul Winkler -
Tino Wildenhain -
Tres Seaver