当前位置: 首页>>代码示例>>Python>>正文


Python ToolbarMiddleware.process_request方法代码示例

本文整理汇总了Python中cms.middleware.toolbar.ToolbarMiddleware.process_request方法的典型用法代码示例。如果您正苦于以下问题:Python ToolbarMiddleware.process_request方法的具体用法?Python ToolbarMiddleware.process_request怎么用?Python ToolbarMiddleware.process_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cms.middleware.toolbar.ToolbarMiddleware的用法示例。


在下文中一共展示了ToolbarMiddleware.process_request方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _prepare_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
 def _prepare_request(self, request, page, user, lang, use_middlewares, use_toolbar=False):
     request.current_page = SimpleLazyObject(lambda: page)
     if not user:
         if self._login_context:
             user = self._login_context.user
         else:
             user = AnonymousUser()
     request.user = user
     request.session = {}
     request.cookies = SimpleCookie()
     request.errors = StringIO()
     request.LANGUAGE_CODE = lang
     # Let's use middleware in case requested, otherwise just use CMS toolbar if needed
     if use_middlewares:
         handler = BaseHandler()
         handler.load_middleware()
         for middleware_method in handler._request_middleware:
             if middleware_method(request):
                 raise Exception(u'Couldn\'t create request mock object -'
                                 u'request middleware returned a response')
     elif use_toolbar:
         from cms.middleware.toolbar import ToolbarMiddleware
         mid = ToolbarMiddleware()
         mid.process_request(request)
     return request
开发者ID:cyberstar,项目名称:djangocms-helper,代码行数:27,代码来源:base_test.py

示例2: get_page_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
    def get_page_request(self, page, user, path=None, edit=False, lang='en'):
        """
        Createds a GET request for the given page suitable for use the
        django CMS toolbar

        :param page: current page object
        :param user: current user
        :param path: path (if different from the current page path)
        :param edit: editing mode
        :param lang: request language
        :return: request
        """
        from cms.middleware.toolbar import ToolbarMiddleware
        path = path or page and page.get_absolute_url()
        if edit:
            path += '?edit'
        request = RequestFactory().get(path)
        request.session = {}
        request.user = user
        request.LANGUAGE_CODE = lang
        if edit:
            request.GET = {'edit': None}
        else:
            request.GET = {'edit_off': None}
        request.current_page = page
        mid = ToolbarMiddleware()
        mid.process_request(request)
        return request
开发者ID:thoreg,项目名称:djangocms-helper,代码行数:30,代码来源:base_test.py

示例3: test_get_page_by_pk_arg_edit_mode

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
 def test_get_page_by_pk_arg_edit_mode(self):
     control = self._getfirst()
     request = self.get_request('/')
     request.GET = {"edit": ''}
     user = self._create_user("admin", True, True)
     request.current_page = control
     request.user = user
     middleware = ToolbarMiddleware()
     middleware.process_request(request)
     page = _get_page_by_untyped_arg(control.pk, request, 1)
     self.assertEqual(page, control.publisher_draft)
开发者ID:1oscar,项目名称:django-cms,代码行数:13,代码来源:templatetags.py

示例4: test_get_page_by_pk_arg_edit_mode

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
 def test_get_page_by_pk_arg_edit_mode(self):
     control = self._getfirst()
     request = self.get_request('/')
     request.GET = {"edit": ''}
     user = User(username="admin", password="admin", is_superuser=True, is_staff=True, is_active=True)
     user.save()
     request.current_page = control
     request.user = user
     middleware = ToolbarMiddleware()
     middleware.process_request(request)
     page = _get_page_by_untyped_arg(control.pk, request, 1)
     self.assertEqual(page, control.publisher_draft)
开发者ID:conrado,项目名称:django-cms,代码行数:14,代码来源:templatetags.py

示例5: get_page_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
 def get_page_request(self, page, user, path=None, edit=False, lang_code="en"):
     path = path or page and page.get_absolute_url()
     if edit:
         path += "?edit"
     request = RequestFactory().get(path)
     request.session = {}
     request.user = user
     request.LANGUAGE_CODE = lang_code
     if edit:
         request.GET = {"edit": None}
     else:
         request.GET = {"edit_off": None}
     request.current_page = page
     mid = ToolbarMiddleware()
     mid.process_request(request)
     return request
