# cherrypy package

## Subpackages

- cherrypy.lib package
  - Submodules
    - cherrypy.lib.auth_basic module
      - `_try_decode()`
      - `basic_auth()`
      - `checkpassword_dict()`
    - cherrypy.lib.auth_digest module
      - `H()`
      - `HttpDigestAuthorization`
      - `TRACE()`
      - `_get_charset_declaration()`
      - `_respond_401()`
      - `_try_decode_header()`
      - `digest_auth()`
      - `get_ha1_dict()`
      - `get_ha1_dict_plain()`
      - `get_ha1_file_htdigest()`
      - `md5_hex()`
      - `synthesize_nonce()`
      - `www_authenticate()`
    - cherrypy.lib.caching module
      - Usage
      - `AntiStampedeCache`
      - `Cache`
      - `MemoryCache`
      - `expires()`
      - `get()`
      - `tee_output()`
    - cherrypy.lib.covercp module
      - `CoverStats`
      - `_graft()`
      - `_percent()`
      - `_show_branch()`
      - `_skip_file()`
      - `get_tree()`
      - `serve()`
      - `start()`
    - cherrypy.lib.cpstats module
      - Overview
      - Usage
      - `ByteCountWrapper`
      - `StatsPage`
      - `StatsTool`
      - `_get_threading_ident()`
      - `average_uriset_time()`
      - `extrapolate_statistics()`
      - `iso_format()`
      - `locale_date()`
      - `pause_resume()`
      - `proc_time()`
    - cherrypy.lib.cptools module
      - `MonitoredHeaderMap`
      - `SessionAuth`
      - `accept()`
      - `allow()`
      - `autovary()`
      - `convert_params()`
      - `flatten()`
      - `ignore_headers()`
      - `log_hooks()`
      - `log_request_headers()`
      - `log_traceback()`
      - `proxy()`
      - `redirect()`
      - `referer()`
      - `response_headers()`
      - `session_auth()`
      - `trailing_slash()`
      - `validate_etags()`
      - `validate_since()`
    - cherrypy.lib.encoding module
      - `ResponseEncoder`
      - `UTF8StreamEncoder`
      - `compress()`
      - `decode()`
      - `decompress()`
      - `gzip()`
      - `prepare_iter()`
    - cherrypy.lib.gctools module
      - `GCRoot`
      - `ReferrerTree`
      - `RequestCounter`
      - `get_context()`
      - `get_instances()`
    - cherrypy.lib.headers module
      - `_parse_param()`
      - `parse_header()`
    - cherrypy.lib.httputil module
      - `AcceptElement`
      - `CaseInsensitiveDict`
      - `HeaderElement`
      - `HeaderMap`
      - `Host`
      - `SanitizedHost`
      - `_parse_qs()`
      - `decode_TEXT()`
      - `decode_TEXT_maybe()`
      - `get_ranges()`
      - `header_elements()`
      - `parse_query_string()`
      - `protocol_from_http()`
      - `urljoin()`
      - `urljoin_bytes()`
      - `valid_status()`
    - cherrypy.lib.jsontools module
      - `json_handler()`
      - `json_in()`
      - `json_out()`
      - `json_processor()`
    - cherrypy.lib.locking module
      - `LockChecker`
      - `LockTimeout`
      - `NeverExpires`
      - `Timer`
    - cherrypy.lib.profiler module
      - CherryPy users
      - CherryPy developers
      - `ProfileAggregator`
      - `Profiler`
      - `make_app`
      - `new_func_strip_path()`
      - `serve()`
    - cherrypy.lib.reprconf module
      - Namespaces
      - `Config`
      - `NamespaceSet`
      - `Parser`
      - `_Builder`
      - `attributes()`
      - `modules()`
      - `unrepr()`
    - cherrypy.lib.sessions module
      - Locking sessions
      - Expiring Sessions
      - Session Fixation Protection
      - Sharing Sessions
      - Expiration Dates
      - `FileSession`
      - `MemcachedSession`
      - `RamSession`
      - `Session`
      - `_add_MSIE_max_age_workaround()`
      - `close()`
      - `expire()`
      - `init()`
      - `save()`
      - `set_response_cookie()`
    - cherrypy.lib.static module
      - `_attempt()`
      - `_make_content_disposition()`
      - `_serve_fileobj()`
      - `_setup_mimetypes()`
      - `serve_download()`
      - `serve_file()`
      - `serve_fileobj()`
      - `staticdir()`
      - `staticfile()`
    - cherrypy.lib.xmlrpcutil module
      - `_set_response()`
      - `on_error()`
      - `patched_path()`
      - `process_body()`
      - `respond()`
  - Module contents
    - `file_generator`
      - `file_generator.next()`
    - `file_generator_limited()`
    - `is_closable_iterator()`
    - `is_iterator()`
    - `set_vary_header()`
- cherrypy.process package
  - Submodules
    - cherrypy.process.plugins module
      - `Autoreloader`
      - `BackgroundTask`
      - `Daemonizer`
      - `DropPrivileges`
      - `Monitor`
      - `PIDFile`
      - `PerpetualTimer`
      - `SignalHandler`
      - `SimplePlugin`
      - `ThreadManager`
    - cherrypy.process.servers module
      - Multiple servers/ports
      - FastCGI/SCGI
      - `FlupCGIServer`
      - `FlupFCGIServer`
      - `FlupSCGIServer`
      - `ServerAdapter`
      - `Timeouts`
      - `_safe_wait()`
    - cherrypy.process.win32 module
      - `ConsoleCtrlHandler`
      - `PyWebService`
      - `Win32Bus`
      - `_ControlCodes`
      - `signal_child()`
    - cherrypy.process.wspbus module
      - Web Site Process Bus
      - `Bus`
      - `ChannelFailures`
      - `_StateEnum`
  - Module contents
- cherrypy.scaffold package
  - Module contents
    - `Root`
      - `Root._cp_config`
      - `Root.default()`
      - `Root.files()`
      - `Root.index()`
      - `Root.other()`
- cherrypy.test package
  - Submodules
    - cherrypy.test._test_decorators module
      - `ExposeExamples`
      - `ToolExamples`
    - cherrypy.test._test_states_demo module
      - `Root`
    - cherrypy.test.benchmark module
      - `ABSession`
      - `Root`
      - `print_report()`
      - `run_standard_benchmarks()`
      - `size_report()`
      - `thread_report()`
    - cherrypy.test.checkerdemo module
      - `Root`
    - cherrypy.test.helper module
      - `CPProcess`
      - `CPWebCase`
      - `LocalSupervisor`
      - `LocalWSGISupervisor`
      - `NativeServerSupervisor`
      - `Supervisor`
      - `_test_method_sorter()`
      - `get_cpmodpy_supervisor()`
      - `get_modfastcgi_supervisor()`
      - `get_modfcgid_supervisor()`
      - `get_modpygw_supervisor()`
      - `get_modwsgi_supervisor()`
      - `get_wsgi_u_supervisor()`
      - `log_to_stderr()`
      - `setup_client()`
    - cherrypy.test.logtest module
      - `LogCase`
      - `getchar()`
    - cherrypy.test.modfastcgi module
      - KNOWN BUGS
      - `ModFCGISupervisor`
      - `erase_script_name()`
      - `read_process()`
    - cherrypy.test.modfcgid module
      - KNOWN BUGS
      - `ModFCGISupervisor`
      - `read_process()`
    - cherrypy.test.modpy module
      - KNOWN BUGS
      - `ModPythonSupervisor`
      - `cpmodpysetup()`
      - `read_process()`
      - `wsgisetup()`
    - cherrypy.test.modwsgi module
      - KNOWN BUGS
      - `ModWSGISupervisor`
      - `application()`
      - `read_process()`
    - cherrypy.test.sessiondemo module
      - `Root`
    - cherrypy.test.test_auth_basic module
      - `BasicAuthTest`
    - cherrypy.test.test_auth_digest module
      - `DigestAuthTest`
      - `_fetch_users()`
    - cherrypy.test.test_bus module
      - `bus()`
      - `listener()`
      - `log_tracker()`
      - `test_block()`
      - `test_builtin_channels()`
      - `test_custom_channels()`
      - `test_exit()`
      - `test_graceful()`
      - `test_listener_errors()`
      - `test_log()`
      - `test_start()`
      - `test_start_with_callback()`
      - `test_stop()`
      - `test_wait()`
      - `test_wait_publishes_periodically()`
    - cherrypy.test.test_caching module
      - `CacheTest`
    - cherrypy.test.test_config module
      - `CallablesInConfigTest`
      - `ConfigTests`
      - `StringIOFromNative()`
      - `VariableSubstitutionTests`
      - `setup_server()`
    - cherrypy.test.test_config_server module
      - `ServerConfigTests`
    - cherrypy.test.test_conn module
      - `BadRequestTests`
      - `ConnectionCloseTests`
      - `ConnectionTests`
      - `LimitedRequestQueueTests`
      - `PipelineTests`
      - `setup_server()`
      - `setup_upload_server()`
      - `socket_reset_errors`
    - cherrypy.test.test_core module
      - `CoreRequestHandlingTest`
      - `ErrorTests`
      - `TestBinding`
    - cherrypy.test.test_dynamicobjectmapping module
      - `DynamicObjectMappingTest`
      - `setup_server()`
    - cherrypy.test.test_encoding module
      - `EncodingTests`
    - cherrypy.test.test_etags module
      - `ETagTest`
    - cherrypy.test.test_http module
      - `HTTPTests`
      - `encode_filename()`
      - `encode_multipart_formdata()`
      - `is_ascii()`
    - cherrypy.test.test_httputil module
      - `test_invalid_status()`
      - `test_urljoin()`
      - `test_valid_status()`
    - cherrypy.test.test_iterator module
      - `IteratorBase`
      - `IteratorTest`
      - `OurClosableIterator`
      - `OurGenerator`
      - `OurIterator`
      - `OurNotClosableIterator`
      - `OurUnclosableIterator`
    - cherrypy.test.test_json module
      - `JsonTest`
    - cherrypy.test.test_logging module
      - `access_log_file()`
      - `configure_server()`
      - `error_log_file()`
      - `log_tracker()`
      - `server()`
      - `shutdown_server()`
      - `test_UUIDv4_parameter_log_format()`
      - `test_custom_log_format()`
      - `test_escaped_output()`
      - `test_normal_return()`
      - `test_normal_yield()`
      - `test_timez_log_format()`
      - `test_tracebacks()`
      - `test_utc_in_timez()`
    - cherrypy.test.test_mime module
      - `MultipartTest`
      - `SafeMultipartHandlingTest`
      - `setup_server()`
    - cherrypy.test.test_misc_tools module
      - `AcceptTest`
      - `AutoVaryTest`
      - `RefererTest`
      - `ResponseHeadersTest`
      - `setup_server()`
    - cherrypy.test.test_native module
      - `cp_native_server()`
      - `test_basic_request()`
    - cherrypy.test.test_objectmapping module
      - `ObjectMappingTest`
    - cherrypy.test.test_params module
      - `ParamsTest`
    - cherrypy.test.test_plugins module
      - `TestAutoreloader`
    - cherrypy.test.test_proxy module
      - `ProxyTest`
    - cherrypy.test.test_refleaks module
      - `ReferenceTests`
    - cherrypy.test.test_request_obj module
      - `RequestObjectTests`
    - cherrypy.test.test_routes module
      - `RoutesDispatchTest`
    - cherrypy.test.test_session module
      - `MemcachedSessionTest`
      - `SessionTest`
      - `http_methods_allowed()`
      - `is_memcached_present()`
      - `memcached_client_present()`
      - `memcached_configured()`
      - `memcached_instance()`
      - `memcached_server_present()`
      - `setup_server()`
    - cherrypy.test.test_sessionauthenticate module
      - `SessionAuthenticateTest`
    - cherrypy.test.test_states module
      - `Dependency`
      - `PluginTests`
      - `ServerStateTests`
      - `SignalHandlingTests`
      - `setup_server()`
      - `test_safe_wait_INADDR_ANY()`
    - cherrypy.test.test_static module
      - `StaticTest`
      - `_check_unicode_filesystem()`
      - `ensure_unicode_filesystem()`
      - `error_page_404()`
      - `unicode_filesystem()`
    - cherrypy.test.test_tools module
      - `SessionAuthTest`
      - `TestHooks`
      - `ToolTests`
    - cherrypy.test.test_tutorials module
      - `TutorialTest`
    - cherrypy.test.test_virtualhost module
      - `VirtualHostTest`
    - cherrypy.test.test_wsgi_ns module
      - `WSGI_Namespace_Test`
    - cherrypy.test.test_wsgi_unix_socket module
      - `USocketHTTPConnection`
      - `WSGI_UnixSocket_Test`
      - `usocket_path()`
    - cherrypy.test.test_wsgi_vhost module
      - `WSGI_VirtualHost_Test`
    - cherrypy.test.test_wsgiapps module
      - `WSGIGraftTests`
    - cherrypy.test.test_xmlrpc module
      - `XmlRpcTest`
      - `setup_server()`
    - cherrypy.test.webtest module
  - Module contents
    - `newexit()`
    - `setup()`
    - `teardown()`
- cherrypy.tutorial package
  - Submodules
    - cherrypy.tutorial.tut01_helloworld module
      - `HelloWorld`
    - cherrypy.tutorial.tut02_expose_methods module
      - `HelloWorld`
    - cherrypy.tutorial.tut03_get_and_post module
      - `WelcomePage`
    - cherrypy.tutorial.tut04_complex_site module
      - `ExtraLinksPage`
      - `HomePage`
      - `JokePage`
      - `LinksPage`
    - cherrypy.tutorial.tut05_derived_objects module
      - `AnotherPage`
      - `HomePage`
      - `Page`
    - cherrypy.tutorial.tut06_default_method module
      - `UsersPage`
    - cherrypy.tutorial.tut07_sessions module
      - `HitCounter`
    - cherrypy.tutorial.tut08_generators_and_yield module
      - `GeneratorDemo`
    - cherrypy.tutorial.tut09_files module
      - Uploads
      - Downloads
      - `FileDemo`
    - cherrypy.tutorial.tut10_http_errors module
      - `HTTPErrorDemo`
  - Module contents

## Submodules

- cherrypy.__main__ module
- cherrypy._cpchecker module
  - `Checker`
    - `Checker._compat()`
    - `Checker._known_ns()`
    - `Checker._known_types()`
    - `Checker._populate_known_types()`
    - `Checker.check_app_config_brackets()`
    - `Checker.check_app_config_entries_dont_start_with_script_name()`
    - `Checker.check_compatibility()`
    - `Checker.check_config_namespaces()`
    - `Checker.check_config_types()`
    - `Checker.check_localhost()`
    - `Checker.check_site_config_entries_in_app_config()`
    - `Checker.check_skipped_app_config()`
    - `Checker.check_static_paths()`
    - `Checker.deprecated`
    - `Checker.extra_config_namespaces`
    - `Checker.formatwarning()`
    - `Checker.global_config_contained_paths`
    - `Checker.known_config_types`
    - `Checker.obsolete`
    - `Checker.on`
- cherrypy._cpcompat module
  - `assert_native()`
  - `ntob()`
  - `ntou()`
  - `tonative()`
- cherrypy._cpconfig module
  - Architecture
  - Declaration
  - Namespaces
  - `Config`
    - `Config._apply()`
    - `Config.environments`
    - `Config.update()`
  - `_Vars`
    - `_Vars.setdefault()`
  - `_engine_namespace_handler()`
  - `_if_filename_register_autoreload()`
  - `_server_namespace_handler()`
  - `_tree_namespace_handler()`
  - `merge()`
- cherrypy._cpdispatch module
  - `Dispatcher`
    - `Dispatcher.dispatch_method_name`
    - `Dispatcher.find_handler()`
  - `LateParamPageHandler`
    - `LateParamPageHandler.kwargs`
  - `MethodDispatcher`
  - `PageHandler`
    - `PageHandler.args`
    - `PageHandler.kwargs`
  - `RoutesDispatcher`
    - `RoutesDispatcher.connect()`
    - `RoutesDispatcher.find_handler()`
    - `RoutesDispatcher.redirect()`
  - `VirtualHost()`
  - `XMLRPCDispatcher()`
  - `getargspec()`
  - `test_callable_spec()`
  - `validate_translator()`
- cherrypy._cperror module
  - Redirecting POST
  - Custom Error Handling
    - Anticipated HTTP responses
    - Unanticipated errors
  - `CherryPyException`
  - `HTTPError`
    - `HTTPError.code`
    - `HTTPError.get_error_page()`
    - `HTTPError.handle()`
    - `HTTPError.reason`
    - `HTTPError.set_response()`
    - `HTTPError.status`
  - `HTTPRedirect`
    - `HTTPRedirect.default_status`
    - `HTTPRedirect.encoding`
    - `HTTPRedirect.set_response()`
    - `HTTPRedirect.status`
    - `HTTPRedirect.urls`
  - `InternalRedirect`
  - `NotFound`
  - `_be_ie_unfriendly()`
  - `bare_error()`
  - `clean_headers()`
  - `format_exc()`
  - `get_error_page()`
- cherrypy._cplogging module
  - Simple config
  - Architecture
    - Separate scopes
    - Errors vs. Access
  - Custom Handlers
  - `LazyRfc3339UtcTime`
  - `LogManager`
    - `LogManager._add_builtin_file_handler()`
    - `LogManager._get_builtin_handler()`
    - `LogManager._set_file_handler()`
    - `LogManager._set_screen_handler()`
    - `LogManager._set_wsgi_handler()`
    - `LogManager.access()`
    - `LogManager.access_file`
    - `LogManager.access_log`
    - `LogManager.access_log_format`
    - `LogManager.appid`
    - `LogManager.error()`
    - `LogManager.error_file`
    - `LogManager.error_log`
    - `LogManager.logger_root`
    - `LogManager.reopen_files()`
    - `LogManager.screen`
    - `LogManager.time()`
    - `LogManager.wsgi`
  - `NullHandler`
    - `NullHandler.createLock()`
    - `NullHandler.emit()`
    - `NullHandler.handle()`
  - `WSGIErrorHandler`
    - `WSGIErrorHandler.emit()`
    - `WSGIErrorHandler.flush()`
- cherrypy._cpmodpy module
  - # Application in a module called myapp.py
  - `ModPythonServer`
    - `ModPythonServer.start()`
    - `ModPythonServer.stop()`
    - `ModPythonServer.template`
  - `_ReadOnlyRequest`
    - `_ReadOnlyRequest.expose`
  - `handler()`
  - `popen()`
  - `read_process()`
  - `send_response()`
  - `setup()`
- cherrypy._cpnative_server module
  - `CPHTTPServer`
  - `NativeGateway`
    - `NativeGateway.recursive`
    - `NativeGateway.respond()`
    - `NativeGateway.send_response()`
