本文整理汇总了Python中feincms.module.page.models.Page.register_response_processors方法的典型用法代码示例。如果您正苦于以下问题:Python Page.register_response_processors方法的具体用法?Python Page.register_response_processors怎么用?Python Page.register_response_processors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feincms.module.page.models.Page
的用法示例。
在下文中一共展示了Page.register_response_processors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticated_request_processor
# 需要导入模块: from feincms.module.page.models import Page [as 别名]
# 或者: from feincms.module.page.models.Page import register_response_processors [as 别名]
Page.create_content_type(ApplicationContent, APPLICATIONS=(
('content.news_urls', 'News Articles', {'admin_fields': get_admin_fields}),
('content.blog_urls', 'Blogs and Opinions', {'admin_fields': get_admin_fields}),
))
Page.create_content_type(CommentsContent)
''' # Using page request processors
def authenticated_request_processor(page, request):
if not request.user.is_authenticated():
return HttpResponseForbidden()
Page.register_request_processors(authenticated_request_processor)
'''
''' # using page response processors
def set_random_header_response_processor(page, request, response):
response['X-Random-Number'] = 42
Page.register_response_processors(set_random_header_response_processor)
'''
'''
# Very stupid etag function, a page is supposed the unchanged as long
# as its id and slug do not change. You definitely want something more
# involved, like including last change dates or whatever.
def my_etag(page, request):
return 'PAGE-%d-%s' % ( page.id, page.slug )
Page.etag = my_etag
Page.register_request_processors(Page.etag_request_processor)