Exemple #1
0
def include(prefix, routes):
    if isinstance(routes, StringTypes):
        routes = import_class('%s.routes' % routes)
    elif hasattr(routes, 'routes'):
        routes = routes.routes

    routes = [Router.route_class(*route) if isinstance(route, tuple) else route for route in routes]

    return PathPrefixRoute(prefix, routes)
Exemple #2
0
 def test_import_class_from_string_path(self):
     """ Utils - importing class type from string path """
     delta_two_hours = timedelta(hours=2)
     self.assertEqual(type(delta_two_hours), import_class('datetime.timedelta'))
Exemple #3
0
 def test_import_class_from_usage(self):
     """ Utils - importing class type from usage """
     delta_two_hours = timedelta(hours=2)
     self.assertEqual(type(delta_two_hours), import_class(timedelta))
Exemple #4
0
 def post(self, queue_name, callback):
     request = self.request
     callback = import_class(callback)
     callback(*json.loads(request.get('args')), **json.loads(request.get('kwargs')))