Changeset 1105
- Timestamp:
- 05/10/06 16:01:36
- Files:
-
- trunk/cherrypy/_cptree.py (modified) (2 diffs)
- trunk/cherrypy/config.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cptree.py
r1096 r1105 1 2 from cherrypy import config 3 1 4 2 5 class Application: 3 6 4 def __init__(self, root, conf ):7 def __init__(self, root, conf=None): 5 8 self.root = root 6 self.conf = conf 9 self.conf = {} 10 if conf: 11 self.merge(conf) 12 13 def merge(self, conf): 14 config.merge(self.conf, conf) 7 15 8 16 … … 14 22 15 23 def mount(self, root, script_name=None, conf=None): 16 """Mount the given application root object at the given script_name.""" 17 import cherrypy 18 19 if conf and not isinstance(conf, dict): 20 conf = cherrypy.config.dict_from_config_file(conf) 21 elif conf is None: 22 conf = {} 23 24 """Mount a new app from a root object, script_name, and conf.""" 25 app = Application(root, conf) 24 26 if script_name is None: 25 27 script_name = "/" 26 if conf: 27 conf_pt = conf.get("global", {}).get("script_name") 28 if conf_pt: 29 script_name = conf_pt 30 31 self.apps[script_name] = Application(root, conf) 28 self.apps[script_name] = app 29 return app 32 30 33 31 def script_name(self, path=None): trunk/cherrypy/config.py
r1102 r1105 31 31 }, 32 32 } 33 34 def merge(base, other): 35 """Merge one app config (from a dict, file, or filename) into another.""" 36 if isinstance(other, basestring): 37 if other not in autoreload.reloadFiles: 38 autoreload.reloadFiles.append(other) 39 other = dict_from_config_file(other) 40 elif hasattr(other, 'read'): 41 other = dict_from_config_file(other) 42 43 # Load other into base 44 for section, value_map in other.iteritems(): 45 base.setdefault(section, {}).update(value_map) 33 46 34 47 default_conf = {

