[Zope] stdin.read() in Python script

Andy McKay andy@agmweb.ca
Tue, 12 Mar 2002 19:47:52 -0800


All data posted to Zope is placed in the REQUEST object. Make a DTML Method
with the content <dtml-var REQUEST> and view the page.

----- Original Message -----
From: "Janez Jere" <janez.jere@void.si>
To: <zope@zope.org>
Sent: Tuesday, March 12, 2002 3:29 PM
Subject: [Zope] stdin.read() in Python script


> Hi,
> I was adviced in comp.lang.python that I have a problem for this mailing
> list:
>
> Could you help me port my simple cgi to zope pathon script. Problem
> which I am unable to solve is reading posted raw data (legacy client
> posts a xml document to my cgi and expects a result). I tried very hard
> to find a solution, in mean time i wrote script with mod_python, which
> works well, but I need to run it fast in app server.
>
> Among all my attempts the closest solutions are:
> request.get(BODY) # BODYFILE a
> and
> request.stdin.read() # but it is not allowed to access read method.
>
> Thanks, janez
>
> # CGI script and test
> import sys, os
> if len(sys.argv) == 1:
>     print 'Content-Type: text/plain'
>     print
>
>     length = os.environ['CONTENT_LENGTH']
>
>     #print 'length', length
>     print repr(sys.stdin.read(int(length))) # !!! how to read posted data
!!!
>
> else:
>     # test echo
>     url = sys.argv[1]
>     import urllib2 as w
>
>     x= w.urlopen(url, 'abc '*300)
>     print 'read(%s):\n' % url, x.read()
>
>
>
>
> _______________________________________________
> 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 )
>