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


Python webapp2.RedirectHandler方法代码示例

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


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

示例1: _VerifyInheritance

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def _VerifyInheritance(self, routes_list, base_class):
    """Checks that the handlers of the given routes inherit from base_class."""
    router = webapp2.Router(routes_list)
    routes = router.match_routes + router.build_routes.values()
    inheritance_errors = ''
    for route in routes:
      if issubclass(route.__class__, webapp2_extras.routes.MultiRoute):
        self._VerifyInheritance(list(route.get_routes()), base_class)
        continue

      if issubclass(route.handler, webapp2.RedirectHandler):
        continue

      if not issubclass(route.handler, base_class):
        inheritance_errors += '* %s does not inherit from %s.\n' % (
            route.handler.__name__, base_class.__name__)

    return inheritance_errors 
开发者ID:google,项目名称:gae-secure-scaffold-python,代码行数:20,代码来源:main_test.py

示例2: testStrictHandlerMethodRouting

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def testStrictHandlerMethodRouting(self):
    """Checks that handler functions properly limit applicable HTTP methods."""
    router = webapp2.Router(main._USER_ROUTES + main._AJAX_ROUTES +
                            main._ADMIN_ROUTES + main._ADMIN_AJAX_ROUTES)
    routes = router.match_routes + router.build_routes.values()
    failed_routes = []
    while routes:
      route = routes.pop()
      if issubclass(route.__class__, webapp2_extras.routes.MultiRoute):
        routes += list(route.get_routes())
        continue

      if issubclass(route.handler, webapp2.RedirectHandler):
        continue

      if route.handler_method and not route.methods:
        failed_routes.append('%s (%s)' % (route.template,
                                          route.handler.__name__))

    if failed_routes:
      self.fail('Some handlers specify a handler_method but are missing a '
                'methods" attribute and may be vulnerable to XSRF via GET '
                'requests:\n * ' + '\n * '.join(failed_routes)) 
开发者ID:google,项目名称:gae-secure-scaffold-python,代码行数:25,代码来源:main_test.py

示例3: __init__

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def __init__(self, dispatch, configuration):
    """Initializer for AdminApplication.

    Args:
      dispatch: A dispatcher.Dispatcher instance used to route requests and
          provide state about running servers.
      configuration: An application_configuration.ApplicationConfiguration
          instance containing the configuration for the application.
    """
    super(AdminApplication, self).__init__(
        [('/datastore', datastore_viewer.DatastoreRequestHandler),
         ('/datastore/edit/(.*)', datastore_viewer.DatastoreEditRequestHandler),
         ('/datastore/edit', datastore_viewer.DatastoreEditRequestHandler),
         ('/datastore-indexes',
          datastore_indexes_viewer.DatastoreIndexesViewer),
         ('/datastore-stats', datastore_stats_handler.DatastoreStatsHandler),
         ('/console', console.ConsoleRequestHandler),
         ('/console/restart/(.+)', console.ConsoleRequestHandler.restart),
         ('/memcache', memcache_viewer.MemcacheViewerRequestHandler),
         ('/blobstore', blobstore_viewer.BlobstoreRequestHandler),
         ('/blobstore/blob/(.+)', blobstore_viewer.BlobRequestHandler),
         ('/taskqueue', taskqueue_queues_handler.TaskQueueQueuesHandler),
         ('/taskqueue/queue/(.+)',
          taskqueue_tasks_handler.TaskQueueTasksHandler),
         ('/cron', cron_handler.CronHandler),
         ('/xmpp', xmpp_request_handler.XmppRequestHandler),
         ('/mail', mail_request_handler.MailRequestHandler),
         ('/quit', quit_handler.QuitHandler),
         ('/search', search_handler.SearchIndexesListHandler),
         ('/search/document', search_handler.SearchDocumentHandler),
         ('/search/index', search_handler.SearchIndexHandler),
         ('/assets/(.+)', static_file_handler.StaticFileHandler),
         ('/instances', servers_handler.ServersHandler),
         webapp2.Route('/',
                       webapp2.RedirectHandler,
                       defaults={'_uri': '/instances'})],
        debug=True)
    self.dispatcher = dispatch
    self.configuration = configuration 
开发者ID:elsigh,项目名称:browserscope,代码行数:41,代码来源:admin_server.py

示例4: _get_redirect_route

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def _get_redirect_route(self, template=None, name=None):
        template = template or self.template
        name = name or self.name
        defaults = self.defaults.copy()
        defaults.update({
            '_uri': self._redirect,
            '_name': name,
        })
        new_route = webapp2.Route(template, webapp2.RedirectHandler,
                                  defaults=defaults)
        return new_route 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:13,代码来源:routes.py

