<div>Jamu:</div><div><br></div>Yes, testing also indicates that Date attrs were not serialized.<div>I will test other datatypes while I work on the appl code. <div>So this is the corrected code.<div><br></div><div><b>def encode_storm_object(object):</b></div>
<div><b> if not hasattr(object, "__storm_table__"):</b></div><div><b> raise TypeError(repr(object) + " is not JSON serializable")</b></div><div><b><br></b></div><div><b> result = {}</b></div>
<div><b> cls_info = get_cls_info(object.__class__)</b></div><div><b> for name in cls_info.attributes.iterkeys():</b></div><div><b> value= getattr(object, name)</b></div><div><b> if ("<type 'datetime.date'>" == str(value.__class__)): </b></div>
<div><b> value= str(value)</b></div><div><b> result[name] = value</b></div><div><b> return result</b></div><div><br></div><div><b>json_str = json.dumps(storm_obj, default=encode_storm_object)</b></div>
<div><br>Sorry, but the only way that worked was using the string "<b><type 'datetime.date'></b>" to test the object class.</div><div>I tried using <b>isinstance(obj, "datetime.date")</b> but did not work.</div>
<div>Maybe you have a better solution here to check the attr class ... I am new in Python :-(</div><div><br></div><div>Mario</div><div><br></div><div><div class="gmail_quote">2010/5/27 Jamu Kakar <span dir="ltr"><<a href="mailto:jkakar@kakar.ca">jkakar@kakar.ca</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<div class="im"><br>
On Thu, May 27, 2010 at 11:08 PM, Mario Zito <<a href="mailto:mazito@analyte.com">mazito@analyte.com</a>> wrote:<br>
> Ok, it works with VERY minor corrections:<br>
<br>
</div>Yeah, not testing is a great way to write code that doesn't<br>
work. ;) Thanks for posting the fixes.<br>
<br>
Take care,<br>
<font color="#888888">J.<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Mario A. Zito<br>ANALYTE SRL<br>Parana 457, piso 2, of. 'A'<br>(C1033AAI) Buenos Aires, Argentina<br>tel: (54-11) 5258-0205 int 138<br><a href="mailto:mazito@analyte.com">mazito@analyte.com</a><br>
<a href="http://www.analyte.com">www.analyte.com</a><br>
</div></div></div>