First off I am brand new to python, pylons, elixir, sqlalchemy, etc so
please go easy on me.  I am looking to turn some data from an Elixir
model into json.  If I pull the data with:

data = model.Item.query.all()

and attempt to jsonify:

simplejson.dumps(data)

I get the TypeError: <Item> is not JSON serializable

which I can work around with:

def encode_elixir_entity(obj):
     if isinstance(obj, elixir.entity.Entity):
         return obj.to_dict()
     raise TypeError(repr(o) + " is not JSON serializable")

then:

simplejson.dumps(data,default=encode_elixir_entity)

works as expected.  So, now with my limited python/pylons knowledge, I
am ultimately trying to make use of the above in a pylons controller.

Since the @jsonify decorator takes no arguments im assuming there is
no way for me to specify the default=encode_elixir_entity option, is
that correct?

I think I can I hack the pylons.decorator code to meet my purposes,
but I am trying to do things "the right way".  Is there another
alternative someone can suggest or point me in the right direction?

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to