Package: pyramid_rest
Pyramid RESTOverviewFirst draft of a pyramid extension to build RESTful web application.Features included:resource definition which configure routes/views, i.e:a resource ‘application’:route [GET/POST] /applicationsroute [GET/DELETE/PUT] /applications/{application_id}route GET /applications/{application_id}/newroute GET /applications/{application_id}/edita resource ‘application.user’:route [GET/POST] /applications/{application_id}/usersroute [GET/DELETE/PUT] /applications/{application_id}/users/{user_id}route GET /applications/{application_id}/users/newroute GET /applications/{application_id}/users/edita singular resource ‘application.user.score’:route [GET/PUT] /applications/{application_id}/users/{user_id}/scoreroute GET /applications/{application_id}/users/{user_id}/score/editresources are added to config introspector and related to their routes,
views, sub-resource and parent resource;end user defines REST methods (index, create, show, update, delete, new,
edit);by default:HTTP 405 is returned for any method not provided;permissions ‘index, create, show, update, delete, new, edit’ are
associated to respective method;3 ways to configure resource:Imperative usingconfig.add_resource, it will associate class in views module to resourceconfig.add_resource('application')# .views.applications:ApplicationsViewconfig.add_resource('application.user')# .views.application_users:ApplicationUsersViewDeclarative usingResourceclass (cornice style)app_users=Resource('application.user')@app_users.index()defindex(context,request,application_id):pass@app_users.show()defshow(context,request,application_id,id):passDeclarative usingresource_configdecorator@resource_config('application.user')classAppUsers(object):def__init__(self,context,request):passdefindex(self,application_id):return{}@method_config(renderer='example.mako')defedit(self,application_id,id):return{}What next?HTTP PATCH method:http://tools.ietf.org/html/rfc5789Resource Scaffolding command;Links;Validation;Pagination;Automatic resource definition of SQLAlchemy entities;Have a view parameter in add_resource to override view definition;Code/Feedbackshttps://github.com/hadrien/pyramid_restChangelogDevelopment0.2.8Compatibility with updated zope.interfacesUsing last functionality of pyramid_mongokitNo more distribute in setup.py0.2.5Moved mongo connection to pyramid_mongokit.0.2.4Switch to github.Add support for mongo database:Setting in ini filepyramid_rest.mongoconsidered true by defaultMongoConnectionis registered to registryTwo properties added torequest:mongo_connectionandmongo_dbMongo connection gets uri fromos.environ['MONGO_URI']Database name comes fromos.environ['MONGO_DB_NAME']Any resource view with amodel_classclass attribute with value being
a definition of amongokit.Documentcan inheritpyramid_rest.mongo.DocumentViewto inherit all default actions.Add custom renderer which adapts output format depending on accept headers,
format supported areapplication/json&application/bson0.1.0Rename ResourceUtility to ResourceConfigurator to make its role clearer.Force human-friendly names for route pattern variables and view callable
parameters, e.g. /applications/{application_id}/users/{id} and
show(context, request, application_id, id)Remove ability to configure resource separator in resource names: it’s always
‘.’Singular resources viaadd_singular_resourcedirective orsingular=Truekeyword argument onResourceorresource_configMoved example from tests directory to root directory: used in test and useful
for documentation.0.0.1Collection resource onlyImperative mode viaadd_resourcedirectiveDeclarative mode viaResourceclassDeclarative mode viewresource_configdecorator