开发者ID:conrado,项目名称:django-cms,代码行数:18,代码来源:toolbar.py

示例6: get_page_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
def get_page_request(page, user=None, path=None, edit=False, language='en'):
    path = path or page and page.get_absolute_url()
    if edit:
        path += '?edit'
    request = RequestFactory().get(path)
    request.session = {}
    request.user = user or AnonymousUser()
    request.LANGUAGE_CODE = language
    if edit:
        request.GET = {'edit': None}
    else:
        request.GET = {'edit_off': None}
    request.current_page = page
    mid = ToolbarMiddleware()
    mid.process_request(request)
    return request
开发者ID:victorevector,项目名称:aldryn-events,代码行数:18,代码来源:base.py

示例7: get_page_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
 def get_page_request(self, page, user, path=None, edit=False, lang_code='en'):
     from cms.middleware.toolbar import ToolbarMiddleware
     path = path or page and page.get_absolute_url(lang_code)
     if edit:
         path += '?edit'
     request = RequestFactory().get(path)
     request.session = {}
     request.user = user
     request.LANGUAGE_CODE = lang_code
     if edit:
         request.GET = {'edit': None}
     else:
         request.GET = {'edit_off': None}
     request.current_page = page
     mid = ToolbarMiddleware()
     mid.process_request(request)
     return request
开发者ID:CptLemming,项目名称:djangocms-page-meta,代码行数:19,代码来源:__init__.py

示例8: get_page_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
 def get_page_request(self, page, user, path=None, edit=False, lang_code='en', disable=False):
     path = path or page and page.get_absolute_url()
     if edit:
         path += '?%s' % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON')
     request = RequestFactory().get(path)
     request.session = {}
     request.user = user
     request.LANGUAGE_CODE = lang_code
     if edit:
         request.GET = {'edit': None}
     else:
         request.GET = {'edit_off': None}
     if disable:
         request.GET[get_cms_setting('CMS_TOOLBAR_URL__DISABLE')] = None
     request.current_page = page
     mid = ToolbarMiddleware()
     mid.process_request(request)
     if hasattr(request, 'toolbar'):
         request.toolbar.populate()
     return request
开发者ID:AaronJaramillo,项目名称:shopDPM,代码行数:22,代码来源:test_no_i18n.py

示例9: _prepare_request

# 需要导入模块: from cms.middleware.toolbar import ToolbarMiddleware [as 别名]
# 或者: from cms.middleware.toolbar.ToolbarMiddleware import process_request [as 别名]
    def _prepare_request(self, request, page, user, lang, use_middlewares, use_toolbar=False,
                         secure=False):
        from django.contrib.auth.models import AnonymousUser
        from importlib import import_module

        engine = import_module(settings.SESSION_ENGINE)

        request.current_page = SimpleLazyObject(lambda: page)
        if not user:
            if self._login_context:
                user = self._login_context.user
            else:
                user = AnonymousUser()
        if callable(user.is_authenticated):
            authenticated = user.is_authenticated()
        else:
            authenticated = user.is_authenticated
        if authenticated:
            session_key = user._meta.pk.value_to_string(user)
        else:
            session_key = 'session_key'

        request.user = user
        request._cached_user = user
        request.session = engine.SessionStore(session_key)
        if secure:
            request.environ['SERVER_PORT'] = str('443')
            request.environ['wsgi.url_scheme'] = str('https')
        request.cookies = SimpleCookie()
        request.errors = StringIO()
        request.LANGUAGE_CODE = lang
        if request.method == 'POST':
            request._dont_enforce_csrf_checks = True
        # Let's use middleware in case requested, otherwise just use CMS toolbar if needed
        if use_middlewares:
            self._apply_middlewares(request)
        elif use_toolbar:
            from cms.middleware.toolbar import ToolbarMiddleware
            mid = ToolbarMiddleware()
            mid.process_request(request)
        return request
开发者ID:nephila,项目名称:djangocms-helper,代码行数:43,代码来源:base_test.py


注:本文中的cms.middleware.toolbar.ToolbarMiddleware.process_request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。