[Zope] Security in External Method - urllib

Andreas Jung Andreas Jung <lists@andreas-jung.com>
Sun, 23 Feb 2003 19:29:13 +0100


http://user:password@host:port/...

--On Sonntag, 23. Februar 2003 18:12 +0000 Marc Burgauer 
<marc@sharedbase.com> wrote:

> In an external method, I want to perform an HTTP POST to a remote web
> site, to submit a record to a database.
>
> The remote site requires basic HTTP authentication to submit the data, the
> users database is in synch with my Zope.
>
> My external method:
>
> def DoHTTPpost (firstname, lastname, email):
>     """
>     This function performs an HTTP Post and returns the
>     resulting data. No parsing of the data is done.
>     """
>     import urllib
>     TheURL =  'http://somedomain.com/databasescript'
>     postData = {'Firstname':firstname, 'Lastname':lastname, 'Email':email}
>     codedData = urllib.urlencode(postData)
>     TheCall = urllib.urlopen(TheURL, codedData)
>     return TheCall.read()
>
> This works fine if the authentication on the remote site is switched off.
> How can I supply the current user's name and password in my urlopen call?
>
> What's the syntax and how do I get the current users name and password?
>
> If this is not possible in an external method, how could it be done?
>
> Cheers
>
> Marc
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )




-- 
    ---------------------------------------------------------------------
   -    Andreas Jung                     http://www.andreas-jung.com   -
  -   EMail: andreas at andreas-jung.com                              -
   -            "Life is too short to (re)write parsers"               -
    ---------------------------------------------------------------------