Changeset 4761

Show
Ignore:
Timestamp:
06/17/08 18:00:17 (5 months ago)
Author:
mramm
Message:

Update the config system to use an AppConfig? object to provide the base configuration stuff.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tg/config.py

    r4759 r4761  
    2424            raise AttributeError(name) 
    2525 
    26 class AppSetup(Bunch): 
     26class AppConfig(Bunch): 
    2727    """Class to store application configuration 
    2828     
     
    3535    def __init__(self): 
    3636        self.stand_alone = True 
     37        self.default_renderer = 'genshi' 
     38        self.auth_backend = None  
    3739     
    3840    pass 
  • trunk/tg/controllers.py

    r4698 r4761  
    393393                continue 
    394394 
    395  
    396395def _find_object(obj, remainder, notfound_handlers): 
    397396    while True: 
     
    418417        obj = getattr(obj, remainder[0], None) 
    419418        remainder = remainder[1:] 
    420  
    421419 
    422420def _iscontroller(obj): 
  • trunk/tg/middleware.py

    r4752 r4761  
    1313from tw.api import make_middleware as tw_middleware 
    1414 
    15 def setup_tg_wsgi_app(load_environment, setup_vars): 
     15def setup_tg_wsgi_app(load_environment, base_config): 
    1616    """Create a base TG app, with all the standard middleware 
    1717     
     
    2222        A dictionary any special values nessisary for setting up 
    2323        the base wsgi app. 
    24 .  
    2524    """                   
    26  
     25     
    2726    def make_base_app(global_conf, full_stack=True, **app_conf): 
    2827        """Create a tg WSGI application and return it 
     
    5756        app = tw_middleware(app, { 
    5857            'toscawidgets.framework.default_view':  
    59             setup_vars.get('default_renderer', 'genshi') 
     58            base_config.default_renderer 
    6059            }) 
    6160 
    62         if setup_vars.get('identity', None) == "sqlalchemy": 
     61        if base_config.auth_backend == "sqlalchemy": 
    6362            # configure identity Middleware 
    6463            from tg.ext.repoze.who.middleware import make_who_middleware 
    65             DBSession = setup_vars['identity.dbsession']  
    66             User = setup_vars['identity.user']  
    67             user_criterion = setup_vars['identity.user_criterion']  
    68             user_id_col = setup_vars['identity.user_id_col']  
    69             app = make_who_middleware(app, config, User,  
    70                                       user_criterion,  
    71                                       user_id_col,  
    72                                       DBSession) 
     64             
     65            auth = base_config.sa_auth 
     66             
     67            app = make_who_middleware(app, config, auth.User,  
     68                                      auth.user_criterion, auth.user_id_col,  
     69                                      auth.DBSession) 
    7370 
    7471        if asbool(full_stack): 
  • trunk/tg/render.py

    r4698 r4761  
    5555    template = app_globals.genshi_loader.load(template_name) 
    5656    # Render the template 
    57     return template.generate(**tmpl_vars) 
     57    return template.render(**tmpl_vars)