[Mpuls-commits] r5883 - base/trunk/mpulsweb/lib

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu Mar 8 13:56:00 CET 2012


Author: ludwig
Date: 2012-03-08 13:56:00 +0100 (Thu, 08 Mar 2012)
New Revision: 5883

Modified:
   base/trunk/mpulsweb/lib/base.py
   base/trunk/mpulsweb/lib/dialogs.py
   base/trunk/mpulsweb/lib/formedrenderer.py
   base/trunk/mpulsweb/lib/navigation.py
Log:
Issue 2738: Replace url_for (libs)


Modified: base/trunk/mpulsweb/lib/base.py
===================================================================
--- base/trunk/mpulsweb/lib/base.py	2012-03-08 12:46:38 UTC (rev 5882)
+++ base/trunk/mpulsweb/lib/base.py	2012-03-08 12:56:00 UTC (rev 5883)
@@ -35,8 +35,6 @@
 
 from webob.exc import HTTPUnauthorized, HTTPNotFound
 
-from routes import url_for
-
 from pylons import tmpl_context as c, config, app_globals as g, \
                    request, response, url
 from pylons.controllers import WSGIController
@@ -250,7 +248,7 @@
             p = str(request.path_info)
             if not p in ('/auth/login', '/auth/loginAction'):
                 redirect(config.get("mpuls.auth.login_url")
-                         or url_for(controller='/auth', action='login'))
+                         or h.url(controller='auth', action='login'))
 
     def __call__(self, environ, start_response):
         """Invoke the Controller"""

Modified: base/trunk/mpulsweb/lib/dialogs.py
===================================================================
--- base/trunk/mpulsweb/lib/dialogs.py	2012-03-08 12:46:38 UTC (rev 5882)
+++ base/trunk/mpulsweb/lib/dialogs.py	2012-03-08 12:56:00 UTC (rev 5883)
@@ -9,7 +9,7 @@
 from mpulsweb.lib.translation import _
 
 from mpulsweb.lib.base import render, session, load_case
-from mpulsweb.lib.helpers import url_for 
+from mpulsweb.lib.helpers import url
 from mpulsweb.model.appointment import CaseAppointmentFactory
 
 
@@ -39,17 +39,17 @@
                 app_factory = CaseAppointmentFactory()
                 app = app_factory.loadById(app_id)
                 case_id = app.case_id
-                c.targeturl = url_for(controller="/caseappointment",
-                                        action="show",
-                                        id=app_id, confirmed=1)
+                c.targeturl = url(controller="caseappointment",
+                                  action="show",
+                                  id=app_id, confirmed=1)
             else:
                 try:
                     case_id = int(args[0])
                     confirmed = int(args[1])
                 except:
                     raise HTTPNotFound()
-                c.targeturl = url_for(controller="/case", action=context,
-                                        id=case_id, confirmed=1)
+                c.targeturl = url(controller="case", action=context,
+                                  id=case_id, confirmed=1)
 
             case = load_case(case_id)
             statement = case.getPrivacyStatement()
@@ -82,17 +82,17 @@
                 app_factory = CaseAppointmentFactory()
                 app = app_factory.loadById(app_id)
                 case_id = app.case_id
-                c.targeturl = url_for(controller="/caseappointment",
-                                        action="show",
-                                        id=app_id, confirmed=1)
+                c.targeturl = url(controller="caseappointment",
+                                  action="show",
+                                  id=app_id, confirmed=1)
             else:
                 try:
                     case_id = int(args[0])
                     confirmed = int(args[1])
                 except:
                     raise HTTPNotFound()
-                c.targeturl = url_for(controller="/case", action=context,
-                                        id=case_id, confirmed=1)
+                c.targeturl = url(controller="case", action=context,
+                                  id=case_id, confirmed=1)
 
             case = load_case(case_id)
             meta = case.getMeta()
@@ -138,7 +138,7 @@
     else:
         c.dialog_text = text or _('Default Text')
     c.url_ok = url_ok
-    c.url_abort = url_abort or url_for(controller="meta", action="index")
+    c.url_abort = url_abort or url(controller="meta", action="index")
     return render('/dialogs/confirm_%s.mako' % get_dialog_template(ctx))
 
 
