Exemple #1
0
    def __init__(self):
        mapper = routes.Mapper()
        super(ManagementApplication, self).__init__(mapper)

        mapper.connect(
            "create_backup",
            "/{project_id}/{table_name}/backups",
            conditions={'method': 'POST'},
            controller=create_resource(
                create_backup.CreateBackupController()),
            action="process_request"
        )

        mapper.connect(
            "list_backups",
            "/{project_id}/{table_name}/backups",
            conditions={'method': 'GET'},
            controller=create_resource(
                list_backups.ListBackupsController()),
            action="process_request"
        )

        mapper.connect(
            "describe_backup",
            "/{project_id}/{table_name}/backups/{backup_id}",
            conditions={'method': 'GET'},
            controller=create_resource(
                describe_backup.DescribeBackupController()),
            action="process_request"
        )

        mapper.connect(
            "delete_backup",
            "/{project_id}/{table_name}/backups/{backup_id}",
            conditions={'method': 'DELETE'},
            controller=create_resource(
                delete_backup.DeleteBackupController()),
            action="process_request"
        )

        mapper.connect(
            "create_restore_job",
            "/{project_id}/{table_name}/restores",
            conditions={'method': 'POST'},
            controller=create_resource(
                create_restore_job.CreateRestoreJobController()),
            action="process_request"
        )

        mapper.connect(
            "list_restore_jobs",
            "/{project_id}/{table_name}/restores",
            conditions={'method': 'GET'},
            controller=create_resource(
                list_restore_jobs.ListRestoreJobsController()),
            action="process_request"
        )

        mapper.connect(
            "describe_restore_job",
            "/{project_id}/{table_name}/restores/{restore_job_id}",
            conditions={'method': 'GET'},
            controller=create_resource(
                describe_restore_job.DescribeRestoreJobController()),
            action="process_request"
        )
Exemple #2
0
 def __init__(self, controller, mapper=None):
     if not mapper:
         mapper = routes.Mapper()
     mapper.resource("test", "tests",
                     controller=os_wsgi.Resource(controller))
     super(TestRouter, self).__init__(mapper)
Exemple #3
0
 def setUp(self):
     super(DispatchTest, self).setUp()
     self.mapper = routes.Mapper()
     self.route_handler = mock.MagicMock()
Exemple #4
0
 def __init__(self):
     mapper = routes.Mapper()
     super(APIV10, self).__init__(mapper)
     APICommon(mapper)
     self._instance_interface_ips_mapper(mapper)
 def __init__(self):
     mapper = routes.Mapper()
     super(VnfpkgmAPIRouter, self).__init__(mapper)
Exemple #6
0
 def __init__(self, mapper=None):
     if (mapper == None):
         mapper = routes.Mapper()
     versions_resource = versions.create_resource()
     mapper.connect("/", controller=versions_resource, action="index")
     super(API, self).__init__(mapper)
Exemple #7
0
def admin_version_app_factory(global_conf, **local_conf):
    return wsgi.ComposingRouter(routes.Mapper(),
                                [routers.Versions('admin')])
Exemple #8
0
 def factory(cls, global_conf, **local_conf):
     return cls(routes.Mapper())
Exemple #9
0
    def setUp(self):
        super(TestRegistryRPC, self).setUp()
        self.mapper = routes.Mapper()
        self.api = test_utils.FakeAuthMiddleware(rserver.API(self.mapper),
                                                 is_admin=True)

        self.FIXTURES = [{
            'id':
            UUID1,
            'name':
            'fake image #1',
            'status':
            'active',
            'disk_format':
            'ami',
            'container_format':
            'ami',
            'is_public':
            False,
            'created_at':
            timeutils.utcnow(),
            'updated_at':
            timeutils.utcnow(),
            'deleted_at':
            None,
            'deleted':
            False,
            'checksum':
            None,
            'min_disk':
            0,
            'min_ram':
            0,
            'size':
            13,
            'locations': [{
                'url': "file:///%s/%s" % (self.test_dir, UUID1),
                'metadata': {}
            }],
            'properties': {
                'type': 'kernel'
            }
        }, {
            'id':
            UUID2,
            'name':
            'fake image #2',
            'status':
            'active',
            'disk_format':
            'vhd',
            'container_format':
            'ovf',
            'is_public':
            True,
            'created_at':
            timeutils.utcnow(),
            'updated_at':
            timeutils.utcnow(),
            'deleted_at':
            None,
            'deleted':
            False,
            'checksum':
            None,
            'min_disk':
            5,
            'min_ram':
            256,
            'size':
            19,
            'locations': [{
                'url': "file:///%s/%s" % (self.test_dir, UUID2),
                'metadata': {}
            }],
            'properties': {}
        }]

        self.context = glance.context.RequestContext(is_admin=True)
        db_api.setup_db_env()
        db_api.get_engine()
        self.destroy_fixtures()
        self.create_fixtures()
Exemple #10
0
 def __init__(self):
     
     self.mapper = routes.Mapper()
     self.add_routes()
     self._router = routes.middleware.RoutesMiddleware(self._dispatch,
                                                       self.mapper)
Exemple #11
0
 def __init__(self, options={}):
     mapper = routes.Mapper()
     controller = ext_stubs.StubBaseAppController()
     mapper.resource("dummy_resource", "/dummy_resources",
                     controller=controller)
     super(ExtensionsTestApp, self).__init__(mapper)
