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

Changeset 706

Show
Ignore:
Timestamp:
10/03/05 01:54:02
Author:
fumanchu
Message:

More updates to apireference.xml (CherryPy library).

Files:

Legend:

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

    r705 r706  
    354354    </section> 
    355355    <section id="lib"> 
    356         <title>CherryPy included library functions</title> 
     356        <title>The CherryPy library</title> 
    357357        <section> 
    358358            <title>cherrypy.lib.cptools</title> 
    359359            <section> 
    360360                <title>ExposeItems</title> 
    361                 <para /> 
     361                <para>Utility class that exposes a getitem-aware object. It does not provide index() 
     362                or default() methods, and it does not expose the individual item objects - just the 
     363                list or dict that contains them. User-specific index() and default() methods can be 
     364                implemented by inheriting from this class.</para> 
    362365            </section> 
    363366            <section> 
    364367                <title>PositionalParametersAware</title> 
    365                 <para /> 
     368                <para>Utility class that restores positional parameters functionality that was found 
     369                in 2.0.0-beta.</para> 
    366370            </section> 
     371            <section> 
     372                <title>getRanges(content_length)</title> 
     373                <para>Returns a list of (start, stop) indices from a Range request header. Returns 
     374                None if no such header is provided in the request. Each (start, stop) tuple will be 
     375                composed of two ints, which are suitable for use in a slicing operation. That is, the 
     376                header "Range: bytes=3-6", if applied against a Python string, is requesting 
     377                resource[3:7]. This function will return the list [(3, 7)].</para> 
     378            </section> 
     379            <section> 
     380                <title>serveFile(path, contentType=None, disposition=None, name=None)</title> 
     381                <para>Set status, headers, and body in order to serve the file at the given path. The 
     382                Content-Type header will be set to the contentType arg, if provided. If not provided, 
     383                the Content-Type will be guessed by the extension of the file. If disposition is not 
     384                None, the Content-Disposition header will be set to "&lt;disposition&gt;; 
     385                filename=&lt;name&gt;". If name is None, it will be set to the basename of path. If 
     386                disposition is None, no Content-Disposition header will be written.</para> 
     387            </section> 
     388        </section> 
     389        <section> 
     390            <title>cherrypy.lib.covercp</title> 
     391            <para>This module both provides code-coverage tools, and may also be run as a script. To 
     392            use this module, or the coverage tools in the test suite, you need to download 
     393            'coverage.py', either Gareth Rees' <ulink url="???">original implementation</ulink> or 
     394            Ned Batchelder's <ulink 
     395            url="http://www.nedbatchelder.com/code/modules/coverage.html">enhanced 
     396            version</ulink>.</para> 
     397            <para>Set cherrypy.codecoverage to True to turn on coverage tracing. Then, use the 
     398            covercp.serve() function to browse the results in a web browser. If you run this module 
     399            as a script (i.e., from the command line), it will call serve() for you.</para> 
     400        </section> 
     401        <section> 
     402            <title>cherrypy.lib.profiler</title> 
     403            <para>You can profile any of your page handlers (exposed methods) as follows:</para> 
     404            <example> 
     405                <title>Profiling example</title> 
     406                <para> 
     407                    <code>from cherrypy.lib import profile class Root: p = 
     408                    profile.Profiler("/path/to/profile/dir") def index(self): self.p.run(self._index) 
     409                    index.exposed = True def _index(self): return "Hello, world!" cherrypy.root = 
     410                    Root()</code> 
     411                     
     412                </para> 
     413            </example> 
     414            <para>Set the config entry: "profiling.on = True" if you'd rather turn on profiling for 
     415            all requests. Then, use the serve() function to browse the results in a web browser. If 
     416            you run this module as a script (i.e., from the command line), it will call serve() for 
     417            you.</para> 
     418            <para>Developers: this module should be used whenever you make significant changes to 
     419            CherryPy, to get a quick sanity-check on the performance of the request process. Basic 
     420            requests should complete in about 5 milliseconds on a reasonably-fast machine running 
     421            Python 2.4 (Python 2.3 will be much slower due to threadlocal being implemented in 
     422            Python, not C). You can profile the test suite by supplying the --profile option to 
     423            test.py.</para> 
    367424        </section> 
    368425    </section> 

Hosted by WebFaction

Log in as guest/cpguest to create tickets