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


Python session_csrf.monkeypatch函数代码示例

本文整理汇总了Python中session_csrf.monkeypatch函数的典型用法代码示例。如果您正苦于以下问题:Python monkeypatch函数的具体用法?Python monkeypatch怎么用?Python monkeypatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ready

    def ready(self):
        # Monkeypatch session_csrf
        import session_csrf
        session_csrf.monkeypatch()
        # Set our admin site as admin.site
        django_admin.site = django_admin_sites.site = admin_site
        # Monkeypath hglib.client.pathto
        # Working around the lack of
        # https://bz.mercurial-scm.org/show_bug.cgi?id=4510
        from hglib.client import hgclient
        if not hasattr(hgclient, 'pathto'):
            import os
            from hglib.util import b

            def pathto(self, f, cwd='.'):
                """
                Return relative path to f. If cwd is given, use it as current
                working directory.
                The returned path uses os.sep as separator.

                f - file path with / as separator
                cwd - working directory with os.sep as separator
                """
                return b(
                    os.path.relpath(
                        os.path.join(
                            self.root().decode('latin-1'), *(f.split('/'))
                        ),
                        start=cwd
                    )
                )
            hgclient.pathto = pathto
开发者ID:Pike,项目名称:elmo,代码行数:32,代码来源:apps.py

示例2: monkeypatch

def monkeypatch():
    """All the monkeypatching we have to do to get things running"""
    global _has_patched
    if _has_patched:
        return

    # Import for side-effect: configures logging handlers
    from fjord.settings.log_settings import noop

    noop()

    # Monkey-patch admin site
    from django.contrib import admin
    from django.contrib.auth.decorators import login_required
    from session_csrf import anonymous_csrf
    from adminplus.sites import AdminSitePlus

    # Patch the admin
    admin.site = AdminSitePlus()
    admin.site.login = login_required(anonymous_csrf(admin.site.login))

    # Monkey-patch Django's csrf_protect decorator to use
    # session-based CSRF tokens
    import session_csrf

    session_csrf.monkeypatch()

    logging.debug("Note: monkeypatches executed in %s" % __file__)

    # Prevent it from being run again later
    _has_patched = True
开发者ID:Givemore,项目名称:fjord,代码行数:31,代码来源:manage_utils.py

示例3: patch

def patch():
    global _has_patched
    if _has_patched:
        return

    # Import for side-effect: configures logging handlers.
    # pylint: disable-msg=W0611
    import log_settings

    # Monkey-patch django forms to avoid having to use Jinja2's |safe
    # everywhere.
    import safe_django_forms
    safe_django_forms.monkeypatch()

    # Monkey-patch Django's csrf_protect decorator to use session-based CSRF
    # tokens:
    if 'session_csrf' in settings.INSTALLED_APPS:
        import session_csrf
        session_csrf.monkeypatch()
        from . import admin
        admin.monkeypatch()

    if 'compressor' in settings.INSTALLED_APPS:
        import jingo
        from compressor.contrib.jinja2ext import CompressorExtension
        jingo.env.add_extension(CompressorExtension)

    logging.debug("Note: funfactory monkey patches executed in %s" % __file__)

    # prevent it from being run again later
    _has_patched = True
开发者ID:church29,项目名称:cyder,代码行数:31,代码来源:monkeypatches.py

示例4: patch

def patch():
    import jingo.monkey
    jingo.monkey.patch()

    import session_csrf
    session_csrf.monkeypatch()

    import jingo
    from compressor.contrib.jinja2ext import CompressorExtension
    jingo.env.add_extension(CompressorExtension)
开发者ID:jlin,项目名称:airmozilla,代码行数:10,代码来源:monkeypatches.py

示例5: ready

    def ready(self):
        # The app is now ready. Include any monkey patches here.

        # Monkey patch CSRF to switch to session based CSRF. Session
        # based CSRF will prevent attacks from apps under the same
        # domain. If you're planning to host your app under it's own
        # domain you can remove session_csrf and use Django's CSRF
        # library. See also
        # https://github.com/mozilla/sugardough/issues/38
        session_csrf.monkeypatch()
开发者ID:mozilla,项目名称:medlem,代码行数:10,代码来源:app.py

示例6: monkeypatch

    def monkeypatch(self):
        # Only patch once, ever.
        if BaseConfig._has_patched:
            return

        # Monkey-patch Django's csrf_protect decorator to use
        # session-based CSRF tokens:
        session_csrf.monkeypatch()
        admin.site = SessionCsrfAdminSite()

        BaseConfig._has_patched = True
开发者ID:rajul,项目名称:pontoon,代码行数:11,代码来源:apps.py

示例7: ready

    def ready(self):
        super(CoreConfig, self).ready()

        # Ignore Python warnings unless we're running in debug mode.
        if not settings.DEBUG:
            warnings.simplefilter('ignore')

        session_csrf.monkeypatch()

        self.configure_logging()
        self.load_product_details()
        self.set_recursion_limit()
        self.enable_urllib_certificate_checking()
