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)
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'))
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))
def post(self, queue_name, callback): request = self.request callback = import_class(callback) callback(*json.loads(request.get('args')), **json.loads(request.get('kwargs')))