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

Changeset 781

Show
Ignore:
Timestamp:
11/02/05 19:19:04
Author:
fumanchu
Message:

Docs: more 2.2 updates: cptools, server.request, special attributes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docs/book/xml/apireference.xml

    r753 r781  
    177177            Instead, it should be used to determine which features are <emphasis>available</emphasis> 
    178178            for the response. For example, an HTTP server may send an HTTP/1.1 response even though 
    179             the client is known to only understand HTTP/1.0the response.version will be set to 
     179            the client is known to only understand HTTP/1.0—the response.version will be set to 
    180180            Version("1.0") to inform you of this, so that you (and CherryPy) can restrict the 
    181181            response to HTTP/1.0 features only.</para> 
     
    280280        <section> 
    281281            <title>cherrypy.server.stop()</title> 
    282             <para>Stop the CherryPy Server. Well, "suspend" might be a better termthis doesn't 
     282            <para>Stop the CherryPy Server. Well, "suspend" might be a better term—this doesn't 
    283283            terminate the process.</para> 
    284284        </section> 
     
    314314        <section> 
    315315            <title>cherrypy.server.request()</title> 
    316             <para>HTTP servers should call this function to hand off the HTTP request to the CherryPy 
    317             core. There is no return value; instead, the core sets response content in the 
    318             cherrypy.response object.</para> 
     316            <para>HTTP servers should call this function to create a new Request and Response object. 
     317            The return value is the Request object; call its <code>run</code> method to have the 
     318            CherryPy core process the request data and populate the response.</para> 
    319319        </section> 
    320320    </section> 
     
    341341            file.</para> 
    342342        </section> 
     343        <section> 
     344            <title>cherrypy.config.environments</title> 
     345            <para>Dict containing config defaults for each named server.environment.</para> 
     346        </section> 
    343347    </section> 
    344348    <section id="exceptions"> 
     
    351355                <title>cherrypy.NotFound</title> 
    352356                <para>This exception is raised when CherryPy is unable to map a requested path to an 
    353                 internal method. It's a subclass of HTTPError.</para> 
     357                internal method. It's a subclass of HTTPError (404).</para> 
    354358            </section> 
    355359        </section> 
     
    379383                <para>Utility class that restores positional parameters functionality that was found 
    380384                in 2.0.0-beta.</para> 
     385            </section> 
     386            <section> 
     387                <title>getAccept(headername)</title> 
     388                <para>Returns a list of AcceptValue objects from the specified Accept-* header (or 
     389                None if the header is not present). The list is sorted so that the most-preferred 
     390                values are first in the list.</para> 
     391                <para>Each AcceptValue object has a <code>value</code> attribute, a string which is 
     392                the value itself. For example, if <code>headername</code> is "Accept-Encoding", the 
     393                <code>value</code> attribute might be "gzip". It also has a (read-only) 
     394                <code>qvalue</code> attribute, a float between 0 and 1 which specifies the client's 
     395                preference for the value; higher numbers are preferred. Finally, each AcceptValue 
     396                also has a <code>params</code> attribute, a dict; for most headers, this dict will 
     397                only possess the original "q" value as a string.</para> 
     398                <para>If <code>headername</code> is "Accept" (the default), then the params attribute 
     399                may contain extra parameters which further differentiate the value. In addition, 
     400                <code>params["q"]</code> may itself be an AcceptValue object, with its own 
     401                <code>params</code> dict. Don't ask us why; ask the authors of the HTTP spec.</para> 
    381402            </section> 
    382403            <section> 
     
    387408                header "Range: bytes=3-6", if applied against a Python string, is requesting 
    388409                resource[3:7]. This function will return the list [(3, 7)].</para> 
     410            </section> 
     411            <section> 
     412                <title>HeaderMap</title> 
     413                <para>A subclass of Python's builtin <code>dict</code> class; CherryPy's default 
     414                <code>request.headerMap</code> and <code>response.headerMap</code> objects are 
     415                instances of this class. The keys are automatically titled 
     416                (<code>str(key).title()</code>) in order to provide case-insensitive comparisons and 
     417                avoid duplicates.</para> 
     418            </section> 
     419            <section> 
     420                <title>parseRequestLine(requestLine)</title> 
     421                <para>Returns (<code>method, path, querystring, protocol</code>) from an HTTP 
     422                requestLine. The default Request processor calls this function.</para> 
     423            </section> 
     424            <section> 
     425                <title>parseQueryString(queryString, keep_blank_values=True)</title> 
     426                <para>Returns a dict of <code>{'key': 'value'}</code> pairs from an HTTP "key=value" 
     427                query string. Also handles server-side image map query strings. The default Request 
     428                processor calls this function.</para> 
     429            </section> 
     430            <section> 
     431                <title>paramsFromCGIForm(form)</title> 
     432                <para>Returns a dict of <code>{'key': ''value'}</code> pairs from a 
     433                <code>cgi.FieldStorage</code> object. The default Request processor calls this 
     434                function.</para> 
    389435            </section> 
    390436            <section> 
     
    461507            <title>_cpOnError</title> 
    462508            <para>_cpOnError is a function for handling unanticipated exceptions, whether raised by 
    463             CherryPy itself, or in user applications. The default simply raises 
    464             HTTPError(500).</para> 
     509            CherryPy itself, or in user applications. The default simply responds as if 
     510            HTTPError(500) had been raised.</para> 
     511        </section> 
     512        <section> 
     513            <title>_cpOnHTTPError</title> 
     514            <para>_cpOnHTTPError handles HTTPError responses, setting cherrypy.response.status, 
     515            headers, and body.</para> 
    465516        </section> 
    466517        <section> 
     
    470521            class.</para> 
    471522        </section> 
     523        <section> 
     524            <title>_cpLogAccess</title> 
     525            <para>Function to log HTTP requests into the access.log file.</para> 
     526        </section> 
     527        <section> 
     528            <title>_cpLogMessage</title> 
     529            <para>Function to log errors into the error.log file. The <code>cherrypy.log</code> 
     530            function is syntactic sugar for this one.</para> 
     531        </section> 
    472532    </section> 
    473533    <section id="filters"> 

Hosted by WebFaction

Log in as guest/cpguest to create tickets