ZSI & Python newbie

Alex Martelli aleax at aleax.it
Wed Nov 12 11:16:53 EST 2003


Faser wrote:

> 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





More information about the Python-list mailing list