Hi, again:

I would like to iterate over all items of a returned ResultSet encoding each
one using JSON. Example code follows:

class Topic(object):
    __storm_table__= "Trancos.topic"
    id = Int(primary=True)
    account_id= Int()
    title= Unicode()
    properties= Unicode()
    notes= Unicode()
    # and other attrs not important here ...

def do_query():
    ''' Query'''
    engine= create_database("postgres://postgres:mypassw...@localhost
/trancos")
    store= Store(engine)

    # execute the query and iterate over the ResultSet
    rs= store.find(Topic)
    for t in rs:
        print t.id, json.dumps(t)

But I get the error:

  File "/usr/lib/python2.6/json/encoder.py", line 344, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <__main__.Topic object at 0x26f3090> is not JSON serializable

Any ideas ? Is there a way to serialize a Storm object (or a full ResultSet)
to JSON ?

Sorry if this a strict Python language item !

Thanks.
Mario

-- 
Mario A. Zito
ANALYTE SRL
www.analyte.com
-- 
storm mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/storm

Reply via email to