1. cherrypy
  2. CherryPy

Commits

fumanchu  committed 605aefa

Changed page WhatsNewIn21

  • Participants
  • Parent commits a554a71
  • Branches default

Comments (0)

Files changed (1)

File WhatsNewIn21.wiki

View file
  • Ignore whitespace
 = What's new in CherryPy-2.1 =
 
- 1. Changes to [wiki:PackageLayout21 the package layout] '''IMPORTANT'''
- 2. Changes to [wiki:ConfigSystem21 config system]
+= Package Layout '''IMPORTANT''' =
+
+The cpg module has been removed. If you attempt to start a CherryPy 2.0 application under CherryPy 2.1+, you'll see a traceback ending with this:
+
+{{{
+AttributeError: 'module' object has no attribute 'getSpecialFunction'
+}}}
+
+The quick fix is to change "from cherrypy import cpg" to "import cherrypy as cpg". The longer fix is to change "from cherrypy import cpg" to "import cherrypy", and change all occurrences of "cpg" to "cherrypy".
+
+
+In addition, some modules have been renamed:
+
+ * ''_cpconfig'' is now ''config''. However, you can also write "cherrypy.config" (as you used to write "cpg.config").
+ * ''cperror'' is now ''_cperror''. However, you can also raise "cherrypy.HTTPRedirect", "cherrypy.NotFound", etc.
+ * You should now write "cherrypy.server" (as you used to write "cpg.server").
+
+
+= New config system =
+
+The config options are now stored in a dictionary called "cherrypy.config.configMap". It's a dictionary of dictionaries. The keys of the first dictionaries correspond to the PATH of the HTTP requests (except 'global', which is the default). This way you can use different configurations for different PATHs. The default value is:
+{{{
+#!python
+cherrypy.config.configMap = {
+        'global': {
+            'server.socketPort': 8080,
+            'server.socketHost': '',
+            'server.socketFile': '',
+            'server.socketQueueSize': 5,
+
+            'server.protocolVersion': 'HTTP/1.0',
+            'server.logToScreen': True,
+            'server.logFile': '',
+            'server.reverseDNS': False,
+            'server.threadPool': 0,
+            'server.environment': 'development',
+        },
+    }
+}}}
+
+To update this dictionary, users should call cherrypy.config.update, either by passing an update dictionary, like this:
+
+{{{
+#!python
+cherrypy.config.update({
+    'global': {
+        'sessionFilter.on': True,
+        'sessionFilter.storageType': 'file'}
+    },
+# or the shortcut version for 'global':
+cherrypy.config.update({'sessionFilter.on': True})
+}}}
+
+Or by passing a file name, in which case !CherryPy will parse the INI file (see below for more on this format) and store the values in cherrypy.config.configMap, like this:
+
+{{{
+#!python
+cherrypy.config.update(file = 'server.cfg')
+}}}
+
+'''Note that !CherryPy uses "unrepr" to parse the values in your config file, so you need to write them as python expressions (ex: "string", True, 1)'''
+
+'''Also note that the config file keys are now CASE-SENSITIVE'''
+
+To access a config option from your code, the new API is:
+
+{{{
+#!python
+cherrypy.config.get(key, defaultValue = None)
+}}}
+
+ Examples:
+
+{{{
+#!python
+cherrypy.config.get('sessionFilter.storageType')
+or
+cherrypy.config.get('server.socketPort', 8080)
+}}}
+
+{{{
+#!html
+<div class="highlighted">
+}}}
+
+'''Steps to upgrade your site'''
+If you're using a config file, change this call:
+
+{{{
+#!python
+cpg.server.start(configFile = xxx)
+}}}
+
+into this:
+
+{{{
+#!python
+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:
+{{{
+#!python
+cpg.server.start(configMap = {'socketPort': 8080})
+}}}
+
+...into this:
+
+{{{
+#!python
+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)
+
+{{{
+#!html
+</div>
+}}}
+
+
+
  3. Changes to [wiki:Filters21 filters]
     * [wiki:StdFilterBaseUrl Base URL filter]
     * [wiki:StdFilterCache Cache filter]