Pyramid and Web Services open space at PyCon?

72 views
Skip to first unread message

Laurence Rowe

unread,
Mar 5, 2013, 2:34:47 PM3/5/13
to pylons...@googlegroups.com
I'd like to propose holding a Pyramid and Web Services open space at PyCon later this month. If there's interest, I'll try and pre-register it with the PyCon organisers. Some of the topics I'd like to discuss are:

I've found merging the context factory and view class can make sense when building web services (I've ended up using a custom mapper). Maybe there could be `route_config` decorator for defining route patterns and context factories which could be used in combination with the `view_defaults` decorator on view classes/methods? Maybe we could end up with something like:

@factory
@route_config('thing', '/thing/{name}')
class Thing:
    __acl__ = [...]
    @view_config(permission='view', request_method='GET')
    def get(self):
        ...

I'd also like to make it possible for view_config to work for base classes.

What are people's experience with JSON Schema? It's an attractive option for me as I want to provide client side validation in addition to server side validation. The PyPI jsonschema module has extensive tests but is focussed only on validation and lacks lacks the full  serialization and deserialization features of Colander. I started extending jsonschema in https://github.com/Julian/jsonschema/pull/72, but might mapping onto Colander be the better option?

Rendering of WSGIHTTPExceptions is currently tied directly into the exception class. Should the content negotiation there between html and plain text be extended to cover json, or would it be best left to an exception view? When an HTTPException is returned by a view, there is no opportunity for a an exception view to be invoked. Perhaps WSGIHTTPException.__call__ should invoke the same exception view lookup logic as in excview_tween, with the the current prepare method moved to an exception view? 

I'm currently using a variation on Cornice's resource pattern in my application. Pyramid 1.4 now provides built in JSON rendering support, are there any other Cornice features that should be implemented in core?

Laurence

Zak

unread,
Mar 6, 2013, 11:18:29 PM3/6/13
to pylons...@googlegroups.com
+1. Incorporating useful features from Cornice into the Pyramid core is a VASTLY superior option than having to pip install a pseudo-platform like Cornice. Pyramid should be able to stand on its own...it should not need a layer of any sort on top of it.

My view on validation: To have the most concise and efficient validation system possible, you must be able to use the same system to validate and serialize/deserialize the entire stack: view -> controller -> model (in our case, JSON requests -> Python objects -> database entries/nodes/docs/whatever). This means that your method of validation should be tailored (to some degree) to, or flexible enough to consider, what database you're using. Your validation and modelling should be quite different depending on whether you're using NoSQL or SQL, for example.

I'm in the process of creating a validation system which extends Voluptous to create a super concise, easy to use, extensible validation and modelling template to use with MongoDB. It's custom designed for NoSQL, which means it embraces such concepts as informal schemas and lightweight validation. I mention this because many validation systems, such as Pyramids built-in system, don't really take model philosophies into consideration, and have many conventions which are holdovers from traditional database modeling.

In summary, your validation system should depend on what modeling philosophy/db you're using.

Whit Morriss

unread,
Mar 7, 2013, 5:02:26 PM3/7/13
to <pylons-devel@googlegroups.com>

<snip>
>
> I'm currently using a variation on Cornice's resource pattern in my application. Pyramid 1.4 now provides built in JSON rendering support, are there any other Cornice features that should be implemented in core?

the auto documentation of endpoints plugin for sphinx are pretty sweet and I think generally useful.

There also was some work on auto generating crud controllers from models in cornice-sqlalchemy. I don't think this should be in the core obviously, but fleshing that out and bring it up to date would be a great resource for folks wanting to get a fast start or doing rapid prototyping.

-w

d. "whit" morriss
Platform Codemonkey
wh...@surveymonkey.com

Laurence Rowe

unread,
Mar 15, 2013, 1:46:25 AM3/15/13
to pylons...@googlegroups.com
On Tuesday, 5 March 2013 11:34:47 UTC-8, Laurence Rowe wrote:
I'd like to propose holding a Pyramid and Web Services open space at PyCon later this month. If there's interest, I'll try and pre-register it with the PyCon organisers.

We have room 209, 2-4pm Sunday.

Laurence
Reply all
Reply to author
Forward
0 new messages