Exemple #12
0
    def __init__(self, conf, **local_conf):
        self.conf = conf
        mapper = routes.Mapper()

        # Stacks
        stacks_resource = stacks.create_resource(conf)
        with mapper.submapper(controller=stacks_resource,
                              path_prefix="/{tenant_id}") as stack_mapper:
            # Template handling
            stack_mapper.connect("template_validate",
                                 "/validate",
                                 action="validate_template",
                                 conditions={'method': 'POST'})
            stack_mapper.connect("resource_types",
                                 "/resource_types",
                                 action="list_resource_types",
                                 conditions={'method': 'GET'})
            stack_mapper.connect("resource_schema",
                                 "/resource_types/{type_name}",
                                 action="resource_schema",
                                 conditions={'method': 'GET'})
            stack_mapper.connect("generate_template",
                                 "/resource_types/{type_name}/template",
                                 action="generate_template",
                                 conditions={'method': 'GET'})

            # Stack collection
            stack_mapper.connect("stack_index",
                                 "/stacks",
                                 action="index",
                                 conditions={'method': 'GET'})
            stack_mapper.connect("stack_create",
                                 "/stacks",
                                 action="create",
                                 conditions={'method': 'POST'})
            stack_mapper.connect("stack_detail",
                                 "/stacks/detail",
                                 action="detail",
                                 conditions={'method': 'GET'})

            # Stack data
            stack_mapper.connect("stack_lookup",
                                 "/stacks/{stack_name}",
                                 action="lookup")
            # \x3A matches on a colon.
            # Routes treats : specially in its regexp
            stack_mapper.connect("stack_lookup",
                                 r"/stacks/{stack_name:arn\x3A.*}",
                                 action="lookup")
            subpaths = ['resources', 'events', 'template', 'actions']
            path = "{path:%s}" % '|'.join(subpaths)
            stack_mapper.connect("stack_lookup_subpath",
                                 "/stacks/{stack_name}/" + path,
                                 action="lookup",
                                 conditions={'method': 'GET'})
            stack_mapper.connect("stack_lookup_subpath_post",
                                 "/stacks/{stack_name}/" + path,
                                 action="lookup",
                                 conditions={'method': 'POST'})
            stack_mapper.connect("stack_show",
                                 "/stacks/{stack_name}/{stack_id}",
                                 action="show",
                                 conditions={'method': 'GET'})
            stack_mapper.connect("stack_template",
                                 "/stacks/{stack_name}/{stack_id}/template",
                                 action="template",
                                 conditions={'method': 'GET'})

            # Stack update/delete
            stack_mapper.connect("stack_update",
                                 "/stacks/{stack_name}/{stack_id}",
                                 action="update",
                                 conditions={'method': 'PUT'})
            stack_mapper.connect("stack_delete",
                                 "/stacks/{stack_name}/{stack_id}",
                                 action="delete",
                                 conditions={'method': 'DELETE'})

            # Stack abandon
            stack_mapper.connect("stack_abandon",
                                 "/stacks/{stack_name}/{stack_id}/abandon",
                                 action="abandon",
                                 conditions={'method': 'DELETE'})

        # Resources
        resources_resource = resources.create_resource(conf)
        stack_path = "/{tenant_id}/stacks/{stack_name}/{stack_id}"
        with mapper.submapper(controller=resources_resource,
                              path_prefix=stack_path) as res_mapper:

            # Resource collection
            res_mapper.connect("resource_index",
                               "/resources",
                               action="index",
                               conditions={'method': 'GET'})

            # Resource data
            res_mapper.connect("resource_show",
                               "/resources/{resource_name}",
                               action="show",
                               conditions={'method': 'GET'})
            res_mapper.connect("resource_metadata_show",
                               "/resources/{resource_name}/metadata",
                               action="metadata",
                               conditions={'method': 'GET'})

        # Events
        events_resource = events.create_resource(conf)
        with mapper.submapper(controller=events_resource,
                              path_prefix=stack_path) as ev_mapper:

            # Stack event collection
            ev_mapper.connect("event_index_stack",
                              "/events",
                              action="index",
                              conditions={'method': 'GET'})
            # Resource event collection
            ev_mapper.connect("event_index_resource",
                              "/resources/{resource_name}/events",
                              action="index",
                              conditions={'method': 'GET'})

            # Event data
            ev_mapper.connect("event_show",
                              "/resources/{resource_name}/events/{event_id}",
                              action="show",
                              conditions={'method': 'GET'})

        # Actions
        actions_resource = actions.create_resource(conf)
        with mapper.submapper(controller=actions_resource,
                              path_prefix=stack_path) as ac_mapper:

            ac_mapper.connect("action_stack",
                              "/actions",
                              action="action",
                              conditions={'method': 'POST'})

        # Info
        info_resource = build_info.create_resource(conf)
        with mapper.submapper(controller=info_resource,
                              path_prefix="/{tenant_id}") as info_mapper:

            info_mapper.connect('build_info',
                                '/build_info',
                                action='build_info',
                                conditions={'method': 'GET'})

        super(API, self).__init__(mapper)
Exemple #13
0
    def __init__(self, mapper=None):
        if (mapper == None):
            mapper = routes.Mapper()

        mapper.connect("/", controller=api.VersionAPI(), action="index")
        super(MyApp, self).__init__(mapper)
Exemple #14
0
    def __init__(self):
        # pylint: disable=E1103,W0142
        mapper = routes.Mapper()

        url = runtime.default.server_url
        log.debug('server URL: %s', url)

        with mapper.submapper() as router_mapper:

            # configure /bootstrap
            router_mapper.connect('bootstrap',
                                  '/bootstrap',
                                  controller=BootstrapController,
                                  action='index',
                                  conditions=dict(method=['GET']))

            router_mapper.connect('bootstrap_config',
                                  '/bootstrap/config',
                                  controller=BootstrapController,
                                  action='config',
                                  conditions=dict(method=['GET']))

            # configure /meta
            router_mapper.connect('meta', '/meta/{type:actions|files|nodes}/'
                                  '{path_info:.*}',
                                  controller=MetaController,
                                  action='metadata',
                                  conditions=dict(method=['GET']))

            # configure /nodes
            router_mapper.collection('nodes',
                                     'node',
                                     controller=NodesController,
                                     collection_actions=['create'],
                                     member_actions=['show'],
                                     member_prefix='/{resource}')

            router_mapper.connect('get_node_config',
                                  '/nodes/{resource}/startup-config',
                                  controller=NodesController,
                                  action='get_config',
                                  conditions=dict(method=['GET']))

            router_mapper.connect('put_node_config',
                                  '/nodes/{resource}/startup-config',
                                  controller=NodesController,
                                  action='put_config',
                                  conditions=dict(method=['PUT']))

            # configure /actions
            router_mapper.collection('actions',
                                     'action',
                                     controller=ActionsController,
                                     collection_actions=[],
                                     member_actions=['show'],
                                     member_prefix='/{resource}')

            # configure /files
            router_mapper.collection('files',
                                     'file',
                                     controller=FilesController,
                                     collection_actions=[],
                                     member_actions=['show'],
                                     member_prefix='/{resource:.*}')

        super(Router, self).__init__(mapper)
