Changeset 5728

Show
Ignore:
Timestamp:
11/19/08 17:29:52 (2 months ago)
Author:
carndt
Message:

Fixup docstring for controllers.url and RESTMethod

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/turbogears/controllers.py

    r5727 r5728  
    506506 
    507507class ExposedDescriptor(object): 
    508     """Descriptor used by RESTMethod to tell if it is exposed 
    509     """ 
     508    """Descriptor used by RESTMethod to tell if it is exposed.""" 
     509 
    510510    def __get__(self, obj, cls=None): 
    511         """Return True if the object has a method for the HTTP method of the current request 
     511        """Return True if object has a method for HTTP method of current request 
    512512        """ 
    513513        if cls is None: cls = obj 
     
    522522 
    523523class RESTMethod(object): 
    524     """Allows REST style dispatch based on different HTTP methods 
    525  
    526     For an example usage see turbogears.tests.test_restmethod 
     524    """Allow REST style dispatch based on different HTTP methods. 
     525 
     526    For an elaborate usage example see turbogears.tests.test_restmethod. 
     527 
     528    In short, instead of an exposed method, you define a sub-class of 
     529    RESTMethod inside the controller class and inside this class you define 
     530    exposed methods named after each HTTP method that should be supported. 
     531 
     532    Example:: 
     533 
     534        class Controller(controllers.Controller): 
     535 
     536            class article(copntrollers.RESTMethod): 
     537                @expose() 
     538                def get(self, id): 
     539                    ... 
     540 
     541                @expose() 
     542                def post(self, id): 
     543                    ... 
     544 
    527545    """ 
    528546    exposed = ExposedDescriptor() 
     
    537555 
    538556def url(tgpath, tgparams=None, **kw): 
    539     """Computes URLs. 
    540  
    541     tgpath can be a list or a string. If the path is absolute (starts 
    542     with a "/"), the server.webpath, SCRIPT_NAME and the approot of the 
    543     application are prepended to the path. In order for the approot to 
    544  
    545     be detected properly, the root object should extend 
    546  
    547     controllers.RootController. 
     557    """Computes relocatable URLs. 
     558 
     559    tgpath can be a list or a string. If the path is absolute (starts with a 
     560    "/"), the server.webpath, SCRIPT_NAME and the approot of the application 
     561    are prepended to the path. In order for the approot to be detected 
     562    properly, the root object must extend controllers.RootController. 
    548563 
    549564    Query parameters for the URL can be passed in as a dictionary in 
    550     the second argument *or* as keyword parameters. 
     565    the second argument and/or as keyword parameters where keyword args 
     566    overwrite entries in the dictionary. 
    551567 
    552568    Values which are a list or a tuple are used to create multiple 
    553569    key-value pairs. 
     570 
     571    tgpath may also already contain a (properly escaped) query string seperated 
     572    by a question mark ('?'), in which case additional query params are 
     573    appended. 
    554574 
    555575    """