CherryPy Toolbox
The tool interface has been designed by Robert Brewer while refactoring CherryPy. The goal was to offer ready-to-employ tools achieving common tasks with a friendly and flexible API. Within CherryPy, built-in tools offer a single interface to call the CherryPy library that we have reviewed in Chapter 3 using the hooking mechanism.
As we have seen in Chapter 3 tools can be used in three different ways:
From the configuration settings
As a Python decorator or via the special
_cp_config
attribute of a page handlerAs a Python callable that can be applied from within any function
Thanks to this flexibility, a tool can be set either globally to a path and its subset or to a particular page handler. Let's now review the built-in tools provided by CherryPy.
Basic Authentication Tool
Purpose: The purpose of this tool is to provide basic authentication (RFC 2617) to your application.
Arguments:
Name |
Default |
Description |
---|---|---|
|
N/A ( N/A in this case means the parameter must be provided... |