Exemple #15
0
    def __init__(self):
        mapper = routes.Mapper()
        super(MagnetoDBApplication, self).__init__(mapper)

        mapper.connect("batch_write_item",
                       "/{project_id}/batch_write_item",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           batch_write_item.BatchWriteItemController()),
                       action="process_request")
        mapper.connect("put_item",
                       "/{project_id}/tables/{table_name}/put_item",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           put_item.PutItemController()),
                       action="process_request")
        mapper.connect("get_item",
                       "/{project_id}/tables/{table_name}/get_item",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           get_item.GetItemController()),
                       action="process_request")
        mapper.connect("delete_item",
                       "/{project_id}/tables/{table_name}/delete_item",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           delete_item.DeleteItemController()),
                       action="process_request")
        mapper.connect("update_item",
                       "/{project_id}/tables/{table_name}/update_item",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           update_item.UpdateItemController()),
                       action="process_request")
        mapper.connect("batch_get_item",
                       "/{project_id}/batch_get_item",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           batch_get_item.BatchGetItemController()),
                       action="process_request")
        mapper.connect("list_tables",
                       "/{project_id}/tables",
                       conditions={'method': 'GET'},
                       controller=create_resource(
                           list_tables.ListTablesController()),
                       action="list_tables")
        mapper.connect("create_table",
                       "/{project_id}/tables",
                       conditions={'method': 'POST'},
                       controller=create_resource(
                           create_table.CreateTableController()),
                       action="create_table")
        mapper.connect("describe_table",
                       "/{project_id}/tables/{table_name}",
                       conditions={'method': 'GET'},
                       controller=create_resource(
                           describe_table.DescribeTableController()),
                       action="describe_table")
        mapper.connect("scan",
                       "/{project_id}/tables/{table_name}/scan",
                       conditions={'method': 'POST'},
                       controller=create_resource(scan.ScanController()),
                       action="scan")
        mapper.connect("query",
                       "/{project_id}/tables/{table_name}/query",
                       conditions={'method': 'POST'},
                       controller=create_resource(query.QueryController()),
                       action="query")
        mapper.connect("delete_table",
                       "/{project_id}/tables/{table_name}",
                       conditions={'method': 'DELETE'},
                       controller=create_resource(
                           delete_table.DeleteTableController()),
                       action="delete_table")
    def __init__(self):

        self.mapper = routes.Mapper()
        self.container_controller = ContainerController()
        self.image_controller = ImageController()
        self.misc_controller = MiscController()

        #self.mapper.redirect("","/")

        self.mapper.connect(
            '/containers',
            controller=self.container_controller,
            action='index',
            conditions={'method': ['GET']},
        )
        self.mapper.connect(
            '/containers/{container_id}',
            controller=self.container_controller,
            action='delete',
            conditions={'method': ['DELETE']},
        )

        self.mapper.connect(
            '/containers/{container_id}',
            controller=self.container_controller,
            action='show',
            condition={'method': ['GET']},
        )

        self.mapper.connect(
            '/containers/{container_id}',
            controller=self.container_controller,
            action='inspect',
            conditions={'method': ['GET']},
        )

        self.mapper.connect(
            '/containers',
            controller=self.container_controller,
            action='create',
            conditions={'method': ['POST']},
        )

        self.mapper.connect(
            '/images',
            controller=self.image_controller,
            action='index',
            conditions={'method': ['GET']},
        )
        self.mapper.connect(
            '/images/{image_id}',
            controller=self.image_controller,
            action='show',
            conditions={'method': ['GET']},
        )
        self.mapper.connect(
            '/images/{image_id}/inspect',
            controller=self.image_controller,
            action='inspect',
            conditions={'method': ['GET']},
        )

        self.mapper.connect(
            '/images',
            controller=self.image_controller,
            action='create',
            conditions={'method': ['POST']},
        )

        self.mapper.connect(
            '/images/{image_id}',
            controller=self.image_controller,
            action='delete',
            conditions={'method': ['DELETE']},
        )

        self.mapper.connect(
            '/info',
            controller=self.misc_controller,
            action='info',
            condition={'method': ['GET']},
        )

        self.mapper.connect(
            '/version',
            controller=self.misc_controller,
            action='version',
            condition={'method': ['GET']},
        )
        self.mapper.connect(
            '/events',
            controller=self.misc_controller,
            action='events',
            condition={'method': ['GET']},
        )
        self.router = routes.middleware.RoutesMiddleware(
            self._dispatch, self.mapper)
Exemple #17
0
def admin_version_app_factory(global_conf, **local_conf):
    conf = global_conf.copy()
    conf.update(local_conf)
    return wsgi.ComposingRouter(routes.Mapper(), [routers.Versions('admin')])
Exemple #18
0
def public_app_factory(global_conf, **local_conf):
    return wsgi.ComposingRouter(routes.Mapper(),
                                [routers.Router()])