- cherrypy._cpreqbody module
  - Custom Processors
  - `Entity`
    - `Entity.attempt_charsets`
    - `Entity.charset`
    - `Entity.content_type`
    - `Entity.decode_entity()`
    - `Entity.default_content_type`
    - `Entity.default_proc()`
    - `Entity.filename`
    - `Entity.fp`
    - `Entity.fullvalue()`
    - `Entity.headers`
    - `Entity.length`
    - `Entity.make_file()`
    - `Entity.name`
    - `Entity.next()`
    - `Entity.params`
    - `Entity.part_class`
    - `Entity.parts`
    - `Entity.process()`
    - `Entity.processors`
    - `Entity.read()`
    - `Entity.read_into_file()`
    - `Entity.readline()`
    - `Entity.readlines()`
  - `Part`
    - `Part.attempt_charsets`
    - `Part.boundary`
    - `Part.default_content_type`
    - `Part.default_proc()`
    - `Part.from_fp()`
    - `Part.maxrambytes`
    - `Part.read_headers()`
    - `Part.read_into_file()`
    - `Part.read_lines_to_boundary()`
  - `RequestBody`
    - `RequestBody.bufsize`
    - `RequestBody.default_content_type`
    - `RequestBody.maxbytes`
    - `RequestBody.process()`
  - `SizedReader`
    - `SizedReader.finish()`
    - `SizedReader.read()`
    - `SizedReader.readline()`
    - `SizedReader.readlines()`
  - `_old_process_multipart()`
  - `process_multipart()`
  - `process_multipart_form_data()`
  - `process_urlencoded()`
  - `unquote_plus()`
- cherrypy._cprequest module
  - `Hook`
    - `Hook.callback`
    - `Hook.failsafe`
    - `Hook.kwargs`
    - `Hook.priority`
  - `HookMap`
    - `HookMap.attach()`
    - `HookMap.copy()`
    - `HookMap.run()`
    - `HookMap.run_hooks()`
  - `LazyUUID4`
    - `LazyUUID4.uuid4`
  - `Request`
    - `Request._do_respond()`
    - `Request.app`
    - `Request.base`
    - `Request.body`
    - `Request.close()`
    - `Request.closed`
    - `Request.config`
    - `Request.cookie`
    - `Request.dispatch`
    - `Request.error_page`
    - `Request.error_response()`
    - `Request.get_resource()`
    - `Request.handle_error()`
    - `Request.handler`
    - `Request.header_list`
    - `Request.headers`
    - `Request.hooks`
    - `Request.is_index`
    - `Request.local`
    - `Request.login`
    - `Request.method`
    - `Request.methods_with_bodies`
    - `Request.namespaces`
    - `Request.params`
    - `Request.path_info`
    - `Request.prev`
    - `Request.process_headers()`
    - `Request.process_query_string()`
    - `Request.process_request_body`
    - `Request.protocol`
    - `Request.query_string`
    - `Request.query_string_encoding`
    - `Request.remote`
    - `Request.request_line`
    - `Request.respond()`
    - `Request.rfile`
    - `Request.run()`
    - `Request.scheme`
    - `Request.script_name`
    - `Request.server_protocol`
    - `Request.show_mismatched_params`
    - `Request.show_tracebacks`
    - `Request.stage`
    - `Request.throw_errors`
    - `Request.throws`
    - `Request.toolmaps`
    - `Request.unique_id`
  - `Response`
    - `Response._flush_body()`
    - `Response.body`
    - `Response.collapse_body()`
    - `Response.cookie`
    - `Response.finalize()`
    - `Response.header_list`
    - `Response.headers`
    - `Response.status`
    - `Response.stream`
    - `Response.time`
  - `ResponseBody`
    - `ResponseBody.unicode_err`
  - `error_page_namespace()`
  - `hooks_namespace()`
  - `request_namespace()`
  - `response_namespace()`
- cherrypy._cpserver module
  - `Server`
    - `Server._socket_host`
    - `Server.accepted_queue_size`
    - `Server.accepted_queue_timeout`
    - `Server.base()`
    - `Server.bind_addr`
    - `Server.httpserver_from_self()`
    - `Server.instance`
    - `Server.max_request_body_size`
    - `Server.max_request_header_size`
    - `Server.nodelay`
    - `Server.peercreds`
    - `Server.peercreds_resolve`
    - `Server.protocol_version`
    - `Server.shutdown_timeout`
    - `Server.socket_file`
    - `Server.socket_host`
    - `Server.socket_port`
    - `Server.socket_queue_size`
    - `Server.socket_timeout`
    - `Server.ssl_certificate`
    - `Server.ssl_certificate_chain`
    - `Server.ssl_ciphers`
    - `Server.ssl_context`
    - `Server.ssl_module`
    - `Server.ssl_private_key`
    - `Server.start()`
    - `Server.statistics`
    - `Server.thread_pool`
    - `Server.thread_pool_max`
    - `Server.wsgi_version`
