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

Changeset 2048

Show
Ignore:
Timestamp:
10/01/08 20:45:49
Author:
fumanchu
Message:

Easier config access to engine and plugins.

Files:

Legend:

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

    r2040 r2048  
    311311    elif k == 'SIGTERM': 
    312312        engine.listeners['SIGTERM'] = set([v]) 
     313    elif "." in k: 
     314        plugin, attrname = k.split(".", 1) 
     315        plugin = getattr(engine, plugin) 
     316        if attrname == 'on': 
     317            if v and callable(getattr(plugin, 'subscribe', None)): 
     318                plugin.subscribe() 
     319                return 
     320            elif (not v) and callable(getattr(plugin, 'unsubscribe', None)): 
     321                plugin.unsubscribe() 
     322                return 
     323        setattr(plugin, attrname, v) 
     324    else: 
     325        setattr(engine, k, v) 
    313326Config.namespaces["engine"] = _engine_namespace_handler 
    314327 

Hosted by WebFaction

Log in as guest/cpguest to create tickets