Hello Everybody,
I have been using soaplib since a few weeks. One thing caught my eye. Its
the "Date" and "DateTime" data types. I wanted to have a customized
representation/format of the Date object when the xml tree is generated. The
default one is YYYY-MM-DD. But what if I wanted to have YYYY/MM/DD or
DD-MM-YYYY ? I have tried to look for a way I can do it with the existing
soaplib API. Unfortunately I was not able to figure out. Can you please
guide me ? If I know the trick, I can implement it and will send a
pull-request for your review. Please help.
Here is sample code:
from lxml import etree
from soaplib.core.model.primitive import String, Date
from soaplib.core.model.clazz import ClassModel
from soaplib.core.util.model_utils import ClassModelConverter
from datetime import datetime
class FormattedDate(Date):
'''This is supposed to used for a customized Date display'''
pass
class Employee(ClassModel):
** roll = String
dob = FormattedDate(nillable=False, min_occurs=1, max_occurs=1,
doc='Date of Birth')
emp = Employee()
emp.roll = '001'
emp.dob = datetime.date(datetime.now())
conv = ClassModelConverter(emp)
conv.include_parent = False
conv.include_ns = True
print conv.to_xml()
PS: I haven't tried rpclib <https://github.com/arskom/rpclib>, but I guess
the customizations which I want to achieve for soaplib, might be the same
for rpclib also. If not, can you please clarify ?
Regards,
Nandakishore
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap