本文整理汇总了Python中feincms.module.page.models.Page.register_request_processor方法的典型用法代码示例。如果您正苦于以下问题:Python Page.register_request_processor方法的具体用法?Python Page.register_request_processor怎么用?Python Page.register_request_processor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feincms.module.page.models.Page
的用法示例。
在下文中一共展示了Page.register_request_processor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: require_login_processor
# 需要导入模块: from feincms.module.page.models import Page [as 别名]
# 或者: from feincms.module.page.models.Page import register_request_processor [as 别名]
from django.utils.translation import ugettext_lazy as _
import logging
from feincms.module.page.models import Page
from django.contrib.auth import REDIRECT_FIELD_NAME
def require_login_processor(page, request):
if ((page.require_permission and not request.user.has_perm("page.can_view",
page))
or (page.require_login and not request.user.is_authenticated())):
return HttpResponseRedirect("%s?%s=%s" % (settings.LOGIN_URL,
REDIRECT_FIELD_NAME, urlquote(request.get_full_path())))
else:
return None
Page.register_request_processor(require_login_processor)
CONTENT_TYPES = ('text/html','application/xhtml+xml','application/xml')
HEADER_VALUE = getattr(settings, 'X_UA_COMPATIBLE', 'IE=edge,chrome=1')
def set_XUACompatible_processor(page, request, response):
response_ct = response.get('Content-Type','').split(';', 1)[0].lower()
if response_ct in CONTENT_TYPES:
if not 'X-UA-Compatible' in response:
response['X-UA-Compatible'] = HEADER_VALUE
return response
Page.register_response_processor(set_XUACompatible_processor)
from feincms.views.cbv.views import Handler
class GenericFeinView(Handler):
示例2: BlogTestCase
# 需要导入模块: from feincms.module.page.models import Page [as 别名]
# 或者: from feincms.module.page.models.Page import register_request_processor [as 别名]
('region2', 'region2 title'))
Page.register_extensions(
'feincms.module.extensions.datepublisher',
'feincms.module.extensions.translations',
'feincms.module.extensions.ct_tracker',
'feincms.module.extensions.seo',
'feincms.module.extensions.changedate',
'feincms.module.extensions.seo', # duplicate
'feincms.module.page.extensions.navigation',
'feincms.module.page.extensions.symlinks',
'feincms.module.page.extensions.titles',
)
Page.create_content_type(ContactFormContent, form=ContactForm)
Page.create_content_type(FileContent)
Page.register_request_processor(processors.etag_request_processor)
Page.register_response_processor(processors.etag_response_processor)
Page.register_response_processor(processors.debug_sql_queries_response_processor())
class BlogTestCase(TestCase):
def setUp(self):
u = User(username='test', is_active=True, is_staff=True, is_superuser=True)
u.set_password('test')
u.save()
Entry.register_regions(('main', 'Main region'), ('another', 'Another region'))
def login(self):
self.assertTrue(self.client.login(username='test', password='test'))
示例3:
# 需要导入模块: from feincms.module.page.models import Page [as 别名]
# 或者: from feincms.module.page.models.Page import register_request_processor [as 别名]
# -- conding: utf-8 --
from django.utils.translation import ugettext_lazy as _
from feincms.module.page.models import Page
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.v2 import MediaFileContent
from feincms.content.application.models import ApplicationContent
from account.extensions.permission import authenticated_request_processor
from todomvc.admin import application_admin_fields as todo_application_admin_fields
from todomvc.models import TodoContent
Page.register_request_processor(authenticated_request_processor)
Page.register_extensions('datepublisher', 'changedate', 'seo', 'account.extensions.permission')
Page.register_templates({
'title': _('Standard template'),
'path': 'pera/feincms_templates/default.html',
'regions': (
('main', _('Main content area')),
('sidebar', _('Sidebar'), 'inherited'),
),
})
Page.create_content_type(TodoContent, TYPE_CHOICES=(
('backbone', _('Backbone')),
))
Page.create_content_type(RichTextContent)
Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
('default', _('default')),