web/views/urlpublishing.py
changeset 2650 18aec79ec3a3
parent 2293 7ded2a1416e4
child 2657 de974465d381
--- a/web/views/urlpublishing.py	Mon Aug 03 09:37:13 2009 +0200
+++ b/web/views/urlpublishing.py	Mon Aug 03 10:50:57 2009 +0200
@@ -56,8 +56,7 @@
         super(URLPublisherComponent, self).__init__()
         self.default_method = default_method
         evaluators = []
-        for evaluatorcls in self.vreg.registry_objects('components',
-                                                       'urlpathevaluator'):
+        for evaluatorcls in self.vreg['components']['urlpathevaluator']:
             # instantiation needed
             evaluator = evaluatorcls(self)
             evaluators.append(evaluator)
@@ -83,7 +82,7 @@
         parts = [part for part in path.split('/')
                  if part != ''] or (self.default_method,)
         if req.form.get('rql'):
-            if parts[0] in self.vreg.registry('controllers'):
+            if parts[0] in self.vreg['controllers']:
                 return parts[0], None
             return 'view', None
         for evaluator in self.evaluators:
@@ -114,7 +113,7 @@
     """
     priority = 0
     def evaluate_path(self, req, parts):
-        if len(parts) == 1 and parts[0] in self.vreg.registry('controllers'):
+        if len(parts) == 1 and parts[0] in self.vreg['controllers']:
             return parts[0], None
         raise PathDontMatch()
 
@@ -195,9 +194,8 @@
     def evaluate_path(self, req, parts):
         # uri <=> req._twreq.path or req._twreq.uri
         uri = req.url_unquote('/' + '/'.join(parts))
-        vobjects = sorted(self.vreg.registry_objects('urlrewriting'),
-                          key=lambda x: x.priority,
-                          reverse=True)
+        vobjects = sorted(self.vreg['urlrewriting'].all_objects(),
+                          key=lambda x: x.priority, reverse=True)
         for rewritercls in vobjects:
             rewriter = rewritercls()
             try:
@@ -220,8 +218,9 @@
         # remove last part and see if this is something like an actions
         # if so, call
         try:
+            actionsreg = self.vreg['actions']
             requested = parts.pop(-1)
-            actions = self.vreg.registry_objects('actions', requested)
+            actions = actionsreg[requested]
         except RegistryException:
             raise PathDontMatch()
         for evaluator in self.urlpublisher.evaluators:
@@ -233,9 +232,9 @@
                 continue
             else:
                 try:
-                    action = self.vreg.select_best(actions, req, rset=rset)
+                    action = actionsreg.select_best(actions, req, rset=rset)
                 except RegistryException:
-                    raise PathDontMatch()
+                    continue
                 else:
                     # XXX avoid redirect
                     raise Redirect(action.url())