Commits

Robert Brewer committed 0e83e2a

Changed LateParamPageHandler to use a property instead of __getattribute__ (thanks, michele!) and added a docstring.

Comments (0)

Files changed (1)

 
 
 class LateParamPageHandler(PageHandler):
+    """When passing cherrypy.request.params to the page handler, we don't
+    want to capture that dict too early; we want to give tools like the
+    decoding tool a chance to modify the params dict in-between the lookup
+    of the handler and the actual calling of the handler. This subclass
+    takes that into account, and allows request.params to be 'bound late'
+    (it's more complicated than that, but that's the effect).
+    """
     
-    def __getattribute__(self, name):
-        attr = object.__getattribute__(self, name)
-        if name == "kwargs":
-            if attr:
-                kwargs = cherrypy.request.params.copy()
-                kwargs.update(attr)
-            else:
-                kwargs = cherrypy.request.params
-            return kwargs
-        else:
-            return attr
+    def _get_kwargs(self):
+        kwargs = cherrypy.request.params.copy()
+        if self._kwargs:
+            kwargs.update(self._kwargs)
+        return kwargs
+    
+    def _set_kwargs(self, kwargs):
+        self._kwargs = kwargs
+    
+    kwargs = property(_get_kwargs, _set_kwargs,
+                      doc='page handler kwargs (with '
+                      'cherrypy.request.params copied in)')
 
 
 class Dispatcher(object):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.