ZSI & Python newbie

F

Faser

Sorry if this post is stupid, but I'm a python newbie. I would like to do
some experiments with webservices and I try to consume a web service that
return an italian fiscal code (a simple string). I have to send some
strings and a date (birth date). I'm using the ZSI module, but I don't
understand how I can convert a python date in a ZSI SOAP date. The
documentation doesn't help me much.
(http://pywebsvcs.sourceforge.net/zsi.html#SECTION007600000000000000000)
This is my code:

#wsdlURL = "http://www.pinellus.com/cfc/Cod_fiscale.cfc?wsdl";
import sys
import datetime

from ZSI import TC
from ZSI import ServiceProxy

cognome = 'Marco'
nome = 'Rossi'
sesso = 'M'
comune = 'Milano'
provincia = 'MI'
nascita = datetime.date(1950,12,22)
soapNascita = TC.gDate(nascita)

service = ServiceProxy('http://www.pinellus.com/cfc/Cod_fiscale.cfc?wsdl')
codice_fiscale =
service.makecod(cognome,nome,sesso,comune,provincia,soapNascita)
print codice_fiscale

The error is:
File "D:\MySoft\Python\codicefiscale\cf.py", line 16, in ?
soapNascita = TC.gDate(nascita)
File "C:\PROGRA~1\Python23\Lib\site-packages\ZSI\TC.py", line 65, in
__init__
i = self.pname.find(':')
AttributeError: 'datetime.date' object has no attribute 'find'

Could you point me in the right direction to solve this problem?
Thanks in advance.

Faser
 
A

Alex Martelli

Faser said:
Sorry if this post is stupid, but I'm a python newbie. I would like to do
some experiments with webservices and I try to consume a web service that
return an italian fiscal code (a simple string). I have to send some
strings and a date (birth date). I'm using the ZSI module, but I don't
understand how I can convert a python date in a ZSI SOAP date. The
documentation doesn't help me much.
(http://pywebsvcs.sourceforge.net/zsi.html#SECTION007600000000000000000)

The doc you quote says, and I quote its very first line:
"""
SOAP dates and times are Python time tuples in UTC (GMT), as documented in
the Python time module.
"""

Are you using the Python time module, and the time tuples documented in
it? You surely don't seem to be:
import datetime ...
nascita = datetime.date(1950,12,22)
soapNascita = TC.gDate(nascita)

Now, if you passed nascita.timetuple(), THAT might help -- at least
it could be said to place you in compliance with the doc you quote.

However, from the traceback you quote it doesn't seem like that...:

File "D:\MySoft\Python\codicefiscale\cf.py", line 16, in ?
soapNascita = TC.gDate(nascita)
File "C:\PROGRA~1\Python23\Lib\site-packages\ZSI\TC.py", line 65, in
__init__
i = self.pname.find(':')
AttributeError: 'datetime.date' object has no attribute 'find'

Indeed it does, and neither does a timetuple. What this code in
TC.py is doing is trying to parse a string by finding a colon in it.
So, maybe, a string is what you need to pass...? That parameter IS
called 'name' in the docs you quote, after all -- even though to
think of a 'name' as something containing a colon seems strange to me.

Somebody else who IS familiar with ZSI (I'm not) can no doubt help
you more with the details; all I can say for sure is that you surely
don't want to pass a datetime.date object, but what it IS that you
DO want to pass is not clear to me.


Alex
 
F

Faser

Are you using the Python time module, and the time tuples documented in
it? You surely don't seem to be:

I used the time module too, but I always got some kind of errors.
Now, if you passed nascita.timetuple(), THAT might help -- at least
it could be said to place you in compliance with the doc you quote.

However, from the traceback you quote it doesn't seem like that...:



Indeed it does, and neither does a timetuple. What this code in
TC.py is doing is trying to parse a string by finding a colon in it.
So, maybe, a string is what you need to pass...? That parameter IS
called 'name' in the docs you quote, after all -- even though to
think of a 'name' as something containing a colon seems strange to me.

I tried to pass this:
nascita = datetime.date(1950,12,22).timetuple()[:9]

and the error change in:

File "D:\MySoft\Python\codicefiscale\cf.py", line 24, in ?
cf = codiceFiscale('Rossi','Marco','M','Milano','MI',nascita)
File "D:\MySoft\Python\codicefiscale\cf.py", line 14, in codiceFiscale
soapNascita = TC.gDate(nascita)
File "C:\PROGRA~1\Python23\Lib\site-packages\ZSI\TC.py", line 59, in
__init__
self.nspname, self.pname = pname
ValueError: unpack tuple of wrong size

I think I will give up.
Thank you very much for your help.


Faser
 
U

Uche Ogbuji

Faser said:
I used the time module too, but I always got some kind of errors.

[SNIP]

There are some date/time bugs in current ZSI code, as I confirmed in
private correspondence with Rich Salz. He says he expects to work on
it soon. The upshot is that I'm not sure it's possible to pass
date/time params using recent versions of Python with ZSI.

Sorry I don't have better news.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top