How to upgrade to CherryPy 2.1
Configuration
If you're using a config file, change this call:
cpg.server.start(configFile = xxx)
into this:
cherrypy.config.update(file = xxx) cherrypy.server.start()
...and change your config file to use the new format:
[global] server.socketPort = 8080 server.threadPool = 10 server.environment = "production"
[This example is in the CherryPy tutorial directory as "tutorial.conf", or on-line at http://www.cherrypy.org/file/trunk/cherrypy/tutorial/tutorial.conf]
If you're setting the config options programmatically, change this call:
cpg.server.start(configMap = {'socketPort': 8080})
...into this:
cherrypy.config.update({ 'global': { 'server.socketPort': 8080 } }) cherrypy.server.start()
If you were using cpg.configFile anywhere in your code to read custom values from the config file, you need to use cherrypy.config.get instead (if the option is under a /path section, or use cherrypy.config.configMap directly if you want)
Filters
If you're using some of the default filters in your code, remove them from _cpFilterList and just enable them through the config file.
Since the core was rewritten to use iterators, some of the filter method names are obsolete, and have been replaced. In addition, the filters are no longer divided into separate input and output classes; each core filter is now implemented with a single class per filter.
If you have custom filters, you should collapse your classes, and then change the method names (or your code will not be called). In general, you can follow this mapping from old to new names:
| Old Name | New Name |
| no equivalent | onStartResource |
| setConfig, afterRequestHeader | beforeRequestBody |
| afterRequestBody | beforeMain |
| beforeResponse | beforeFinalize |
| afterResponse | onEndResource |
| beforeErrorResponse | no change |
| afterErrorResponse | no change |
Also, be aware that CherryPy 2.1 no longer uses wfile to write output to the client. Instead, you should append output strings to cherrypy.response.body.
Sessions
You may need to update your config. You also need to change any references of "cpg.request.sessionMap" to "cherrypy.session".

