跳转到主要内容

pyramid的注解视图映射器

项目描述

rebecca.annotationmapper是pyramid Web应用的视图映射器。它处理视图参数的注解。

安装

$ pip install rebecca.annotationmapper

用法

rebecca.annotationmapper提供了包含功能。

config.include('rebecca.annotationmapper')

使用rebecca.annotationmapper.annotations注解参数

def hello(context, request, nane: FromMatchDict):
    request.response.text = "Hello, {name}".format(name=name)
    return request.response

config.add_route("hello", "/hello/{name}")
config.add_view(hello, route_name="hello")

FromMatchDict注解的参数名称由rebecca.annotationmapper.AnnotationViewMapperrequest.matchdict['name']提供值。

例如,您访问‘https:///hello/aodag’,然后您会收到消息‘Hello, aodag’。

注解

FromMatchDict

提供request.matchdict的值。

FromParam

提供request.params的值。

FromSession

提供request.session的值。

FromHeader

提供request.headers的值。

FromAttr

提供request属性的值。

变更

0.1

  • 第一个版本

由以下组织支持