- cherrypy._cptools module
  - `CachingTool`
    - `CachingTool._setup()`
    - `CachingTool._wrapper()`
  - `ErrorTool`
    - `ErrorTool._setup()`
    - `ErrorTool._wrapper()`
  - `HandlerTool`
    - `HandlerTool._setup()`
    - `HandlerTool._wrapper()`
    - `HandlerTool.handler()`
  - `HandlerWrapperTool`
    - `HandlerWrapperTool.callable()`
  - `SessionAuthTool`
  - `SessionTool`
    - `SessionTool._lock_session()`
    - `SessionTool._setup()`
    - `SessionTool.regenerate()`
  - `Tool`
    - `Tool._merged_args()`
    - `Tool._setargs()`
    - `Tool._setup()`
    - `Tool.namespace`
    - `Tool.on`
  - `Toolbox`
    - `Toolbox.register()`
  - `XMLRPCController`
    - `XMLRPCController._cp_config`
    - `XMLRPCController.default()`
  - `_getargs()`
- cherrypy._cptree module
  - `Application`
    - `Application.config`
    - `Application.find_config()`
    - `Application.get_serving()`
    - `Application.log`
    - `Application.merge()`
    - `Application.namespaces`
    - `Application.relative_urls`
    - `Application.release_serving()`
    - `Application.request_class`
    - `Application.response_class`
    - `Application.root`
    - `Application.script_name`
    - `Application.script_name_doc`
    - `Application.toolboxes`
    - `Application.wsgiapp`
  - `Tree`
    - `Tree.apps`
    - `Tree.graft()`
    - `Tree.mount()`
    - `Tree.script_name()`
- cherrypy._cpwsgi module
  - `AppResponse`
    - `AppResponse.close()`
    - `AppResponse.headerNames`
    - `AppResponse.recode_path_qs()`
    - `AppResponse.run()`
    - `AppResponse.translate_headers()`
  - `CPWSGIApp`
    - `CPWSGIApp.config`
    - `CPWSGIApp.head`
    - `CPWSGIApp.namespace_handler()`
    - `CPWSGIApp.pipeline`
    - `CPWSGIApp.response_class`
    - `CPWSGIApp.tail()`
  - `ExceptionTrapper`
  - `InternalRedirector`
  - `VirtualHost`
    - `VirtualHost.default`
    - `VirtualHost.domains`
    - `VirtualHost.use_x_forwarded_host`
  - `_TrappedResponse`
    - `_TrappedResponse.close()`
    - `_TrappedResponse.response`
    - `_TrappedResponse.trap()`
  - `downgrade_wsgi_ux_to_1x()`
- cherrypy._cpwsgi_server module
  - `CPWSGIHTTPRequest`
  - `CPWSGIServer`
    - `CPWSGIServer.error_log()`
    - `CPWSGIServer.fmt`
    - `CPWSGIServer.version`
- cherrypy._helper module
  - `_ClassPropertyDescriptor`
  - `classproperty()`
  - `expose()`
  - `normalize_path()`
  - `popargs()`
  - `url()`
- cherrypy._json module
  - `decode()`
  - `encode()`
- cherrypy.daemon module
  - `run()`
  - `start()`

## Module contents

CherryPy is a pythonic, object-oriented HTTP framework.

CherryPy consists of not one, but four separate API layers.

The APPLICATION LAYER is the simplest. CherryPy applications are written as a tree of classes and methods, where each branch in the tree corresponds to a branch in the URL path. Each method is a ‘page handler’, which receives GET and POST params as keyword arguments, and returns or yields the (HTML) body of the response. The special method name ‘index’ is used for paths that end in a slash, and the special method name ‘default’ is used to handle multiple paths via a single handler. This layer also includes:

> - the ‘exposed’ attribute (and cherrypy.expose)

> - cherrypy.quickstart()

> - _cp_config attributes

> - cherrypy.tools (including cherrypy.session)

> - cherrypy.url()

The ENVIRONMENT LAYER is used by developers at all levels. It provides information about the current request and response, plus the application and server environment, via a (default) set of top-level objects:

> - cherrypy.request

> - cherrypy.response

> - cherrypy.engine

> - cherrypy.server

> - cherrypy.tree

> - cherrypy.config

> - cherrypy.thread_data

> - cherrypy.log

> - cherrypy.HTTPError, NotFound, and HTTPRedirect

> - cherrypy.lib

The EXTENSION LAYER allows advanced users to construct and share their own plugins. It consists of:

> - Hook API

> - Tool API

> - Toolbox API

> - Dispatch API

> - Config Namespace API

Finally, there is the CORE LAYER, which uses the core API’s to construct the default components which are available at higher layers. You can think of the default components as the ‘reference implementation’ for CherryPy. Megaframeworks (and advanced users) may replace the default components with customized or extended components. The core API’s are:

> - Application API

> - Engine API

> - Request API

> - Server API

> - WSGI API

These API’s are described in the CherryPy specification.

