what if you did something like:
1. define a custom renderer `render_marshmallow` that just does json on the
columns (not relationships) unless you already...
2. define a request property of `render_marshmallow_schema`
3. have your views define `request.render_marshmallow_schema ` (unless
If the renderer name contain a dot then pyramid will use the extension to
get the renderer. So you can create a schema renderer and use it with
something like:
@view_config(renderer='your.module.UserOutputSchema.schema')
Then resolve the dotted name to get the class and instanciate your schema
Hi all,
in my current project we use SQLAlchemy, so we need to be able to render
SQLAlchemy-instances to JSON.
We cannot simply provide a __json__-method, because the serialization
depends on the context. Sometimes, you want to serialize the object without
any relations (e.g. only the
@Gael: Interesting idea, I hadn't thought about that. Though the
no-arguments aspect might be a bit of a problem.
The approach of attaching the schema to the request in the view-function:
request.marshmallow_schema = UserOutputSchema()
... has another advantage besides allowing arguments: You
What about defining your own renderer, and using that in viewconfig instead
of json?
--
You received this message because you are subscribed to the Google Groups
pylons-discuss group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
Good point. I guess that would work for 1 domain object: users. But the
whole approach for modifying the JSON-serialization should work for
multiple view-methods with different model-classes. E.g.:
def get_own_user(request):
...
def get_posts(request):
...
def