Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1105

Show
Ignore:
Timestamp:
05/10/06 16:01:36
Author:
fumanchu
Message:

Bah. I knew I had config.merge in there for a reason.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cptree.py

    r1096 r1105  
     1 
     2from cherrypy import config 
     3 
    14 
    25class Application: 
    36     
    4     def __init__(self, root, conf): 
     7    def __init__(self, root, conf=None): 
    58        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) 
    715 
    816 
     
    1422     
    1523    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) 
    2426        if script_name is None: 
    2527            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 
    3230     
    3331    def script_name(self, path=None): 
  • trunk/cherrypy/config.py

    r1102 r1105  
    3131        }, 
    3232    } 
     33 
     34def 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) 
    3346 
    3447default_conf = { 

Hosted by WebFaction

Log in as guest/cpguest to create tickets