Python routes.Mapper() Examples
The following are 30
code examples of routes.Mapper().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
routes
, or try the search function
.
Example #1
Source File: s3server.py From ec2-api with Apache License 2.0 | 7 votes |
def __init__(self, root_directory, bucket_depth=0, mapper=None): if mapper is None: mapper = routes.Mapper() mapper.connect( '/', controller=lambda *a, **kw: RootHandler(self)(*a, **kw)) mapper.connect( '/{bucket}/{object_name}', controller=lambda *a, **kw: ObjectHandler(self)(*a, **kw)) mapper.connect( '/{bucket_name}', controller=lambda *a, **kw: BucketHandler(self)(*a, **kw), requirements={'bucket_name': '[^/]+/?'}) self.directory = os.path.abspath(root_directory) fileutils.ensure_tree(self.directory) self.bucket_depth = bucket_depth super(S3Application, self).__init__(mapper)
Example #2
Source File: test_wsgi.py From manila with Apache License 2.0 | 6 votes |
def test_router(self): class Application(common_wsgi.Application): """Test application to call from router.""" def __call__(self, environ, start_response): start_response("200", []) return ['Router result'] class Router(wsgi.Router): """Test router.""" def __init__(self): mapper = routes.Mapper() mapper.connect("/test", controller=Application()) super(Router, self).__init__(mapper) result = webob.Request.blank('/test').get_response(Router()) self.assertEqual("Router result", result.body) result = webob.Request.blank('/bad').get_response(Router()) self.assertNotEqual(result.body, "Router result")
Example #3
Source File: _cpdispatch.py From opsbro with MIT License | 5 votes |
def __init__(self, full_result=False, **mapper_options): """ Routes dispatcher Set full_result to True if you wish the controller and the action to be passed on to the page handler parameters. By default they won't be. """ import routes self.full_result = full_result self.controllers = {} self.mapper = routes.Mapper(**mapper_options) self.mapper.controller_scan = self.controllers.keys
Example #4
Source File: _cpdispatch.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, full_result=False): """ Routes dispatcher Set full_result to True if you wish the controller and the action to be passed on to the page handler parameters. By default they won't be. """ import routes self.full_result = full_result self.controllers = {} self.mapper = routes.Mapper() self.mapper.controller_scan = self.controllers.keys
Example #5
Source File: router.py From tacker with Apache License 2.0 | 5 votes |
def __init__(self, **local_config): mapper = routes_mapper.Mapper() ext_mgr = extensions.ExtensionManager.get_instance() ext_mgr.extend_resources("1.0", attributes.RESOURCE_ATTRIBUTE_MAP) super(APIRouter, self).__init__(mapper)
Example #6
Source File: router.py From tacker with Apache License 2.0 | 5 votes |
def __init__(self): mapper = routes.Mapper() super(VnfpkgmAPIRouter, self).__init__(mapper)
Example #7
Source File: router.py From tacker with Apache License 2.0 | 5 votes |
def __init__(self): mapper = routes.Mapper() super(VnflcmAPIRouter, self).__init__(mapper)
Example #8
Source File: test_extensions.py From tacker with Apache License 2.0 | 5 votes |
def __init__(self, options={}): mapper = routes.Mapper() controller = ext_stubs.StubBaseAppController() mapper.resource("dummy_resource", "/dummy_resources", controller=controller) super(ExtensionsTestApp, self).__init__(mapper)
Example #9
Source File: router.py From st2 with Apache License 2.0 | 5 votes |
def __init__(self, arguments=None, debug=False, auth=True, is_gunicorn=True): self.debug = debug self.auth = auth self.is_gunicorn = is_gunicorn self.arguments = arguments or {} self.spec = {} self.spec_resolver = None self.routes = routes.Mapper()
Example #10
Source File: __init__.py From coriolis with GNU Affero General Public License v3.0 | 5 votes |
def routematch(self, url=None, environ=None): if url is "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ)
Example #11
Source File: __init__.py From coriolis with GNU Affero General Public License v3.0 | 5 votes |
def connect(self, *args, **kwargs): # NOTE(inhye): Default the format part of a route to only accept json # and xml so it doesn't eat all characters after a '.' # in the url. kwargs.setdefault('requirements', {}) if not kwargs['requirements'].get('format'): kwargs['requirements']['format'] = 'json|xml' return routes.Mapper.connect(self, *args, **kwargs)
Example #12
Source File: __init__.py From coriolis with GNU Affero General Public License v3.0 | 5 votes |
def resource(self, member_name, collection_name, **kwargs): if 'parent_resource' not in kwargs: kwargs['path_prefix'] = '{project_id}/' else: parent_resource = kwargs['parent_resource'] p_collection = parent_resource['collection_name'] p_member = parent_resource['member_name'] kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection, p_member) routes.Mapper.resource(self, member_name, collection_name, **kwargs)
Example #13
Source File: _cpdispatch.py From bazarr with GNU General Public License v3.0 | 5 votes |
def __init__(self, full_result=False, **mapper_options): """ Routes dispatcher Set full_result to True if you wish the controller and the action to be passed on to the page handler parameters. By default they won't be. """ import routes self.full_result = full_result self.controllers = {} self.mapper = routes.Mapper(**mapper_options) self.mapper.controller_scan = self.controllers.keys
Example #14
Source File: _cpdispatch.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def __init__(self, full_result=False, **mapper_options): """ Routes dispatcher Set full_result to True if you wish the controller and the action to be passed on to the page handler parameters. By default they won't be. """ import routes self.full_result = full_result self.controllers = {} self.mapper = routes.Mapper(**mapper_options) self.mapper.controller_scan = self.controllers.keys
Example #15
Source File: __init__.py From karbor with Apache License 2.0 | 5 votes |
def routematch(self, url=None, environ=None): if url == "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ)
Example #16
Source File: __init__.py From karbor with Apache License 2.0 | 5 votes |
def connect(self, *args, **kwargs): # NOTE(inhye): Default the format part of a route to only accept json # and xml so it doesn't eat all characters after a '.' # in the url. kwargs.setdefault('requirements', {}) if not kwargs['requirements'].get('format'): kwargs['requirements']['format'] = 'json|xml' return routes.Mapper.connect(self, *args, **kwargs)
Example #17
Source File: __init__.py From karbor with Apache License 2.0 | 5 votes |
def resource(self, member_name, collection_name, **kwargs): if 'parent_resource' not in kwargs: kwargs['path_prefix'] = '{project_id}/' else: parent_resource = kwargs['parent_resource'] p_collection = parent_resource['collection_name'] p_member = parent_resource['member_name'] kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection, p_member) routes.Mapper.resource(self, member_name, collection_name, **kwargs)
Example #18
Source File: fakes.py From karbor with Apache License 2.0 | 5 votes |
def __init__(self, controller): mapper = routes.Mapper() mapper.resource("test", "tests", controller=os_wsgi.Resource(controller)) super(TestRouter, self).__init__(mapper)
Example #19
Source File: _cpdispatch.py From cherrypy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, full_result=False, **mapper_options): """ Routes dispatcher Set full_result to True if you wish the controller and the action to be passed on to the page handler parameters. By default they won't be. """ import routes self.full_result = full_result self.controllers = {} self.mapper = routes.Mapper(**mapper_options) self.mapper.controller_scan = self.controllers.keys
Example #20
Source File: __init__.py From manila with Apache License 2.0 | 5 votes |
def resource(self, member_name, collection_name, **kwargs): if 'parent_resource' not in kwargs: kwargs['path_prefix'] = '{project_id}/' else: parent_resource = kwargs['parent_resource'] p_collection = parent_resource['collection_name'] p_member = parent_resource['member_name'] kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection, p_member) routes.Mapper.resource(self, member_name, collection_name, **kwargs)
Example #21
Source File: __init__.py From vdi-broker with Apache License 2.0 | 5 votes |
def routematch(self, url=None, environ=None): if url is "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ)
Example #22
Source File: __init__.py From vdi-broker with Apache License 2.0 | 5 votes |
def connect(self, *args, **kwargs): # NOTE(inhye): Default the format part of a route to only accept json # and xml so it doesn't eat all characters after a '.' # in the url. kwargs.setdefault('requirements', {}) if not kwargs['requirements'].get('format'): kwargs['requirements']['format'] = 'json|xml' return routes.Mapper.connect(self, *args, **kwargs)
Example #23
Source File: __init__.py From vdi-broker with Apache License 2.0 | 5 votes |
def resource(self, member_name, collection_name, **kwargs): if 'parent_resource' not in kwargs: kwargs['path_prefix'] = '{project_id}/' else: parent_resource = kwargs['parent_resource'] p_collection = parent_resource['collection_name'] p_member = parent_resource['member_name'] kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection, p_member) routes.Mapper.resource(self, member_name, collection_name, **kwargs)
Example #24
Source File: wsgi.py From snippet with MIT License | 5 votes |
def __init__(self, mapper): """Create a router for the given routes.Mapper. Each route in `mapper` must specify a 'controller', which is a WSGI app to call. You'll probably want to specify an 'action' as well and have your controller be an object that can route the request to the action-specific method. Examples: mapper = routes.Mapper() sc = ServerController() # Explicit mapping of one route to a controller+action mapper.connect(None, '/svrlist', controller=sc, action='list') # Actions are all implicitly defined mapper.resource('server', 'servers', controller=sc) # Pointing to an arbitrary WSGI app. You can specify the # {path_info:.*} parameter so the target app can be handed just that # section of the URL. mapper.connect(None, '/v1.0/{path_info:.*}', controller=BlogApp()) """ mapper.redirect("", "/") self._mapper = mapper self._router = routes.middleware.RoutesMiddleware(self._dispatch, mapper)
Example #25
Source File: wsgi.py From searchlight with Apache License 2.0 | 5 votes |
def routematch(self, url=None, environ=None): if url == "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ)
Example #26
Source File: wsgi.py From searchlight with Apache License 2.0 | 5 votes |
def __init__(self, mapper): """ Create a router for the given routes.Mapper. Each route in `mapper` must specify a 'controller', which is a WSGI app to call. You'll probably want to specify an 'action' as well and have your controller be a wsgi.Controller, who will route the request to the action method. Examples: mapper = routes.Mapper() sc = ServerController() # Explicit mapping of one route to a controller+action mapper.connect(None, "/svrlist", controller=sc, action="list") # Actions are all implicitly defined mapper.resource("server", "servers", controller=sc) # Pointing to an arbitrary WSGI app. You can specify the # {path_info:.*} parameter so the target app can be handed just that # section of the URL. mapper.connect(None, "/v1.0/{path_info:.*}", controller=BlogApp()) """ mapper.redirect("", "/") self.map = mapper self._router = routes.middleware.RoutesMiddleware(self._dispatch, self.map)
Example #27
Source File: __init__.py From manila with Apache License 2.0 | 5 votes |
def routematch(self, url=None, environ=None): if url == "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ)
Example #28
Source File: __init__.py From manila with Apache License 2.0 | 5 votes |
def connect(self, *args, **kwargs): # NOTE(inhye): Default the format part of a route to only accept json # and xml so it doesn't eat all characters after a '.' # in the url. kwargs.setdefault('requirements', {}) if not kwargs['requirements'].get('format'): kwargs['requirements']['format'] = 'json|xml' return routes.Mapper.connect(self, *args, **kwargs)
Example #29
Source File: fakes.py From masakari with Apache License 2.0 | 5 votes |
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)
Example #30
Source File: fakes.py From manila with Apache License 2.0 | 5 votes |
def __init__(self, controller): mapper = routes.Mapper() mapper.resource("test", "tests", controller=os_wsgi.Resource(controller)) super(TestRouter, self).__init__(mapper)