Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1234

Show
Ignore:
Timestamp:
08/11/06 13:19:07
Author:
fumanchu
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cprequest.py

    r1231 r1234  
    418418 
    419419class LateParamPageHandler(PageHandler): 
    420      
    421     def __getattribute__(self, name): 
    422         attr = object.__getattribute__(self, name) 
    423         if name == "kwargs": 
    424             if attr: 
    425                 kwargs = cherrypy.request.params.copy() 
    426                 kwargs.update(attr) 
    427             else: 
    428                 kwargs = cherrypy.request.params 
    429             return kwargs 
    430         else: 
    431             return attr 
     420    """When passing cherrypy.request.params to the page handler, we don't 
     421    want to capture that dict too early; we want to give tools like the 
     422    decoding tool a chance to modify the params dict in-between the lookup 
     423    of the handler and the actual calling of the handler. This subclass 
     424    takes that into account, and allows request.params to be 'bound late' 
     425    (it's more complicated than that, but that's the effect). 
     426    """ 
     427     
     428    def _get_kwargs(self): 
     429        kwargs = cherrypy.request.params.copy() 
     430        if self._kwargs: 
     431            kwargs.update(self._kwargs) 
     432        return kwargs 
     433     
     434    def _set_kwargs(self, kwargs): 
     435        self._kwargs = kwargs 
     436     
     437    kwargs = property(_get_kwargs, _set_kwargs, 
     438                      doc='page handler kwargs (with ' 
     439                      'cherrypy.request.params copied in)') 
    432440 
    433441 

Hosted by WebFaction

Log in as guest/cpguest to create tickets