Jamu:

Yes, testing also indicates that Date attrs were not serialized.
I will test other datatypes while I work on the appl code.
So this is the corrected code.

*def encode_storm_object(object):*
*     if not hasattr(object, "__storm_table__"):*
*         raise TypeError(repr(object) + " is not JSON serializable")*
*
*
*     result = {}*
*     cls_info = get_cls_info(object.__class__)*
*     for name in cls_info.attributes.iterkeys():*
*         value= getattr(object, name)*
*         if ("<type 'datetime.date'>" == str(value.__class__)): *
*             value= str(value)*
*         result[name] = value*
*     return result*

*json_str = json.dumps(storm_obj, default=encode_storm_object)*

Sorry, but the only way that worked was using the string "*<type
'datetime.date'>*" to test the object class.
I tried using *isinstance(obj, "datetime.date")* but did not work.
Maybe you have a better solution here to check the attr class ... I am new
in Python :-(

Mario

2010/5/27 Jamu Kakar <[email protected]>

> Hi,
>
> On Thu, May 27, 2010 at 11:08 PM, Mario Zito <[email protected]> wrote:
> > Ok, it works with VERY minor corrections:
>
> Yeah, not testing is a great way to write code that doesn't
> work. ;)  Thanks for posting the fixes.
>
> Take care,
> J.
>



-- 
Mario A. Zito
ANALYTE SRL
Parana 457, piso 2, of. 'A'
(C1033AAI) Buenos Aires, Argentina
tel: (54-11) 5258-0205 int 138
[email protected]
www.analyte.com
-- 
storm mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/storm

Reply via email to