开发者ID:piyushmittal25,项目名称:addons-server,代码行数:13,代码来源:apps.py

示例8: patch

def patch():
    global _has_patched
    if _has_patched:
        return

    # Monkey-patch Django's csrf_protect decorator to use session-based CSRF
    # tokens:
    if 'session_csrf' in settings.INSTALLED_APPS:
        import session_csrf
        session_csrf.monkeypatch()

    logging.debug("Note: funfactory monkey patches executed in %s" % __file__)

    # prevent it from being run again later
    _has_patched = True
开发者ID:akatsoulas,项目名称:mozillians,代码行数:15,代码来源:monkeypatches.py

示例9: ready

    def ready(self):
        super(CoreConfig, self).ready()

        # Ignore Python warnings unless we're running in debug mode.
        if not settings.DEBUG:
            warnings.simplefilter('ignore')

        jingo.monkey.patch()

        jingo_env = jingo.get_env()
        jingo_env.install_gettext_translations(translation, newstyle=True)

        session_csrf.monkeypatch()

        self.configure_logging()
        self.load_product_details()
开发者ID:darktrojan,项目名称:addons-server,代码行数:16,代码来源:apps.py

示例10: patch

def patch():
    # Import for side-effect: configures logging handlers.
    # pylint: disable-msg=W0611
    import log_settings

    # Monkey-patch django forms to avoid having to use Jinja2's |safe
    # everywhere.
    import safe_django_forms
    safe_django_forms.monkeypatch()

    # Monkey-patch Django's csrf_protect decorator to use session-based CSRF
    # tokens:
    if 'session_csrf' in settings.INSTALLED_APPS:
        import session_csrf
        session_csrf.monkeypatch()

    logging.debug("Note: funfactory monkey patches executed in %s" % __file__)
开发者ID:gregglind,项目名称:funfactory,代码行数:17,代码来源:monkeypatches.py

示例11: patch

def patch():
    global _has_patched
    if _has_patched:
        return

    # Import for side-effect: configures logging handlers.
    # pylint: disable-msg=W0611
    import log_settings  # noqa

    # Monkey-patch Django's csrf_protect decorator to use session-based CSRF
    # tokens:
    if 'session_csrf' in settings.INSTALLED_APPS:
        import session_csrf
        session_csrf.monkeypatch()

    logging.debug("Note: funfactory monkey patches executed in %s" % __file__)

    # prevent it from being run again later
    _has_patched = True
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:19,代码来源:monkeypatches.py

示例12: patch

def patch():
    global _has_patched
    if _has_patched:
        return

    # # Monkey-patch django forms to avoid having to use Jinja2's |safe
    # # everywhere.
    import jingo.monkey
    jingo.monkey.patch()

    # Monkey-patch Django's csrf_protect decorator to use session-based CSRF
    # tokens:
    import session_csrf
    session_csrf.monkeypatch()

    logging.debug("Note: monkey patches executed in %s" % __file__)

    # Prevent it from being run again later.
    _has_patched = True
开发者ID:adini121,项目名称:oneanddone,代码行数:19,代码来源:monkeypatches.py

示例13: patch

def patch():
    global _has_patched
    if _has_patched:
        return

    # Import for side-effect: configures logging handlers.
    from fjord.settings.log_settings import noop
    noop()

    # Monkey-patch admin site.
    from django.contrib import admin
    from django.contrib.auth.decorators import login_required
    from session_csrf import anonymous_csrf
    from adminplus.sites import AdminSitePlus

    # Patch the admin
    admin.site = AdminSitePlus()
    admin.site.login = login_required(anonymous_csrf(admin.site.login))

    # Monkey-patch django forms to avoid having to use Jinja2's |safe
    # everywhere.
    import jingo.monkey
    jingo.monkey.patch()

    # Monkey-patch Django's csrf_protect decorator to use
    # session-based CSRF tokens.
    import session_csrf
    session_csrf.monkeypatch()

    from jingo import load_helpers
    load_helpers()

    logging.debug("Note: monkey patches executed in %s" % __file__)

    # Prevent it from being run again later.
    _has_patched = True
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:36,代码来源:monkeypatches.py

示例14: ready

 def ready(self):
     ## Monkeypatch session_csrf
     import session_csrf
     session_csrf.monkeypatch()
     from funfactory import admin
     admin.monkeypatch()
开发者ID:flodolo,项目名称:elmo,代码行数:6,代码来源:apps.py

示例15: init_session_csrf

def init_session_csrf():
    """Load the `session_csrf` module and enable its monkey patches to
    Django's CSRF middleware."""
    import session_csrf
    session_csrf.monkeypatch()
开发者ID:Mritrocker96,项目名称:addons-server,代码行数:5,代码来源:startup.py


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