class cherrypy.Application(root, script_name='', config=None)

  Bases: `object`

  A CherryPy Application.

  Servers and gateways should not instantiate Request objects directly. Instead, they should ask an Application object for a request object.

  An instance of this class may also be used as a WSGI callable (WSGI application object) for itself.

  config = {}

    pathconf} pairs, where ‘pathconf’ is itself a dict of {key: value} pairs.

    Type:

      A dict of {path

  find_config(path, key, default=None)

    Return the most-specific value for key along path, or default.

  get_serving(local, remote, scheme, sproto)

    Create and return a Request and Response object.

  log = None

    A LogManager instance.

    See _cplogging.

  merge(config)

    Merge the given config into self.config.

  namespaces = {}
  relative_urls = False
  release_serving()

    Release the current serving (request and response).

  request_class

    alias of `Request`

  response_class

    alias of `Response`

  root = None

    The top-most container of page handlers for this app.

    Handlers should be arranged in a hierarchy of attributes, matching the expected URI hierarchy; the default dispatcher then searches this hierarchy for a matching handler. When using a dispatcher other than the default, this value may be None.

  property script_name

    The URI “mount point” for this app.

    A mount point is that portion of the URI which is constant for all URIs that are serviced by this application; it does not include scheme, host, or proxy (“virtual host”) portions of the URI.

    For example, if script_name is “/my/cool/app”, then the URL “

    http://www.example.com/my/cool/app/page1” might be handled by a “page1” method on the root object.

    The value of script_name MUST NOT end in a slash. If the script_name refers to the root of the URI, it MUST be an empty string (not “/”).

    If script_name is explicitly set to None, then the script_name will be provided for each call from request.wsgi_environ[‘SCRIPT_NAME’].

  script_name_doc = 'The URI "mount point" for this app. A mount point\n is that portion of the URI which is constant for all URIs that are\n serviced by this application; it does not include scheme, host, or proxy\n ("virtual host") portions of the URI.\n\n For example, if script_name is "/my/cool/app", then the URL\n "http://www.example.com/my/cool/app/page1" might be handled by a\n "page1" method on the root object.\n\n The value of script_name MUST NOT end in a slash. If the script_name\n refers to the root of the URI, it MUST be an empty string (not "/").\n\n If script_name is explicitly set to None, then the script_name will be\n provided for each call from request.wsgi_environ[\'SCRIPT_NAME\'].\n '
  toolboxes = {'tools': <cherrypy._cptools.Toolbox object>}
  wsgiapp = None

    A CPWSGIApp instance.

    See _cpwsgi.

exception cherrypy.CherryPyException

  Bases: `Exception`

  A base class for CherryPy exceptions.

exception cherrypy.HTTPError(status=500, message=None)

  Bases: `CherryPyException`

  Exception used to return an HTTP error code (4xx-5xx) to the client.

  This exception can be used to automatically send a response using a http status code, with an appropriate error page. It takes an optional `status` argument (which must be between 400 and 599); it defaults to 500 (“Internal Server Error”). It also takes an optional `message` argument, which will be returned in the response body. See RFC2616 for a complete list of available error codes and when to use them.

  Examples:

      raise cherrypy.HTTPError(403)
      raise cherrypy.HTTPError(
          "403 Forbidden", "You are not allowed to access this resource.")

  code = None

    The integer HTTP status code.

  get_error_page(*args, **kwargs)
  classmethod handle(exception, status=500, message='')

    Translate exception into an HTTPError.

  reason = None

    The HTTP Reason-Phrase string.

  set_response()

    Modify cherrypy.response status, headers, and body to represent self.

    CherryPy uses this internally, but you can also use it to create an HTTPError object and set its output without raising the exception.

  status = None

    The HTTP status code.

    May be of type int or str (with a Reason-Phrase).

exception cherrypy.HTTPRedirect(urls, status=None, encoding=None)

  Bases: `CherryPyException`

  Exception raised when the request should be redirected.

  This exception will force a HTTP redirect to the URL or URL’s you give it. The new URL must be passed as the first argument to the Exception, e.g., HTTPRedirect(newUrl). Multiple URLs are allowed in a list. If a URL is absolute, it will be used as-is. If it is relative, it is assumed to be relative to the current cherrypy.request.path_info.

  If one of the provided URL is a unicode object, it will be encoded using the default encoding or the one passed in parameter.

  There are multiple types of redirect, from which you can select via the `status` argument. If you do not provide a `status` arg, it defaults to 303 (or 302 if responding with HTTP/1.0).

  Examples:

      raise cherrypy.HTTPRedirect("")
      raise cherrypy.HTTPRedirect("/abs/path", 307)
      raise cherrypy.HTTPRedirect(["path1", "path2?a=1&b=2"], 301)

  See Redirecting POST for additional caveats.

  default_status = 303
  encoding = 'utf-8'

    The encoding when passed urls are not native strings.

  set_response()

    Modify cherrypy.response status, headers, and body to represent self.

    CherryPy uses this internally, but you can also use it to create an HTTPRedirect object and set its output without raising the exception.

  property status

    The integer HTTP status code to emit.

  urls = None

    The list of URL’s to emit.

exception cherrypy.InternalRedirect(path, query_string='')

  Bases: `CherryPyException`

  Exception raised to switch to the handler for a different URL.

  This exception will redirect processing to another path within the site (without informing the client). Provide the new path as an argument when raising the exception. Provide any params in the querystring for the new URL.

exception cherrypy.NotFound(path=None)

  Bases: `HTTPError`

  Exception raised when a URL could not be mapped to any handler (404).

  This is equivalent to raising `HTTPError("404 Not Found")`.

class cherrypy.Tool(point, callable, name=None, priority=50)

  Bases: `object`

  A registered function for use with CherryPy request-processing hooks.

  help(tool.callable) should give you more information about this Tool.

  _merged_args(d=None)

    Return a dict of configuration entries for this Tool.

  _setargs()

    Copy func parameter names to obj attributes.

  _setup()

    Hook this tool into cherrypy.request.

    The standard CherryPy request object will automatically call this method when the tool is “turned on” in config.

  namespace = 'tools'
  property on

cherrypy.expose(func=None, alias=None)

  Expose the function or class.

  Optionally provide an alias or set of aliases.

cherrypy.popargs(*args, **kwargs)

  Decorate _cp_dispatch.

  (cherrypy.dispatch.Dispatcher.dispatch_method_name)

  Optional keyword argument: handler=(Object or Function)

  Provides a _cp_dispatch function that pops off path segments into cherrypy.request.params under the names specified. The dispatch is then forwarded on to the next vpath element.

  Note that any existing (and exposed) member function of the class that popargs is applied to will override that value of the argument. For instance, if you have a method named “list” on the class decorated with popargs, then accessing “/list” will call that function instead of popping it off as the requested parameter. This restriction applies to all _cp_dispatch functions. The only way around this restriction is to create a “blank class” whose only function is to provide _cp_dispatch.

  If there are path elements after the arguments, or more arguments are requested than are available in the vpath, then the ‘handler’ keyword argument specifies the next object to handle the parameterized request. If handler is not specified or is None, then self is used. If handler is a function rather than an instance, then that function will be called with the args specified and the return value from that function used as the next object INSTEAD of adding the parameters to cherrypy.request.args.

  This decorator may be used in one of two ways:

  As a class decorator:

      @cherrypy.popargs('year', 'month', 'day')
      class Blog:
          def index(self, year=None, month=None, day=None):
              #Process the parameters here; any url like
              #/, /2009, /2009/12, or /2009/12/31
              #will fill in the appropriate parameters.

          def create(self):
              #This link will still be available at /create.
              #Defined functions take precedence over arguments.

  Or as a member of a class:

      class Blog:
          _cp_dispatch = cherrypy.popargs('year', 'month', 'day')
          #...

  The handler argument may be used to mix arguments with built in functions. For instance, the following setup allows different activities at the day, month, and year level:

      class DayHandler:
          def index(self, year, month, day):
              #Do something with this day; probably list entries

          def delete(self, year, month, day):
              #Delete all entries for this day

      @cherrypy.popargs('day', handler=DayHandler())
      class MonthHandler:
          def index(self, year, month):
              #Do something with this month; probably list entries

          def delete(self, year, month):
              #Delete all entries for this month

      @cherrypy.popargs('month', handler=MonthHandler())
      class YearHandler:
          def index(self, year):
              #Do something with this year

          #...

      @cherrypy.popargs('year', handler=YearHandler())
      class Root:
          def index(self):
              #...

cherrypy.quickstart(root=None, script_name='', config=None)

  Mount the given root, start the builtin server (and engine), then block.

  root: an instance of a “controller class” (a collection of page handler

    methods) which represents the root of the application.

  script_name: a string containing the “mount point” of the application.

    This should start with a slash, and be the path portion of the URL at which to mount the given root. For example, if root.index() will handle requests to “http://www.example.com:8080/dept/app1/”, then the script_name argument would be “/dept/app1”.

    It MUST NOT end in a slash. If the script_name refers to the root of the URI, it MUST be an empty string (not “/”).

  config: a file or dict containing application config. If this contains

    a [global] section, those entries will be used in the global (site-wide) config.

cherrypy.url(path='', qs='', script_name=None, base=None, relative=None)

  Create an absolute URL for the given path.

  If ‘path’ starts with a slash (‘/’), this will return

    (base + script_name + path + qs).

  If it does not start with a slash, this returns

    (base + script_name [+ request.path_info] + path + qs).

  If script_name is None, cherrypy.request will be used to find a script_name, if available.

  If base is None, cherrypy.request.base will be used (if available). Note that you can use cherrypy.tools.proxy to change this.

  Finally, note that this function can be used to obtain an absolute URL for the current request path (minus the querystring) by passing no args. If you call url(qs=cherrypy.request.query_string), you should get the original browser URL (assuming no internal redirections).

  If relative is None or not provided, request.app.relative_urls will be used (if available, else False). If False, the output will be an absolute URL (including the scheme, host, vhost, and script_name). If True, the output will instead be a URL that is relative to the current request path, perhaps including ‘..’ atoms. If relative is the string ‘server’, the output will instead be a URL that is relative to the server root; i.e., it will start with a slash.