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

Changeset 1305

Show
Ignore:
Timestamp:
09/01/06 11:46:15
Author:
fumanchu
Message:

Moved merge out of Application.__init__ so custom namespaces can be defined per-app. Also allow Tree.mount to accept an Application instance (instead of a root which gets wrapped in an Application).

Files:

Legend:

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

    r1293 r1305  
    1919    """ 
    2020     
    21     def __init__(self, root, script_name="", conf=None): 
     21    def __init__(self, root, script_name=""): 
    2222        self.log = _cplogging.LogManager(id(self)) 
    2323        self.root = root 
     
    2626                           } 
    2727        self.conf = {} 
    28         if conf: 
    29             self.merge(conf) 
    3028     
    3129    def _get_script_name(self): 
     
    4341        _cpconfig.merge(self.conf, conf) 
    4442         
    45         # Create log handlers as specified in config. 
     43        # Handle namespaces specified in config. 
    4644        rootconf = self.conf.get("/", {}) 
    4745        for k, v in rootconf.iteritems(): 
     
    9492        # Next line both 1) strips trailing slash and 2) maps "/" -> "". 
    9593        script_name = script_name.rstrip("/") 
    96         app = Application(root, script_name, conf) 
     94         
     95        if isinstance(root, Application): 
     96            app = root 
     97        else: 
     98            app = Application(root, script_name) 
     99             
     100            # If mounted at "", add favicon.ico 
     101            if script_name == "" and root and not hasattr(root, "favicon_ico"): 
     102                import os 
     103                from cherrypy import tools 
     104                favicon = os.path.join(os.getcwd(), os.path.dirname(__file__), 
     105                                       "favicon.ico") 
     106                root.favicon_ico = tools.staticfile.handler(favicon) 
     107         
     108        if conf: 
     109            app.merge(conf) 
     110         
    97111        self.apps[script_name] = app 
    98          
    99         # If mounted at "", add favicon.ico 
    100         if script_name == "" and root and not hasattr(root, "favicon_ico"): 
    101             import os 
    102             from cherrypy import tools 
    103             favicon = os.path.join(os.getcwd(), os.path.dirname(__file__), 
    104                                    "favicon.ico") 
    105             root.favicon_ico = tools.staticfile.handler(favicon) 
    106112         
    107113        return app 

Hosted by WebFaction

Log in as guest/cpguest to create tickets