Pop and forms and retrieve methods??? 
Author Message
 Pop and forms and retrieve methods???

Thanks for the pointers they really help. But I've stumbled upon another
problem that I cannot understand: I use the Cookie.py module and the cgi.py
module to for Cookie.py store the login and password for future retrieval
and the cgi.py to use with forms that give out the id of the message I want
to view. I have a link that looks like http://localhost/mail.py?id=2 and
then I use the
try:
                form = cgi.FieldStorage()
                LField = form["ogin"]
                PField = form["pwd"]
 try:
                form = cgi.FieldStorage()
                DField = form["id"]
                li = DField.value
finally:
msd = pop.retrieve(li)
only to get:
Traceback (innermost last):
  File "/var/www/cgi-bin/mail/msg.py", line 42, in ?
    msd = pop.retrieve(li)
  File "/usr/local/lib/python1.5/pop.py", line 304, in retrieve
    data = self.command("RETR %d" % msg)
TypeError: illegal argument type for built-in operation
I thought at first since my variable was called ID would be conflicting with
the module but li seems pretty random? What is happening? I also thought it
might be because the DField.value was incorect but it generates a number and
not a phrase.
Regards,
Akhar


Thu, 05 Sep 2002 03:00:00 GMT  
 Pop and forms and retrieve methods???

Quote:

> Thanks for the pointers they really help. But I've stumbled upon another
> problem that I cannot understand: I use the Cookie.py module and the cgi.py
> module to for Cookie.py store the login and password for future retrieval
> and the cgi.py to use with forms that give out the id of the message I want
> to view. I have a link that looks like http://localhost/mail.py?id=2 and
> then I use the
> try:
>                 form = cgi.FieldStorage()
>                 LField = form["ogin"]
>                 PField = form["pwd"]
>  try:
>                 form = cgi.FieldStorage()
>                 DField = form["id"]
>                 li = DField.value
> finally:
> msd = pop.retrieve(li)

The formatting is rather strange here, but assuming that this is merely a result
of the way your message was posted...

Quote:
> only to get:
> Traceback (innermost last):
>   File "/var/www/cgi-bin/mail/msg.py", line 42, in ?
>     msd = pop.retrieve(li)
>   File "/usr/local/lib/python1.5/pop.py", line 304, in retrieve
>     data = self.command("RETR %d" % msg)
> TypeError: illegal argument type for built-in operation

Firstly, where does 'msg' come from? Is it taking the value of 'li' in the
function/method call? If so, then...

Quote:
> I thought at first since my variable was called ID would be conflicting with
> the module but li seems pretty random? What is happening? I also thought it
> might be because the DField.value was incorect but it generates a number and
> not a phrase.

Are you sure that 'li' refers to an integer value? Take a look at this:

Quote:
>>> print "Horse %d" % "2"

Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: illegal argument type for built-in operation

Quote:
>>> print "Horse %d" % int("2")
Horse 2

I can't remember how the 'cgi' module's objects treat numeric values, but I
would suspect that they do no conversions on received field values unless you
somehow specify the kind of conversions you want, or alternatively do them
yourself. The error you get suggests that 'DField.value' is a character string.
Try using the 'int' function as I do in my example, remembering to wrap it in an
appropriate 'try'...'except' block, of course.

Paul



Fri, 06 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. call vb dll (will pop up vb form) form python

2. Pop Mail - retrieve and delete msgs

3. CGI - Retrieving types used in a form

4. EXPECT: Retrieving CGI forms without CGI package

5. Automatic POP UP of a form

6. Pop forms and syntax extension in Prolog and Dylan

7. IE Microsoft Explorer Pop up form hell

8. Squeak Form methods

9. Orphaned Class method on Form

10. form cancel confirm, change method at runtime?

11. CGI forms using POST method and Absoft Fortran on Linux

12. Getting Python to mimic a CGI form submission using GET method

 

 
Powered by phpBB® Forum Software