示例5: __init__

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def __init__(self):
        """Define routes to handlers."""
        super(DnsSyncApplication, self).__init__([
            ('/push_notification', ComputeEngineActivityPush),
            ('/start_audit_log_loop', audit_log.StartAuditLogLoop),
            ('/logout', auth.Logout),
            ('/auth', auth.Oauth2Callback),
            ('/stop_audit_log_loop', audit_log.StopAuditLogLoop),
            ('/get_zone_config', zones.GetZoneConfig),
            ('/get_projects', zones.GetProjects),
            ('/get_project_zones', zones.GetProjectZones),
            ('/set_zone_config', zones.SetZoneConfig),
            ('/get_audit_log_state', audit_log.GetAuditLogState),
            ('/static/(.+)', AdminStaticFileHandler),
            ('/sync_projects', SyncProjectsWithDns),
            webapp2.Route(
                '/',
                webapp2.RedirectHandler,
                defaults={'_uri': '/static/index.html'}),
            webapp2.Route(
                '/index.html',
                webapp2.RedirectHandler,
                defaults={'_uri': '/static/index.html'}),
            webapp2.Route(
                '/favicon.ico',
                webapp2.RedirectHandler,
                defaults={'_uri': '/static/images/favicon.ico'}),
        ]) 
开发者ID:GoogleCloudPlatform,项目名称:professional-services,代码行数:30,代码来源:main.py

示例6: __init__

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def __init__(self, dispatch, configuration):
    """Initializer for AdminApplication.

    Args:
      dispatch: A dispatcher.Dispatcher instance used to route requests and
          provide state about running servers.
      configuration: An application_configuration.ApplicationConfiguration
          instance containing the configuration for the application.
    """
    super(AdminApplication, self).__init__(
        [('/datastore', datastore_viewer.DatastoreRequestHandler),
         ('/datastore/edit/(.*)', datastore_viewer.DatastoreEditRequestHandler),
         ('/datastore/edit', datastore_viewer.DatastoreEditRequestHandler),
         ('/datastore-indexes',
          datastore_indexes_viewer.DatastoreIndexesViewer),
         ('/datastore-stats', datastore_stats_handler.DatastoreStatsHandler),
         ('/console', console.ConsoleRequestHandler),
         ('/console/restart/(.+)', console.ConsoleRequestHandler.restart),
         ('/memcache', memcache_viewer.MemcacheViewerRequestHandler),
         ('/blobstore', blobstore_viewer.BlobstoreRequestHandler),
         ('/blobstore/blob/(.+)', blobstore_viewer.BlobRequestHandler),
         ('/taskqueue', taskqueue_queues_handler.TaskQueueQueuesHandler),
         ('/taskqueue/queue/(.+)',
          taskqueue_tasks_handler.TaskQueueTasksHandler),
         ('/cron', cron_handler.CronHandler),
         ('/xmpp', xmpp_request_handler.XmppRequestHandler),
         ('/mail', mail_request_handler.MailRequestHandler),
         ('/quit', quit_handler.QuitHandler),
         ('/search', search_handler.SearchIndexesListHandler),
         ('/search/document', search_handler.SearchDocumentHandler),
         ('/search/index', search_handler.SearchIndexHandler),
         ('/assets/(.+)', static_file_handler.StaticFileHandler),
         ('/instances', modules_handler.ModulesHandler),
         webapp2.Route('/',
                       webapp2.RedirectHandler,
                       defaults={'_uri': '/instances'})],
        debug=True)
    self.dispatcher = dispatch
    self.configuration = configuration 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:41,代码来源:admin_server.py

示例7: __init__

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import RedirectHandler [as 别名]
def __init__(self, template, handler=None, name=None, defaults=None,
                 build_only=False, handler_method=None, methods=None,
                 schemes=None, redirect_to=None, redirect_to_name=None,
                 strict_slash=False):
        """Initializes a URL route. Extra arguments compared to
        :meth:`webapp2.Route.__init__`:

        :param redirect_to:
            A URL string or a callable that returns a URL. If set, this route
            is used to redirect to it. The callable is called passing
            ``(handler, *args, **kwargs)`` as arguments. This is a
            convenience to use :class:`RedirectHandler`. These two are
            equivalent::

                route = Route('/foo', handler=webapp2.RedirectHandler,
                              defaults={'_uri': '/bar'})
                route = Route('/foo', redirect_to='/bar')

        :param redirect_to_name:
            Same as `redirect_to`, but the value is the name of a route to
            redirect to. In the example below, accessing '/hello-again' will
            redirect to the route named 'hello'::

                route = Route('/hello', handler=HelloHandler, name='hello')
                route = Route('/hello-again', redirect_to_name='hello')

        :param strict_slash:
            If True, redirects access to the same URL with different trailing
            slash to the strict path defined in the route. For example, take
            these routes::

                route = Route('/foo', FooHandler, strict_slash=True)
                route = Route('/bar/', BarHandler, strict_slash=True)

            Because **strict_slash** is True, this is what will happen:

            - Access to ``/foo`` will execute ``FooHandler`` normally.
            - Access to ``/bar/`` will execute ``BarHandler`` normally.
            - Access to ``/foo/`` will redirect to ``/foo``.
            - Access to ``/bar`` will redirect to ``/bar/``.
        """
        super(RedirectRoute, self).__init__(
            template, handler=handler, name=name, defaults=defaults,
            build_only=build_only, handler_method=handler_method,
            methods=methods, schemes=schemes)

        if strict_slash and not name:
            raise ValueError('Routes with strict_slash must have a name.')

        self.strict_slash = strict_slash
        self.redirect_to_name = redirect_to_name

        if redirect_to is not None:
            assert redirect_to_name is None
            self.handler = webapp2.RedirectHandler
            self.defaults['_uri'] = redirect_to 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:58,代码来源:routes.py


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