On 05/13/2013 04:39 AM, Tom Browder wrote:
> 
> I viewed the page source of a typical subscription page to find how it
> normally works.
> 
> I get to the point of subscription and, using modules LWB::UserAgent
> and URI::Esacpe do;
> 
> 
>     my $browser  = LWP::UserAgent->new;
>     # may need to url encode the e-mail
>     my $enc_email = uri_escape($email);
>     my $enc_name  = uri_escape($fullname);
> 
>     my $response = $browser->post(
>                                 
> "https://host.org/cgi-bin/mailman/$oper/$list";,
>                                 email    => $enc_email,
>                                 fullname => $enc_name,
>                                );
[...]
> When using real data I get the following response from Mailman
> 
> <quote>
> listname Subscription results
> 
> You must supply a valid email address.
> </quote>


I assume $oper is 'subscribe'. There is apparently some incompatibility
between the way perl supplies the post data and the way Python's
cgi.FieldStorage() retrieves it as it is either not seeing the 'email'
name or its value is empty. Those are the only things that produce the
"You must supply a valid email address." response.

You could install the following as a CGI script somewhere and use your
perl module to post to it andsee what it gets.

#!/usr/bin/python

import os
import cgi
import sys

def printenv():
    for n,v in os.environ.items():
        print '%s: %s<br>' % (n,v)
    print '<br>'
    print 'Stdin:<br>'
    sys.stdout.write(sys.stdin.read())
    print '<br>'
    print 'CGI:<br>'
    print '%r' % cgi.FieldStorage(keep_blank_values=1)

def generateFormDocument():
    print 'Content-type: text/html'
    print
    print '<HTML><HEAD><TITLE>Print Environment</TITLE></HEAD><BODY>'
    printenv()
    print ' </BODY> </HTML>'

if (__name__=='__main__'):
    generateFormDocument()

-- 
Mark Sapiro <[email protected]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list [email protected]
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to