Ejemplo n.º 1
0
 def make_rst(self):
     routes = import_string(self.content.data[0])
     for method, path, route in traverse_routes(routes):
         if not self.allowed(path):
             continue
         if isinstance(route.target, basestring):
             try:
                 target = import_string(route.target)
             except ImportError:
                 print >> sys.stderr, 'cannot import %s' % route.target
                 continue
         else:
             target = route.target
         docstring = prepare_docstring(target.__doc__ or '')
         for line in http_directive(method, path, docstring):
             yield line
Ejemplo n.º 2
0
def include(spec):
    """ Include routes by ``spec``

    :param spec:
        asset specification which points to :class:`.Route` instance
    """
    r = import_string(spec)
    if not isinstance(r, Route):
        raise RouteConfigurationError(
            "route included by '%s' isn't a route" % spec)
    return r
Ejemplo n.º 3
0
    def test_unicode(self):
        module = import_string(six.u('six'))
        self.assertEqual(module, six)

        klass = import_string(six.u('routr.Route'))
        self.assertEqual(klass, Route)
Ejemplo n.º 4
0
    def test_success(self):
        module = import_string('six')
        self.assertEqual(module, six)

        klass = import_string('routr.Route')
        self.assertEqual(klass, Route)
Ejemplo n.º 5
0
    def test_unicode(self):
        module = import_string(six.u('six'))
        self.assertEqual(module, six)

        klass = import_string(six.u('routr.Route'))
        self.assertEqual(klass, Route)
Ejemplo n.º 6
0
    def test_success(self):
        module = import_string('six')
        self.assertEqual(module, six)

        klass = import_string('routr.Route')
        self.assertEqual(klass, Route)