角锥架延长件
pyramid_rest的Python项目详细描述
棱锥支座
概述
构建restful web应用程序的金字塔扩展的初稿。
包括的功能:
resource definition which configure routes/views, i.e:
a resource ‘application’:
- route [GET/POST] /applications
- route [GET/DELETE/PUT] /applications/{application_id}
- route GET /applications/{application_id}/new
- route GET /applications/{application_id}/edit
资源“application.user”:
- route [GET/POST] /applications/{application_id}/users
- route [GET/DELETE/PUT] /applications/{application_id}/users/{user_id}
- route GET /applications/{application_id}/users/new
- route GET /applications/{application_id}/users/edit
单一资源“application.user.score”:
- route [GET/PUT] /applications/{application_id}/users/{user_id}/score
- route GET /applications/{application_id}/users/{user_id}/score/edit
资源被添加到配置内省程序并与其路由相关, 视图、子资源和父资源;
最终用户定义rest方法(index,create,show,update,delete,new, 编辑);
默认情况下:
- HTTP 405 is returned for any method not provided;
- permissions ‘index, create, show, update, delete, new, edit’ are associated to respective method;
配置资源的3种方法:
Imperative using config.add_resource, it will associate class in views module to resource
config.add_resource('application')# .views.applications:ApplicationsViewconfig.add_resource('application.user')# .views.application_users:ApplicationUsersView
Declarative using Resource class (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):pass
Declarative using resource_config decorator
@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{}
接下来呢?
- http修补程序方法:http://tools.ietf.org/html/rfc5789
- 资源脚手架命令;
- 链接;
- 验证;
- 分页;
- sqlalchemy实体的自动资源定义;
- 在“添加资源”中有一个视图参数以覆盖视图定义;
更改日志
发展
0.2.8
- 与更新的zope.interfaces兼容
- 使用金字塔的最后一个功能
- setup.py中不再分发
0.2.5
- 将Mongo连接移动到Pyramid_Mongokit。
0.2.4
- 切换到github。
- 添加对Mongo数据库的支持:
- Setting in ini file ^{tt1}$ considered true by default
- ^{tt2}$ is registered to registry
- Two properties added to ^{tt3}$: ^{tt4}$ and ^{tt5}$
- Mongo connection gets uri from ^{tt6}$
- Database name comes from ^{tt7}$
- Any resource view with a ^{tt8}$ class attribute with value being a definition of a ^{tt9}$ can inherit ^{tt10}$ to inherit all default actions.
- 添加自定义呈现程序,根据接受头调整输出格式, 支持的格式是application/json&;application/bson
0.1.0
- 将resourceutility重命名为resourceconfigurator以使其角色更清晰。
- 强制路由模式变量和视图可调用的人类友好名称 参数,例如/applications/{application\u id}/users/{id}和 显示(上下文、请求、应用程序ID、ID)
- 删除在资源名称中配置资源分隔符的功能:它总是 '.'.
- 单数资源通过add_singular_resource指令或singular=trueresource或resource配置 上的关键字参数
- 将示例从测试目录移动到根目录:用于测试和有用 用于文档。
0.0.1
- 仅收藏资源
- 命令模式通过add_resource指令
- 通过resource类的声明模式
- 声明式模式视图resource配置