Changeset 1604
- Timestamp:
- 01/21/07 21:50:48
- Files:
-
- trunk/cherrypy/_cpdispatch.py (modified) (1 diff)
- trunk/cherrypy/_cprequest.py (modified) (13 diffs)
- trunk/cherrypy/lib/http.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpdispatch.py
r1597 r1604 1 """CherryPy dispatchers.""" 1 """CherryPy dispatchers. 2 3 A 'dispatcher' is the object which looks up the 'page handler' callable 4 and collects config for the current request based on the path_info, other 5 request attributes, and the application architecture. The core calls the 6 dispatcher as early as possible, passing it a 'path_info' argument. 7 8 The default dispatcher discovers the page handler by matching path_info 9 to a hierarchical arrangement of objects, starting at request.app.root. 10 """ 2 11 3 12 import cherrypy trunk/cherrypy/_cprequest.py
r1602 r1604 19 19 20 20 callback = None 21 callback__doc = """The bare callable that this Hook object is wrapping. 22 This will be called when the Hook is called.""" 21 callback__doc = """ 22 The bare callable that this Hook object is wrapping, which will 23 be called when the Hook is called.""" 23 24 24 25 failsafe = False 25 failsafe__doc = """If True, the callback is guaranteed to run even if 26 other callbacks from the same call point raise exceptions.""" 26 failsafe__doc = """ 27 If True, the callback is guaranteed to run even if other callbacks 28 from the same call point raise exceptions.""" 27 29 28 30 priority = 50 29 priority__doc = """Defines the order of execution for a list of Hooks. 30 Priority numbers should be limited to the closed interval [0, 100], but 31 values outside this range are acceptable, as are fractional values.""" 31 priority__doc = """ 32 Defines the order of execution for a list of Hooks. Priority numbers 33 should be limited to the closed interval [0, 100], but values outside 34 this range are acceptable, as are fractional values.""" 32 35 33 36 kwargs = {} 34 kwargs__doc = """A set of keyword arguments that will be passed 35 to the callable on each call.""" 37 kwargs__doc = """ 38 A set of keyword arguments that will be passed to the 39 callable on each call.""" 36 40 37 41 def __init__(self, callback, failsafe=None, priority=None, **kwargs): … … 105 109 return newmap 106 110 copy = __copy__ 111 112 def __repr__(self): 113 cls = self.__class__ 114 return "%s.%s(points=%r)" % (cls.__module__, cls.__name__, self.keys()) 107 115 108 116 … … 180 188 181 189 base = "" 182 base__doc = """The 'base' (scheme +host) portion of the requested URL."""190 base__doc = """The (scheme://host) portion of the requested URL.""" 183 191 184 192 # Request-Line attributes 185 193 request_line = "" 186 194 request_line__doc = """ 187 The complete Request Line received from the client. This is a195 The complete Request-Line received from the client. This is a 188 196 single string consisting of the request method, URI, and protocol 189 197 version (joined by spaces). Any final CRLF is removed.""" … … 201 209 The query component of the Request-URI, a string of information to be 202 210 interpreted by the resource. The query portion of a URI follows the 203 path component, and is s pearated by a '?'. For example, the URI211 path component, and is separated by a '?'. For example, the URI 204 212 'http://www.cherrypy.org/wiki?a=3&b=4' has the query component, 205 213 'a=3&b=4'.""" … … 227 235 228 236 headers = http.HeaderMap() 237 headers__doc = """ 238 A dict-like object containing the request headers. Keys are header 239 names (in Title-Case format); however, you may get and set them in 240 a case-insensitive manner. That is, headers['Content-Type'] and 241 headers['content-type'] refer to the same value. Values are header 242 values (decoded according to RFC 2047 if necessary). See also: 243 http.HeaderMap, http.HeaderElement.""" 244 229 245 cookie = Cookie.SimpleCookie() 246 cookie__doc = """See help(Cookie).""" 230 247 231 248 rfile = None … … 269 286 # Dispatch attributes 270 287 dispatch = cherrypy.dispatch.Dispatcher() 288 dispatch__doc = """ 289 The object which looks up the 'page handler' callable and collects 290 config for the current request based on the path_info, other 291 request attributes, and the application architecture. The core 292 calls the dispatcher as early as possible, passing it a 'path_info' 293 argument. 294 295 The default dispatcher discovers the page handler by matching path_info 296 to a hierarchical arrangement of objects, starting at request.app.root. 297 See help(cherrypy.dispatch) for more information.""" 271 298 272 299 script_name = "" … … 281 308 282 309 app = None 283 app__doc = """The Application object which is handling this request.""" 310 app__doc = \ 311 """The cherrypy.Application object which is handling this request.""" 284 312 285 313 handler = None … … 310 338 is_index__doc = """ 311 339 This will be True if the current request is mapped to an 'index' 312 resource handler ( ora 'default' handler if path_info ends with340 resource handler (also, a 'default' handler if path_info ends with 313 341 a slash). The value may be used to automatically redirect the 314 342 user-agent to a 'more canonical' URL which either adds or removes … … 316 344 317 345 hooks = HookMap(hookpoints) 346 hooks__doc = """ 347 A HookMap (dict-like object) of the form: {hookpoint: [hook, ...]}. 348 Each key is a str naming the hook point, and each value is a list 349 of hooks which will be called at that hook point during this request. 350 The list of hooks is generally populated as early as possible (mostly 351 from Tools specified in config), but may be extended at any time. 352 See also: _cprequest.Hook, _cprequest.HookMap, and cherrypy.tools.""" 318 353 319 354 error_response = cherrypy.HTTPError(500).set_response 320 355 error_response__doc = """ 321 The callable which will handle unexpected errors during request 322 processing. By default, it uses HTTPError(500) to return an error 323 response to the user-agent.""" 356 The no-arg callable which will handle unexpected, untrapped errors 357 during request processing. This is not used for expected exceptions 358 (like NotFound, HTTPError, or HTTPRedirect) which are raised in 359 response to expected conditions (those should be customized either 360 via request.error_page or by overriding HTTPError.set_response). 361 By default, error_response uses HTTPError(500) to return a generic 362 error response to the user-agent.""" 324 363 325 364 error_page = {} … … 327 366 A dict of {error code: response filename} pairs. The named response 328 367 files should be Python string-formatting templates, and can expect by 329 default to receive the keyword-formatted values 'status', 'message',330 ' traceback', and 'version'. The set of keyword values can be extended331 by overriding HTTPError.set_response."""368 default to receive the format values with the mapping keys 'status', 369 'message', 'traceback', and 'version'. The set of format mappings 370 can be extended by overriding HTTPError.set_response.""" 332 371 333 372 show_tracebacks = True … … 337 376 338 377 throws = (KeyboardInterrupt, SystemExit, cherrypy.InternalRedirect) 339 throws__doc = """The sequence of exceptions which Request.run does not trap.""" 378 throws__doc = \ 379 """The sequence of exceptions which Request.run does not trap.""" 340 380 341 381 throw_errors = False … … 685 725 # Class attributes for dev-time introspection. 686 726 status = "" 727 status__doc = """The HTTP Status-Code and Reason-Phrase.""" 728 687 729 header_list = [] 730 header_list__doc = """ 731 A list of the HTTP response headers as (name, value) tuples. 732 In general, you should use response.headers (a dict) instead.""" 733 688 734 headers = http.HeaderMap() 735 headers__doc = """ 736 A dict-like object containing the response headers. Keys are header 737 names (in Title-Case format); however, you may get and set them in 738 a case-insensitive manner. That is, headers['Content-Type'] and 739 headers['content-type'] refer to the same value. Values are header 740 values (decoded according to RFC 2047 if necessary). See also: 741 http.HeaderMap, http.HeaderElement.""" 742 689 743 cookie = Cookie.SimpleCookie() 744 cookie__doc = """See help(Cookie).""" 745 690 746 body = Body() 747 body__doc = """The body (entity) of the HTTP response.""" 748 691 749 time = None 750 time__doc = """The value of time.time() when created. Use in HTTP dates.""" 751 692 752 timeout = 300 753 timeout__doc = """Seconds after which the response will be aborted.""" 754 693 755 timed_out = False 756 timed_out__doc = """ 757 Flag to indicate the response should be aborted, because it has 758 exceeded its timeout.""" 759 694 760 stream = False 761 stream__doc = """If False, buffer the response body.""" 695 762 696 763 def __init__(self): … … 711 778 712 779 def collapse_body(self): 780 """Iterate over self.body, replacing it with and returning the result.""" 713 781 newbody = ''.join([chunk for chunk in self.body]) 714 782 self.body = newbody trunk/cherrypy/lib/http.py
r1602 r1604 329 329 Each key is changed on entry to str(key).title(). This allows headers 330 330 to be case-insensitive and avoid duplicates. 331 332 Values are header values (decoded according to RFC 2047 if necessary). 331 333 """ 332 334

