[Zope] Raw post data

Steve Spicklemire steve@spvi.com
Sun, 14 Jan 2001 10:48:59 -0500 (EST)


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)