[Zope] Security in External Method - urllib

Marc Burgauer marc@sharedbase.com
Sun, 23 Feb 2003 18:12:27 +0000


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