Beispiel #1
0
 def __call__(self, environ, start_response):
     root = environ['webob.adhoc_attrs']['root']
     path = environ['PATH_INFO'].lstrip('/').split('/')
     res = HTTPNotFound()
     if len(path) == 1:
         path = path[0]
         # we should have a look to see if we want to forward to a resource
         for util in utility_finder.utilities():
             utility = utility_finder(root, util).keys()
             if path in utility:
                 res = HTTPMovedPermanently(location = '/%s/%s' % (util, path))
     return res(environ, start_response)
Beispiel #2
0
def not_found(context, request):
    environ = request.environ
    root = environ['webob.adhoc_attrs']['root']
    path = environ['PATH_INFO'].lstrip('/').split('/')
    res = HTTPNotFound()
    if len(path) == 1:
        path = path[0]
        # we should have a look to see if we want to forward to a resource
        for util in utility_finder.utilities():
            utility = utility_finder(root, util).keys()
            if path in utility:
                res = HTTPMovedPermanently(location = '/%s/%s' % (util, path))
    return res