def publishTraverse(self, request, name): try: return DefaultPublishTraverse.publishTraverse(self, request, name) except KeyError: if ILayer.providedBy(request): registry = getUtility(IRegistry) settings = registry.forInterface(IRoutesSettings) activated_routes = settings.routes fullpath = request.physicalPathFromURL( request.get('ACTUAL_URL', '')) context_path = self.context.getPhysicalPath() fullpath = fullpath[len(context_path):] for route_name in activated_routes: route = getRoute(route_name) if not route: continue if route.matches(fullpath, request): fragments = route.fragments fragment = fragments[0] query = route.defaultQuery.copy() query.update(fragment.query(name)) return FragmentContext(self.context, request, name, route, fragments[0], fragments[1:], query).__of__(self.context) raise
def __call__(self, context): items = [] for route_name in getRouteNames(): route = getRoute(route_name) if not route: continue items.append(SimpleVocabulary.createTerm(route.name, route.name, route.name)) return SimpleVocabulary(items)