#7651 closed defect (worksforme)
Unable to create version and set time field (can't send a datetime.datetime)
Reported by: | pipern | Owned by: | osimons |
---|---|---|---|
Priority: | normal | Component: | XmlRpcPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description
Unable to create version and set time field, as it expects datetime.datetime but that can't be marshalled. If we send it as a string, we get:
xmlrpclib.Fault: <Fault 1: "'unsupported operand type(s) for -: 'str' and 'datetime.datetime'' while executing 'ticket.version.create()'">
Attachments (0)
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Using what protocol? XML-RPC has native support for marshalling datetime values, but that is not the same type as the default Python datetime type. What you want to use is xmlrpclib.DateTime
datatype, that according to docs:
DateTime wrapper for an ISO 8601 string or time tuple or localtime integer value to generate 'dateTime.iso8601' XML-RPC value.
Seeing you are working with Python as client, you want to look at the xmlrpclib
standard library documentation.
comment:3 Changed 14 years ago by
Ah, thanks for that.
Indeed, this works perfectly:
attrs = {"time":xmlrpclib.DateTime(datetime.datetime.utcnow())} server.ticket.version.create(version, attrs)
comment:4 Changed 14 years ago by
Now even with a test case for illustration (and verification) - see [8688] :-)
Examples which fail: