Hi guys, For several reasons, I would like to have direct access to raw posted data in my dtml-code (an analogue of QUERY_STRING). Can anyone please show me the light? Thanks, Shai.
Hi Shai, This external method works for me. -steve ---------------------------------------------------------------------- def getRawInput(self, REQUEST): meth = REQUEST.environ.get('REQUEST_METHOD','GET') if meth != 'GET': REQUEST.stdin.seek(0) result = REQUEST.stdin.read() else: result = REQUEST.environ.get('QUERY_STRING','') return result # # Test functions.. # if __name__=='__main__': import StringIO class Foo: pass REQUEST = Foo() REQUEST.environ = {'REQUEST_METHOD':'GET', 'QUERY_STRING':"Yup.. it's a query string."} print getRawInput(None, REQUEST) REQUEST = Foo() REQUEST.environ = {'REQUEST_METHOD':'POST'} REQUEST.stdin = StringIO.StringIO() REQUEST.stdin.write("It's a streamed input.... ") print getRawInput(None, REQUEST)
Hi, how is it possible to convert a string into my own zclass type? I get a String from a form and want to do some operation like string.manage_addFile(... on it. So what to do ??? Perhaps some out there is able to help ... Thanks, Marc
To "convert" a string to an object, you use the getitem() function. ## example 1: Your: <dtml-var last_name> #returns: Your: Peter Bengtsson ## example 2: <dtml-call "REQUEST.set('var_to_go_and_get','last_name')"> Your: <dtml-var "_.getitem(var_to_go_and_get)"> # returns: Your: Peter Bengtsson There's more.... You could also do this: <dtml-var "_[var_to_go_and_get]"> or <dtml-var "_['last_name']"> The different between _['foo'] and _.getitem('foo') is tricky. Check out (somewhere in the middle): http://www.zope.org/Documentation/How-To/AdvancedDTML
Hi,
how is it possible to convert a string into my own zclass type? I get a String from a form and want to do some operation like string.manage_addFile(... on it. So what to do ??? Perhaps some out there is able to help ...
Thanks,
Marc
_______________________________________________ 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 (4)
-
Marc Fischer -
Peter Bengtsson -
Shai Berger -
Steve Spicklemire