@@ -180,10 +180,10 @@
                 return func(self, *args, **kwargs)
             else: # show dialog
                 # Build url for ok
-                url_ok = url_for(controller=url_dict.get('controller'),
-                                 action=url_dict.get('action'),
-                                 id=url_dict.get('id'),
-                                 confirmed=1)
+                url_ok = url(controller=url_dict.get('controller'),
+                             action=url_dict.get('action'),
+                             id=url_dict.get('id'),
+                             confirmed=1)
                 log.debug('calling function %s is NOT confirmed. Redirecting.'
                           % func.__name__)
                 # Save request.params in a session. Otherwise they will get
@@ -207,13 +207,13 @@
 def success(header=None, text=None, url_ok=None, dynfunc=None):
     """Simple function which can be called after an action was successfully
     done. It returns a rendered success-dialog"""
-    url_ok = url_ok or url_for(controller="case", action="digest")
+    url_ok = url_ok or url(controller="case", action="digest")
     return render_success(header, text, url_ok, dynfunc)
 
 def error(header=None, text=None, url_ok=None, dynfunc=None):
     """Simple function which can be called after an action was  done with
     errors. It returns a rendered error-dialog"""
-    url_ok = url_ok or url_for(controller="case", action="digest")
+    url_ok = url_ok or url(controller="case", action="digest")
     return render_error(header, text, url_ok, dynfunc)
 
 

Modified: base/trunk/mpulsweb/lib/formedrenderer.py
===================================================================
--- base/trunk/mpulsweb/lib/formedrenderer.py	2012-03-08 12:46:38 UTC (rev 5882)
+++ base/trunk/mpulsweb/lib/formedrenderer.py	2012-03-08 12:56:00 UTC (rev 5883)
@@ -32,20 +32,20 @@
 from formed.renderer.html import RendererContext, Container, Item
 from formed.renderer.helpers import tag, escape
 
-from mpulsweb.lib.helpers import url_for
+from mpulsweb.lib.helpers import url
 
 
 class UrlFactory(BaseUrlFactory):
 
     def url_for(self, controller, action, id=None):
-        url_for_args = {"controller": controller, "action":action}
+        url_args = {"controller": controller, "action":action}
         if not id is None:
-            url_for_args["id"] = id
-        return url_for(**url_for_args)
+            url_args["id"] = id
+        return url(**url_args)
 
     def icon(self, name):
         """Return the url for the icon given by name."""
-        return url_for("/images/icons/" + name)
+        return url("/images/icons/" + name)
 
 
 class ViewRenderer(HtmlRenderer):

Modified: base/trunk/mpulsweb/lib/navigation.py
===================================================================
--- base/trunk/mpulsweb/lib/navigation.py	2012-03-08 12:46:38 UTC (rev 5882)
+++ base/trunk/mpulsweb/lib/navigation.py	2012-03-08 12:56:00 UTC (rev 5883)
@@ -52,19 +52,19 @@
 
 
 def select_item_url(id):
-    return mpulsweb.lib.helpers.url_for(controller="/formularpage",
+    return mpulsweb.lib.helpers.url(controller="formularpage",
                                         action="select", id=id)
 
 def select_branch_url(id):
-    return mpulsweb.lib.helpers.url_for(controller="/navigation",
+    return mpulsweb.lib.helpers.url(controller="navigation",
                                         action="select_branch", id=id)
 
 def close_branch_url(id):
-    return mpulsweb.lib.helpers.url_for(controller="/navigation",
+    return mpulsweb.lib.helpers.url(controller="navigation",
                                         action="close_branch", id=id)
 
 def open_branch_url(id):
-    return mpulsweb.lib.helpers.url_for(controller="/navigation",
+    return mpulsweb.lib.helpers.url(controller="navigation",
                                         action="open_branch", id=id)
 
 
@@ -130,7 +130,7 @@
     def get_image(self, name, attributes=""):
         if isinstance(name, unicode):
             name = name.encode("utf-8")
-        return '<img src="%s" %s>' % (mpulsweb.lib.helpers.url_for(name),
+        return '<img src="%s" %s>' % (mpulsweb.lib.helpers.url(name),
                                       attributes)
 
     def get_base(self):



More information about the Mpuls-commits mailing list