Django

Code

Changeset 5744

Show
Ignore:
Timestamp:
07/21/07 22:09:24 (1 year ago)
Author:
gwilson
Message:

Added docstrings to shortcuts module and functions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/shortcuts/__init__.py

    r5511 r5744  
    1 # This module collects helper functions and classes that "span" multiple levels 
    2 # of MVC. In other words, these functions/classes introduce controlled coupling 
    3 # for convenience's sake. 
     1""" 
     2This module collects helper functions and classes that "span" multiple levels 
     3of MVC. In other words, these functions/classes introduce controlled coupling 
     4for convenience's sake. 
     5""" 
    46 
    57from django.template import loader 
     
    810 
    911def render_to_response(*args, **kwargs): 
     12    """ 
     13    Return a HttpResponse whose content is filled with the result of calling 
     14    django.template.loader.render_to_string() with the passed arguments. 
     15    """ 
    1016    return HttpResponse(loader.render_to_string(*args, **kwargs)) 
    1117load_and_render = render_to_response # For backwards compatibility. 
    1218 
    1319def get_object_or_404(klass, *args, **kwargs): 
     20    """ 
     21    Use get() to return an object, or raise a Http404 exception if the object 
     22    does not exist. 
     23 
     24    klass may be a Model, Manager, or QuerySet object.  All other passed 
     25    arguments and keyword arguments are used in the get() query. 
     26 
     27    Note: Like with get(), an AssertionError will be raised if more than one 
     28    object is found. 
     29    """ 
    1430    if isinstance(klass, Manager): 
    1531        manager = klass 
     
    2339 
    2440def get_list_or_404(klass, *args, **kwargs): 
     41    """ 
     42    Use filter() to return a list of objects, or raise a Http404 exception if 
     43    the list is empty. 
     44 
     45    klass may be a Model, Manager, or QuerySet object.  All other passed 
     46    arguments and keyword arguments are used in the filter() query. 
     47    """ 
    2548    if isinstance(klass, Manager): 
    2649        manager = klass