Exemple #19
0
    def __init__(self, conf, **local_conf):
        self.conf = conf
        mapper = routes.Mapper()

        # version
        res = wsgi.Resource(version.VersionController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("version",
                               "/",
                               action="version",
                               conditions={'method': 'GET'})

        # Profile_types
        res = wsgi.Resource(profile_types.ProfileTypeController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("profile_type_index",
                               "/profile-types",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("profile_type_get",
                               "/profile-types/{type_name}",
                               action="get",
                               conditions={'method': 'GET'})
            sub_mapper.connect("profile_type_ops",
                               "/profile-types/{type_name}/ops",
                               action="ops",
                               conditions={'method': 'GET'})

        # Profiles
        res = wsgi.Resource(profiles.ProfileController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("profile_index",
                               "/profiles",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("profile_create",
                               "/profiles",
                               action="create",
                               conditions={'method': 'POST'},
                               success=201)
            sub_mapper.connect("profile_get",
                               "/profiles/{profile_id}",
                               action="get",
                               conditions={'method': 'GET'})
            sub_mapper.connect("profile_update",
                               "/profiles/{profile_id}",
                               action="update",
                               conditions={'method': 'PATCH'})
            sub_mapper.connect("profile_delete",
                               "/profiles/{profile_id}",
                               action="delete",
                               conditions={'method': 'DELETE'})
            sub_mapper.connect("profile_validate",
                               "/profiles/validate",
                               action="validate",
                               conditions={'method': 'POST'})

        # Policy Types
        res = wsgi.Resource(policy_types.PolicyTypeController(conf))
        with mapper.submapper(controller=res) as sub_mapper:
            # Policy collection
            sub_mapper.connect("policy_type_index",
                               "/policy-types",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("policy_type_get",
                               "/policy-types/{type_name}",
                               action="get",
                               conditions={'method': 'GET'})

        # Policies
        res = wsgi.Resource(policies.PolicyController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("policy_index",
                               "/policies",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("policy_create",
                               "/policies",
                               action="create",
                               conditions={'method': 'POST'},
                               success=201)
            sub_mapper.connect("policy_get",
                               "/policies/{policy_id}",
                               action="get",
                               conditions={'method': 'GET'})
            sub_mapper.connect("policy_update",
                               "/policies/{policy_id}",
                               action="update",
                               conditions={'method': 'PATCH'})
            sub_mapper.connect("policy_delete",
                               "/policies/{policy_id}",
                               action="delete",
                               conditions={'method': 'DELETE'})
            sub_mapper.connect("policy_validate",
                               "/policies/validate",
                               action="validate",
                               conditions={'method': 'POST'})

        # Clusters
        res = wsgi.Resource(clusters.ClusterController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("cluster_index",
                               "/clusters",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("cluster_create",
                               "/clusters",
                               action="create",
                               conditions={'method': 'POST'},
                               success=202)
            sub_mapper.connect("cluster_get",
                               "/clusters/{cluster_id}",
                               action="get",
                               conditions={'method': 'GET'})
            sub_mapper.connect("cluster_update",
                               "/clusters/{cluster_id}",
                               action="update",
                               conditions={'method': 'PATCH'},
                               success=202)
            sub_mapper.connect("cluster_action",
                               "/clusters/{cluster_id}/actions",
                               action="action",
                               conditions={'method': 'POST'},
                               success=202)
            sub_mapper.connect("cluster_collect",
                               "/clusters/{cluster_id}/attrs/{path}",
                               action="collect",
                               conditions={'method': 'GET'})
            sub_mapper.connect("cluster_delete",
                               "/clusters/{cluster_id}",
                               action="delete",
                               conditions={'method': 'DELETE'},
                               success=202)
            sub_mapper.connect("cluster_operation",
                               "/clusters/{cluster_id}/ops",
                               action="operation",
                               conditions={'method': 'POST'},
                               success=202)

        # Nodes
        res = wsgi.Resource(nodes.NodeController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("node_index",
                               "/nodes",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("node_create",
                               "/nodes",
                               action="create",
                               conditions={'method': 'POST'},
                               success=202)
            sub_mapper.connect("node_get",
                               "/nodes/{node_id}",
                               action="get",
                               conditions={'method': 'GET'})
            sub_mapper.connect("node_update",
                               "/nodes/{node_id}",
                               action="update",
                               conditions={'method': 'PATCH'},
                               success=202)
            sub_mapper.connect("node_action",
                               "/nodes/{node_id}/actions",
                               action="action",
                               conditions={'method': 'POST'},
                               success=202)
            sub_mapper.connect("node_delete",
                               "/nodes/{node_id}",
                               action="delete",
                               conditions={'method': 'DELETE'},
                               success=202)
            sub_mapper.connect("node_operation",
                               "/nodes/{node_id}/ops",
                               action="operation",
                               conditions={'method': 'POST'},
                               success=202)

        # Cluster Policies
        res = wsgi.Resource(cluster_policies.ClusterPolicyController(conf))
        policies_path = "/clusters/{cluster_id}"
        with mapper.submapper(controller=res,
                              path_prefix=policies_path) as sub_mapper:
            sub_mapper.connect("cluster_policy_list",
                               "/policies",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("cluster_policy_show",
                               "/policies/{policy_id}",
                               action="get",
                               conditions={'method': 'GET'})

        # Actions
        res = wsgi.Resource(actions.ActionController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("action_index",
                               "/actions",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("action_create",
                               "/actions",
                               action="create",
                               conditions={'method': 'POST'},
                               success=201)
            sub_mapper.connect("action_get",
                               "/actions/{action_id}",
                               action="get",
                               conditions={'method': 'GET'})

        # Receivers
        res = wsgi.Resource(receivers.ReceiverController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("receivers_index",
                               "/receivers",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("receiver_create",
                               "/receivers",
                               action="create",
                               conditions={'method': 'POST'},
                               success=201)
            sub_mapper.connect("receiver_get",
                               "/receivers/{receiver_id}",
                               action="get",
                               conditions={'method': 'GET'})
            sub_mapper.connect("receiver_delete",
                               "/receivers/{receiver_id}",
                               action="delete",
                               conditions={'method': 'DELETE'})
            sub_mapper.connect("receiver_notify",
                               "/receivers/{receiver_id}/notify",
                               action="notify",
                               conditions={'method': 'POST'})

        # Webhooks
        res = wsgi.Resource(webhooks.WebhookController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("webhook_trigger",
                               "/webhooks/{webhook_id}/trigger",
                               action="trigger",
                               conditions={'method': 'POST'},
                               success=202)

        # Events
        res = wsgi.Resource(events.EventController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("event_index",
                               "/events",
                               action="index",
                               conditions={'method': 'GET'})
            sub_mapper.connect("event_get",
                               "/events/{event_id}",
                               action="get",
                               conditions={'method': 'GET'})

        # Info
        res = wsgi.Resource(build_info.BuildInfoController(conf))
        with mapper.submapper(controller=res) as sub_mapper:

            sub_mapper.connect("build_info",
                               "/build-info",
                               action="build_info",
                               conditions={'method': 'GET'})

        super(API, self).__init__(mapper)
Exemple #20
0
    def __init__(self, conf, **local_conf):
        self.conf = conf
        mapper = routes.Mapper()
        default_resource = wsgi.Resource(wsgi.DefaultMethodController(),
                                         wsgi.JSONRequestDeserializer())

        def connect(controller, path_prefix, routes):
            """Connects list of routes to given controller with path_prefix.

            This function connects the list of routes to the given
            controller, prepending the given path_prefix. Then for each URL it
            finds which request methods aren't handled and configures those
            to return a 405 error. Finally, it adds a handler for the
            OPTIONS method to all URLs that returns the list of allowed
            methods with 204 status code.
            """
            # register the routes with the mapper, while keeping track of which
            # methods are defined for each URL
            urls = {}
            for r in routes:
                url = path_prefix + r['url']
                methods = r['method']
                if isinstance(methods, six.string_types):
                    methods = [methods]
                methods_str = ','.join(methods)
                mapper.connect(r['name'], url, controller=controller,
                               action=r['action'],
                               conditions={'method': methods_str})
                if url not in urls:
                    urls[url] = methods
                else:
                    urls[url] += methods

            # now register the missing methods to return 405s, and register
            # a handler for OPTIONS that returns the list of allowed methods
            for url, methods in urls.items():
                all_methods = ['HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE']
                missing_methods = [m for m in all_methods if m not in methods]
                allowed_methods_str = ','.join(methods)
                mapper.connect(url,
                               controller=default_resource,
                               action='reject',
                               allowed_methods=allowed_methods_str,
                               conditions={'method': missing_methods})
                if 'OPTIONS' not in methods:
                    mapper.connect(url,
                                   controller=default_resource,
                                   action='options',
                                   allowed_methods=allowed_methods_str,
                                   conditions={'method': 'OPTIONS'})

        # Stacks
        stacks_resource = stacks.create_resource(conf)
        connect(controller=stacks_resource,
                path_prefix='/{tenant_id}',
                routes=[
                    # Template handling
                    {
                        'name': 'template_validate',
                        'url': '/validate',
                        'action': 'validate_template',
                        'method': 'POST'
                    },
                    {
                        'name': 'resource_types',
                        'url': '/resource_types',
                        'action': 'list_resource_types',
                        'method': 'GET'
                    },
                    {
                        'name': 'resource_schema',
                        'url': '/resource_types/{type_name}',
                        'action': 'resource_schema',
                        'method': 'GET'
                    },
                    {
                        'name': 'generate_template',
                        'url': '/resource_types/{type_name}/template',
                        'action': 'generate_template',
                        'method': 'GET'
                    },

                    {
                        'name': 'template_versions',
                        'url': '/template_versions',
                        'action': 'list_template_versions',
                        'method': 'GET'
                    },

                    {
                        'name': 'template_functions',
                        'url': '/template_versions/{template_version}'
                               '/functions',
                        'action': 'list_template_functions',
                        'method': 'GET'
                    },

                    # Stack collection
                    {
                        'name': 'stack_index',
                        'url': '/stacks',
                        'action': 'index',
                        'method': 'GET'
                    },
                    {
                        'name': 'stack_create',
                        'url': '/stacks',
                        'action': 'create',
                        'method': 'POST'
                    },
                    {
                        'name': 'stack_preview',
                        'url': '/stacks/preview',
                        'action': 'preview',
                        'method': 'POST'
                    },
                    {
                        'name': 'stack_detail',
                        'url': '/stacks/detail',
                        'action': 'detail',
                        'method': 'GET'
                    },

                    # Stack data
                    {
                        'name': 'stack_lookup',
                        'url': '/stacks/{stack_name}',
                        'action': 'lookup',
                        'method': ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
                    },
                    # \x3A matches on a colon.
                    # Routes treats : specially in its regexp
                    {
                        'name': 'stack_lookup',
                        'url': r'/stacks/{stack_name:arn\x3A.*}',
                        'action': 'lookup',
                        'method': ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
                    },
                    {
                        'name': 'stack_lookup_subpath',
                        'url': '/stacks/{stack_name}/'
                               '{path:resources|events|template|actions}',
                        'action': 'lookup',
                        'method': 'GET'
                    },
                    {
                        'name': 'stack_lookup_subpath_post',
                        'url': '/stacks/{stack_name}/'
                               '{path:resources|events|template|actions}',
                        'action': 'lookup',
                        'method': 'POST'
                    },
                    {
                        'name': 'stack_show',
                        'url': '/stacks/{stack_name}/{stack_id}',
                        'action': 'show',
                        'method': 'GET'
                    },
                    {
                        'name': 'stack_lookup',
                        'url': '/stacks/{stack_name}/{stack_id}/template',
                        'action': 'template',
                        'method': 'GET'
                    },

                    # Stack update/delete
                    {
                        'name': 'stack_update',
                        'url': '/stacks/{stack_name}/{stack_id}',
                        'action': 'update',
                        'method': 'PUT'
                    },
                    {
                        'name': 'stack_update_patch',
                        'url': '/stacks/{stack_name}/{stack_id}',
                        'action': 'update_patch',
                        'method': 'PATCH'
                    },
                    {
                        'name': 'preview_stack_update',
                        'url': '/stacks/{stack_name}/{stack_id}/preview',
                        'action': 'preview_update',
                        'method': 'PUT'
                    },
                    {
                        'name': 'preview_stack_update_patch',
                        'url': '/stacks/{stack_name}/{stack_id}/preview',
                        'action': 'preview_update_patch',
                        'method': 'PATCH'
                    },
                    {
                        'name': 'stack_delete',
                        'url': '/stacks/{stack_name}/{stack_id}',
                        'action': 'delete',
                        'method': 'DELETE'
                    },

                    # Stack abandon
                    {
                        'name': 'stack_abandon',
                        'url': '/stacks/{stack_name}/{stack_id}/abandon',
                        'action': 'abandon',
                        'method': 'DELETE'
                    },
                    {
                        'name': 'stack_snapshot',
                        'url': '/stacks/{stack_name}/{stack_id}/snapshots',
                        'action': 'snapshot',
                        'method': 'POST'
                    },
                    {
                        'name': 'stack_snapshot_show',
                        'url': '/stacks/{stack_name}/{stack_id}/snapshots/'
                               '{snapshot_id}',
                        'action': 'show_snapshot',
                        'method': 'GET'
                    },
                    {
                        'name': 'stack_snapshot_delete',
                        'url': '/stacks/{stack_name}/{stack_id}/snapshots/'
                               '{snapshot_id}',
                        'action': 'delete_snapshot',
                        'method': 'DELETE'
                    },
                    {
                        'name': 'stack_list_snapshots',
                        'url': '/stacks/{stack_name}/{stack_id}/snapshots',
                        'action': 'list_snapshots',
                        'method': 'GET'
                    },
                    {
                        'name': 'stack_snapshot_restore',
                        'url': '/stacks/{stack_name}/{stack_id}/snapshots/'
                               '{snapshot_id}/restore',
                        'action': 'restore_snapshot',
                        'method': 'POST'
                    }
                ])

        # Resources
        resources_resource = resources.create_resource(conf)
        stack_path = '/{tenant_id}/stacks/{stack_name}/{stack_id}'
        connect(controller=resources_resource, path_prefix=stack_path,
                routes=[
                    # Resource collection
                    {
                        'name': 'resource_index',
                        'url': '/resources',
                        'action': 'index',
                        'method': 'GET'
                    },

                    # Resource data
                    {
                        'name': 'resource_show',
                        'url': '/resources/{resource_name}',
                        'action': 'show',
                        'method': 'GET'
                    },
                    {
                        'name': 'resource_metadata_show',
                        'url': '/resources/{resource_name}/metadata',
                        'action': 'metadata',
                        'method': 'GET'
                    },
                    {
                        'name': 'resource_signal',
                        'url': '/resources/{resource_name}/signal',
                        'action': 'signal',
                        'method': 'POST'
                    }
                ])

        # Events
        events_resource = events.create_resource(conf)
        connect(controller=events_resource, path_prefix=stack_path,
                routes=[
                    # Stack event collection
                    {
                        'name': 'event_index_stack',
                        'url': '/events',
                        'action': 'index',
                        'method': 'GET'
                    },

                    # Resource event collection
                    {
                        'name': 'event_index_resource',
                        'url': '/resources/{resource_name}/events',
                        'action': 'index',
                        'method': 'GET'
                    },

                    # Event data
                    {
                        'name': 'event_show',
                        'url': '/resources/{resource_name}/events/{event_id}',
                        'action': 'show',
                        'method': 'GET'
                    }
                ])

        # Actions
        actions_resource = actions.create_resource(conf)
        connect(controller=actions_resource, path_prefix=stack_path,
                routes=[
                    {
                        'name': 'action_stack',
                        'url': '/actions',
                        'action': 'action',
                        'method': 'POST'
                    }
                ])

        # Info
        info_resource = build_info.create_resource(conf)
        connect(controller=info_resource, path_prefix='/{tenant_id}',
                routes=[
                    {
                        'name': 'build_info',
                        'url': '/build_info',
                        'action': 'build_info',
                        'method': 'GET'
                    }
                ])

        # Software configs
        software_config_resource = software_configs.create_resource(conf)
        connect(controller=software_config_resource,
                path_prefix='/{tenant_id}/software_configs',
                routes=[
                    {
                        'name': 'software_config_index',
                        'url': '',
                        'action': 'index',
                        'method': 'GET'
                    },
                    {
                        'name': 'software_config_create',
                        'url': '',
                        'action': 'create',
                        'method': 'POST'
                    },
                    {
                        'name': 'software_config_show',
                        'url': '/{config_id}',
                        'action': 'show',
                        'method': 'GET'
                    },
                    {
                        'name': 'software_config_delete',
                        'url': '/{config_id}',
                        'action': 'delete',
                        'method': 'DELETE'
                    }
                ])

        # Software deployments
        sd_resource = software_deployments.create_resource(conf)
        connect(controller=sd_resource,
                path_prefix='/{tenant_id}/software_deployments',
                routes=[
                    {
                        'name': 'software_deployment_index',
                        'url': '',
                        'action': 'index',
                        'method': 'GET'
                    },
                    {
                        'name': 'software_deployment_metadata',
                        'url': '/metadata/{server_id}',
                        'action': 'metadata',
                        'method': 'GET'
                    },
                    {
                        'name': 'software_deployment_create',
                        'url': '',
                        'action': 'create',
                        'method': 'POST'
                    },
                    {
                        'name': 'software_deployment_show',
                        'url': '/{deployment_id}',
                        'action': 'show',
                        'method': 'GET'
                    },
                    {
                        'name': 'software_deployment_update',
                        'url': '/{deployment_id}',
                        'action': 'update',
                        'method': 'PUT'
                    },
                    {
                        'name': 'software_deployment_delete',
                        'url': '/{deployment_id}',
                        'action': 'delete',
                        'method': 'DELETE'
                    }
                ])

        # Services
        service_resource = services.create_resource(conf)
        with mapper.submapper(
            controller=service_resource,
            path_prefix='/{tenant_id}/services'
        ) as sa_mapper:

            sa_mapper.connect("service_index",
                              "",
                              action="index",
                              conditions={'method': 'GET'})

        # now that all the routes are defined, add a handler for
        super(API, self).__init__(mapper)
Exemple #21
0
    def __init__(self):
        mapper = routes.Mapper()

        apis = dict(catalog_api=catalog.Manager(),
                    identity_api=identity.Manager(),
                    policy_api=policy.Manager(),
                    token_api=token.Manager())

        # Catalog

        self.crud_routes(mapper, catalog.ServiceControllerV3(**apis),
                         'services', 'service')

        self.crud_routes(mapper, catalog.EndpointControllerV3(**apis),
                         'endpoints', 'endpoint')

        # Identity

        self.crud_routes(mapper, identity.DomainControllerV3(**apis),
                         'domains', 'domain')

        project_controller = identity.ProjectControllerV3(**apis)
        self.crud_routes(mapper, project_controller, 'projects', 'project')
        mapper.connect('/users/{user_id}/projects',
                       controller=project_controller,
                       action='list_user_projects',
                       conditions=dict(method=['GET']))

        self.crud_routes(mapper, identity.UserControllerV3(**apis), 'users',
                         'user')

        self.crud_routes(mapper, identity.CredentialControllerV3(**apis),
                         'credentials', 'credential')

        role_controller = identity.RoleControllerV3(**apis)
        self.crud_routes(mapper, role_controller, 'roles', 'role')
        mapper.connect(
            '/projects/{project_id}/users/{user_id}/roles/{role_id}',
            controller=role_controller,
            action='create_grant',
            conditions=dict(method=['PUT']))
        mapper.connect(
            '/projects/{project_id}/users/{user_id}/roles/{role_id}',
            controller=role_controller,
            action='check_grant',
            conditions=dict(method=['HEAD']))
        mapper.connect('/projects/{project_id}/users/{user_id}/roles',
                       controller=role_controller,
                       action='list_grants',
                       conditions=dict(method=['GET']))
        mapper.connect(
            '/projects/{project_id}/users/{user_id}/roles/{role_id}',
            controller=role_controller,
            action='revoke_grant',
            conditions=dict(method=['DELETE']))
        mapper.connect('/domains/{domain_id}/users/{user_id}/roles/{role_id}',
                       controller=role_controller,
                       action='create_grant',
                       conditions=dict(method=['PUT']))
        mapper.connect('/domains/{domain_id}/users/{user_id}/roles/{role_id}',
                       controller=role_controller,
                       action='check_grant',
                       conditions=dict(method=['HEAD']))
        mapper.connect('/domains/{domain_id}/users/{user_id}/roles',
                       controller=role_controller,
                       action='list_grants',
                       conditions=dict(method=['GET']))
        mapper.connect('/domains/{domain_id}/users/{user_id}/roles/{role_id}',
                       controller=role_controller,
                       action='revoke_grant',
                       conditions=dict(method=['DELETE']))

        # Policy

        policy_controller = policy.PolicyControllerV3(**apis)
        self.crud_routes(mapper, policy_controller, 'policies', 'policy')

        # Token
        """
        # v2.0 LEGACY
        mapper.connect('/tokens/{token_id}',
                       controller=auth_controller,
                       action='validate_token',
                       conditions=dict(method=['GET']))
        mapper.connect('/tokens/{token_id}',
                       controller=auth_controller,
                       action='validate_token_head',
                       conditions=dict(method=['HEAD']))
        mapper.connect('/tokens/{token_id}',
                       controller=auth_controller,
                       action='delete_token',
                       conditions=dict(method=['DELETE']))
        mapper.connect('/tokens/{token_id}/endpoints',
                       controller=auth_controller,
                       action='endpoints',
                       conditions=dict(method=['GET']))
        """

        super(V3Router, self).__init__(mapper, [])
Exemple #22
0
    def __init__(self, **local_config):
        mapper = routes_mapper.Mapper()
        #plugin = manager.NeutronManager.get_plugin()
        plugin = None
        #ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        #ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)

        #col_kwargs = dict(collection_actions=COLLECTION_ACTIONS,
        #                  member_actions=MEMBER_ACTIONS)

        #def _map_resource(collection, resource, params, parent=None):
        #    LOG.debug('zhf.collection=%s,resource=%s,params=%s,parent=%s' % (collection, resource, params, parent))
        #    allow_bulk = cfg.CONF.allow_bulk
        #    allow_pagination = cfg.CONF.allow_pagination
        #    allow_sorting = cfg.CONF.allow_sorting
        #    controller = base.create_resource(
        #        collection, resource, plugin, params, allow_bulk=allow_bulk,
        #        parent=parent, allow_pagination=allow_pagination,
        #        allow_sorting=allow_sorting)
        #    path_prefix = None
        #    if parent:
        #        path_prefix = "/%s/{%s_id}/%s" % (parent['collection_name'],
        #                                          parent['member_name'],
        #                                          collection)
        #    mapper_kwargs = dict(controller=controller,
        #                         requirements=REQUIREMENTS,
        #                         path_prefix=path_prefix,
        #                         **col_kwargs)
        #    return mapper.collection(collection, resource,
        #                             **mapper_kwargs)

        #mapper.connect('index', '/zhf', controller=Index(RESOURCES))
        #controller = base.create_tenant_resource()
        #mapper.connect('getTenantTotal', '/{tenant_id}', action='show',
        #        controller=controller, conditions=dict(method=["GET",]))
        #mapper.connect('addTenantTotal', '/{tenant_id}', action='create',
        #        controller=controller, conditions=dict(method=["POST",]))
        #mapper.connect('delTenantTotal', '/{tenant_id}', action='delete',
        #        controller=controller, conditions=dict(method=["DELETE",]))
        #mapper.connect('updateTenantTotal', '/{tenant_id}', action='update',
        #        controller=controller, conditions=dict(method=["PUT",]))
        #LOG.debug('zhf.mapper=%s' % mapper)

        controller = base.create_resource_new()
        for resource in RESOURCES:
            mapper.connect('',
                           '/{resource}/list',
                           action='list',
                           controller=controller,
                           conditions=dict(method=[
                               'GET',
                           ]))
            for (action, method) in MEMBER_ACTIONS:
                mapper.connect('%s_%s' % (resource, action),
                               '/{resource}/{id}',
                               requirements=REQUIREMENTS,
                               action=action,
                               controller=controller,
                               conditions=dict(method=[
                                   method,
                               ]))

        #for resource in RESOURCES:
        #    _map_resource(RESOURCES[resource], resource,
        #                  attributes.RESOURCE_ATTRIBUTE_MAP.get(
        #                      RESOURCES[resource], dict()))

        #for resource in SUB_RESOURCES:
        #    _map_resource(SUB_RESOURCES[resource]['collection_name'], resource,
        #                  attributes.RESOURCE_ATTRIBUTE_MAP.get(
        #                      SUB_RESOURCES[resource]['collection_name'],
        #                      dict()),
        #                  SUB_RESOURCES[resource]['parent'])

        super(APIRouter, self).__init__(mapper)
Exemple #23
0
    def __init__(self, application, ext_mgr=None):
        self.ext_mgr = (ext_mgr or ExtensionManager(get_extensions_path()))
        mapper = routes.Mapper()

        # extended resources
        for resource in self.ext_mgr.get_resources():
            path_prefix = resource.path_prefix
            if resource.parent:
                path_prefix = (resource.path_prefix + "/%s/{%s_id}" %
                               (resource.parent["collection_name"],
                                resource.parent["member_name"]))

            LOG.debug('Extended resource: %s', resource.collection)
            for action, method in resource.collection_actions.items():
                conditions = dict(method=[method])
                path = "/%s/%s" % (resource.collection, action)
                with mapper.submapper(controller=resource.controller,
                                      action=action,
                                      path_prefix=path_prefix,
                                      conditions=conditions) as submap:
                    submap.connect(path_prefix + path, path)
                    submap.connect(path_prefix + path + "_format",
                                   "%s.:(format)" % path)

            for action, method in resource.collection_methods.items():
                conditions = dict(method=[method])
                path = "/%s" % resource.collection
                with mapper.submapper(controller=resource.controller,
                                      action=action,
                                      path_prefix=path_prefix,
                                      conditions=conditions) as submap:
                    submap.connect(path_prefix + path, path)
                    submap.connect(path_prefix + path + "_format",
                                   "%s.:(format)" % path)

            mapper.resource(resource.collection,
                            resource.collection,
                            controller=resource.controller,
                            member=resource.member_actions,
                            parent_resource=resource.parent,
                            path_prefix=path_prefix)

        # extended actions
        action_controllers = self._action_ext_controllers(
            application, self.ext_mgr, mapper)
        for action in self.ext_mgr.get_actions():
            LOG.debug('Extended action: %s', action.action_name)
            controller = action_controllers[action.collection]
            controller.add_action(action.action_name, action.handler)

        # extended requests
        req_controllers = self._request_ext_controllers(
            application, self.ext_mgr, mapper)
        for request_ext in self.ext_mgr.get_request_extensions():
            LOG.debug('Extended request: %s', request_ext.key)
            controller = req_controllers[request_ext.key]
            controller.add_handler(request_ext.handler)

        self._router = routes.middleware.RoutesMiddleware(
            self._dispatch, mapper)
        super(ExtensionMiddleware, self).__init__(application)
Exemple #24
0
 def __init__(self):
     mapper = routes.Mapper()
     mapper.resource("test", "tests", controller=self.TestController())
     wsgi.Router.__init__(self, mapper)
Exemple #25
0
 def __init__(self):
     mapper = routes.Mapper()
     mapper.connect("/test", controller=Application())
     super(Router, self).__init__(mapper)
Exemple #26
0
def wrap_in_middleware(app, global_conf, application_stack, **local_conf):
    """Based on the configuration wrap `app` in a set of common and useful middleware."""
    stack = application_stack
    # Merge the global and local configurations
    conf = global_conf.copy()
    conf.update(local_conf)
    debug = asbool(conf.get('debug', False))
    interactive = asbool(conf.get('use_interactive', False))
    # First put into place httpexceptions, which must be most closely
    # wrapped around the application (it can interact poorly with
    # other middleware):
    app = wrap_if_allowed(app,
                          stack,
                          httpexceptions.make_middleware,
                          name='paste.httpexceptions',
                          args=(conf, ))
    # Create a separate mapper for redirects to prevent conflicts.
    redirect_mapper = routes.Mapper()
    redirect_mapper = _map_redirects(redirect_mapper)
    # Load the Routes middleware which we use for redirecting
    app = wrap_if_allowed(app,
                          stack,
                          RoutesMiddleware,
                          args=(redirect_mapper, ))
    # If we're using remote_user authentication, add middleware that
    # protects Galaxy from improperly configured authentication in the
    # upstream server
    if asbool(conf.get('use_remote_user', False)):
        from galaxy.webapps.tool_shed.framework.middleware.remoteuser import RemoteUser
        app = wrap_if_allowed(
            app,
            stack,
            RemoteUser,
            kwargs=dict(
                maildomain=conf.get('remote_user_maildomain', None),
                display_servers=util.listify(conf.get('display_servers', '')),
                admin_users=conf.get('admin_users', '').split(','),
                remote_user_header=conf.get('remote_user_header',
                                            'HTTP_REMOTE_USER'),
                remote_user_secret_header=conf.get('remote_user_secret', None),
                normalize_remote_user_email=conf.get(
                    'normalize_remote_user_email', False)))
    # The recursive middleware allows for including requests in other
    # requests or forwarding of requests, all on the server side.
    if asbool(conf.get('use_recursive', True)):
        from paste import recursive
        app = wrap_if_allowed(app,
                              stack,
                              recursive.RecursiveMiddleware,
                              args=(conf, ))
    # Transaction logging (apache access.log style)
    if asbool(conf.get('use_translogger', True)):
        from paste.translogger import TransLogger
        app = wrap_if_allowed(app, stack, TransLogger)
    # If sentry logging is enabled, log here before propogating up to
    # the error middleware
    # TODO sentry config is duplicated between tool_shed/galaxy, refactor this.
    sentry_dsn = conf.get('sentry_dsn', None)
    if sentry_dsn:
        from galaxy.web.framework.middleware.sentry import Sentry
        app = wrap_if_allowed(app, stack, Sentry, args=(sentry_dsn, ))
    # X-Forwarded-Host handling
    from galaxy.web.framework.middleware.xforwardedhost import XForwardedHostMiddleware
    app = wrap_if_allowed(app, stack, XForwardedHostMiddleware)
    # Various debug middleware that can only be turned on if the debug
    # flag is set, either because they are insecure or greatly hurt
    # performance.
    if debug:
        # Middleware to check for WSGI compliance
        if asbool(conf.get('use_lint', True)):
            from paste import lint
            app = wrap_if_allowed(app,
                                  stack,
                                  lint.make_middleware,
                                  name='paste.lint',
                                  args=(conf, ))
        # Middleware to run the python profiler on each request
        if asbool(conf.get('use_profile', False)):
            from paste.debug import profile
            app = wrap_if_allowed(app,
                                  stack,
                                  profile.ProfileMiddleware,
                                  args=(conf, ))
        if interactive:
            # Interactive exception debugging, scary dangerous if publicly
            # accessible, if not enabled we'll use the regular error printing
            # middleware.
            try:
                from weberror import evalexception
                app = wrap_if_allowed_or_fail(
                    app,
                    stack,
                    evalexception.EvalException,
                    args=(conf, ),
                    kwargs=dict(
                        templating_formatters=build_template_error_formatters(
                        )))
            except MiddlewareWrapUnsupported as exc:
                log.warning(str(exc))
                import galaxy.web.framework.middleware.error
                app = wrap_if_allowed(
                    app,
                    stack,
                    galaxy.web.framework.middleware.error.ErrorMiddleware,
                    args=(conf, ))
        else:
            # Not in interactive debug mode, just use the regular error middleware
            import galaxy.web.framework.middleware.error
            app = wrap_if_allowed(
                app,
                stack,
                galaxy.web.framework.middleware.error.ErrorMiddleware,
                args=(conf, ))
    return app
Exemple #27
0
import routes
from simpleservice.wsgi import router

from goperation.manager.wsgi.entity.routers import Routers as entity_routes

mapper = routes.Mapper()

entity_route = entity_routes()
entity_route.append_routers(mapper)

testing_route = router.ComposingRouter(mapper)

for x in mapper.matchlist:
    print x.name

route_dict = mapper._routenames

for route_name in route_dict:
    print route_name, route_dict[route_name].conditions.get('method'),
    print route_dict[route_name].defaults.get(
        'action'), route_dict[route_name].routepath
Exemple #28
0
    def __init__(self, mapper=None):
        if mapper is None:
            mapper = routes.Mapper()

        self._load_registered_routes(mapper)
        super(Router, self).__init__(mapper=mapper)
Exemple #29
0
 def __init__(self, ext_mgr=None):
     self.server_members = {}
     mapper = routes.Mapper()
     self._setup_routes(mapper)
     super(APIRouter, self).__init__(mapper)
Exemple #30
0
 def __init__(self, dict):
     mapper = routes.Mapper()
     self.add_routes(mapper)
     super(ComposableRouter, self).__init__(mapper)