> --
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/GW86sjghplgJ.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discus...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
--
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.
I use a combination of this. A __json__ method on Base, and a custom json renderer, taking this method into account.
Regards
Robert
--
Have a look at
https://github.com/spiral-project/ihatemoney/blob/master/budget/models.py#L12
and
https://github.com/ametaireau/flask-rest/blob/master/flask_rest.py#L144
However, this isn't automatic, and it is probably possible to automate
this without having to explicitly specify what you want to serialize
(like Julien did)
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/TOFfc3SAPXEJ.
Sorry for self-advertisement, but I've wrote a small utility to solve this kind
of problems -- jsonpublish[1]. Code looks like this:
class Base(object):
pass
from jsonpublish import register_adapter, dumps
@register_adapter(Base)
def adapt_base(b):
return {} # adapt Base object to json-encodable structure
dumps(Base()) # now it works!
See docs[1] for more info.
[1]: http://jsonpublish.readthedocs.org/en/latest/index.html