473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

xml-rpc - adodb - None type - DateTime type

Hi to all,

I have functions defined in an xml-rpc server. Some functions query to
a Postgres database (using adodb) and return its recordset. So, if some
xml-rpc client runs the mentioned function, it will retrieve the
recordset. The problem is that if a retrieved field has the Null value
or the Date value (DateTime Database format), then, the retrieved
recordset in the python program will have the 'None' value or the
DateTime type object value.

xml-rpc isn't able to accept any type of value, so I have to solve it.

I can replace all None values with the string 'Null', there's no
problem, but I can't detect the DateTime type object I retrieve from
the database.

I have something like this:
def xmlrpc_function():
conn = adodb.NewADOConnection('postgres')
conn.Connect(host,user,password,database)
rs = conn.Exec("select * from table")
result = []
i = 0
while not rs.EOF:
row = rs.GetRowAssoc(False)
for key, value in row.items():
if value==None:
row[key]='Null'
result.append(row)
i = i + 1
rs.MoveNext()
rs.Close()

print result
return result

The problem here is that if row[key] == <type 'DateTime' object
etc...>, then I don't know what to do for detect it and make the
appropriate change to string.

Console output:
[{'name': 'Null', 'date': <DateTime object for '2005-09-01 00:00:00.00'
at 1515f60>}]

If you consult the python manual, you'll see that there's no 'DateTime'
type object, so I can't do something like:

if value==DateTimeType:
...

I only need to know which type of data is a field for make the change
according to what can I pass through the xml-rpc.

Any help?

Thanks

Oct 28 '05 #1
1 2935
> I can replace all None values with the string 'Null', there's no
problem, but I can't detect the DateTime type object I retrieve from
the database.

I have something like this:
def xmlrpc_function():
conn = adodb.NewADOConnection('postgres')
conn.Connect(host,user,password,database)
rs = conn.Exec("select * from table")
result = []
i = 0
while not rs.EOF:
row = rs.GetRowAssoc(False)
for key, value in row.items():
if value==None:
row[key]='Null'
result.append(row)
i = i + 1
rs.MoveNext()
rs.Close()

print result
return result

The problem here is that if row[key] == <type 'DateTime' object
etc...>, then I don't know what to do for detect it and make the
appropriate change to string.

Console output:
[{'name': 'Null', 'date': <DateTime object for '2005-09-01 00:00:00.00'
at 1515f60>}]

If you consult the python manual, you'll see that there's no 'DateTime'
type object, so I can't do something like:

if value==DateTimeType:
...

I only need to know which type of data is a field for make the change
according to what can I pass through the xml-rpc.


Well, there is the possibility of passing null values through xml-rpc.
I believe there is an optional keyword argument in some of the
xmlrpclib functions to allow it. Basically it translates None to
<nil/> in the xml.

The DateTime type must be defined somewhere. Is it an adodb type? If
so, you could do something like this:

if type(value) == adodb.DateTime:
...

Oct 28 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);...
2
by: Simon Strandgaard | last post by:
I am trying to understand how to create a 'catalog.xml' file for my docbook-xml documents. If I understand correct a local catalog.xml file can both avoid hardcoding in makefiles (portability),...
0
by: MarionEll | last post by:
Premier XML Industry Event Slated for Dec. 7-12 in Philadelphia; Presenters Include Adobe, BEA, Microsoft, IBM, Sun, Hewlett-Packard, Oracle Alexandria, Va. Sept. 30, 2003 - IDEAlliance, a...
6
by: yzzzzz | last post by:
Hi, In which cases is the <?xml version="1.0" encoding="UTF-8"?> processing instruction required at the beginning of an XML document, for the document to be valid? e.g. does it depend on the...
0
by: MarionEll | last post by:
XML 2003 Exposition Draws Leading XML Vendors Trade Show, Presentations Allow Companies to Showcase Cutting-edge Solutions Alexandria, Va. - Dec. 1, 2003 - XML 2003, the world's largest XML...
0
by: Stylus Studio | last post by:
World's Most Advanced XML Schema Editor Adds Support for IBM AlphaWorks XML Schema Quality Checker to Improve XML Schema Style and Quality BEDFORD, MA -- 09/13/2005 -- Stylus Studio...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
0
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): ...
10
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I had a program and it always works fine and suddenly it gives me the following message when a pass a xml file to our server program: error code: -1072896680 reason: XML document must...
0
by: Jacker | last post by:
Xpress Author for MS Word XML Documents In.vision Research empowers knowledge workers to create complex XML documents in Microsoft Word (2000-2003) with a normal Word experience. Deploy XML...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.