Changeset 5650

Show
Ignore:
Timestamp:
11/03/08 15:53:23 (2 months ago)
Author:
mramm
Message:

Updated config to allow you to turn off more stuff without subclassing AppConfig?.

Updated tests.base.TestConfig? to call AppConfig?'s init so that changes to config defaults don't break the tests unessisarily.

Updated AppConfig? docstrings somewhat.

Updated README.txt to get rid of info that didn't belong.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README.txt

    r4568 r5650  
    1 TurboGears2 
    2 =========== 
    3  
    4 Next generation Front-to-back web development megaframework built on Pylons. 
    5  
    6 TurboGears2, provides a comprehensive web development toolkit. 
    7 It is designed to help you create the basic outline of a database-driven 
    8 web application in minutes. 
    9  
    10 TurboGears provides you with sane default for designer friendly templates, 
    11 tools to make  AJAX, and dynamic Javascript driven pages easy on both the 
    12 browser side and the server side. 
    13  
    14 TurboGears is a project that is built upon a foundation of reuse and building up. 
    15 In retrospect, much of the code that was home grown in the TurboGears project 
    16 should have been released as independent projects that integrate with TurboGears. 
    17  
    181TurboGears is licensed under an MIT-style license (see LICENSE.txt). 
    192Other incorporated projects may be licensed under different licenses. 
    203All licenses allow for non-commercial and commercial use. 
    21  
    22 Working on TG2 
    23 -------------- 
    24  
    25 To be able to build TG2 packages or install it for development, you 
    26 need Paver:: 
    27  
    28   easy_install Paver 
    29  
    30 You can then run:: 
    31  
    32   paver develop 
    33  
    34 to start working with the development version of TG2. 
  • trunk/tg/configuration.py

    r5598 r5650  
    1 """Simple AppSetup helper class""" 
     1"""Configuration Helpers for TurboGears 2""" 
    22import os 
    33import logging 
     
    3636    in the same process simultaniously, but to always get the right 
    3737    config data for the app that's requesting them. 
     38     
     39    Sites, with seeking to maximize needs may perfer to use the pylons  
     40    config stacked object proxy directly, using just dictionary style 
     41    access, particularly whenever config is checked on a per-request 
     42    basis.  
    3843    """ 
    3944 
    4045    def __init__(self, dict_to_wrap): 
    41         """Initialize by passing in a dictionary to be wrapped""" 
     46        """Initialize the object by passing in pylons config to be wrapped""" 
    4247        self.__dict__['config_proxy'] = dict_to_wrap 
    4348 
     
    8287 
    8388    This class should have configuration/setup information 
    84     that is NECESSARY for proper application function. 
     89    that is *nessisary* for proper application function. 
    8590    Deployment specific configuration information should go in 
    8691    the config files (eg: dvelopment.ini or production.ini) 
     
    105110 
    106111        #Set individual defaults 
     112        self.auto_reload_templates = True 
     113        self.auth_backend = None 
     114        self.default_renderer = 'genshi' 
     115        self.serve_static = True 
    107116        self.stand_alone = True 
    108         self.default_renderer = 'genshi' 
    109         self.auth_backend = None 
    110         self.serve_static = True 
    111117        self.use_legacy_renderer = True 
    112         self.auto_reload_templates = True 
     118        self.use_toscawidgets = True 
     119        self.use_transaction_manager = True 
    113120 
    114121    def setup_paths(self): 
     
    128135 
    129136        tg.config is a proxy for pylons.config that allows attribute style 
    130         access, so it's automatically setup when we create the poylons config 
    131  
    132         Besides basic initialization,  this method copies all the values 
    133         in base_config  into the ``tg.config`` object. 
     137        access, so it's automatically setup when we create the pylons  
     138        config. 
     139 
     140        Besides basic initialization, this method copies all the values 
     141        in base_config into the ``pylons.config`` and ``tg.config``  
     142        objects. 
     143         
    134144        """ 
    135145        pylons_config.init_app(global_conf, app_conf, 
     
    141151        """Setup the default TG2 routes 
    142152 
    143         Overide this and setup your own routes maps if you want to use routes. 
    144         """ 
     153        Overide this and setup your own routes maps if you want to use  
     154        custom routes. 
     155         
     156        """ 
     157         
    145158        map = Mapper(directory=config['pylons.paths']['controllers'], 
    146159                    always_scan=config['debug']) 
     
    154167 
    155168    def setup_helpers_and_globals(self): 
     169        """Add Hepers and Globals objects to the config. 
     170         
     171        Overide this method to customize the way that ``app_globals``  
     172        and ``helpers`` are setup.   
     173        """ 
     174         
    156175        config['pylons.app_globals'] = self.package.lib.app_globals.Globals() 
     176        config['pylons.helpers'] = self.package.lib.helpers 
    157177        config['pylons.h'] = self.package.lib.helpers 
    158178 
    159179    def setup_sa_auth_backend(self): 
     180        """This method adds sa_auth information to the config.""" 
    160181        defaults = { 
    161182                    'form_plugin': None 
     
    168189 
    169190    def setup_mako_renderer(self): 
    170         """Setup a renderer and loader for mako templates""" 
     191        """Setup a renderer and loader for mako templates 
     192         
     193        Overide this to customize the way that the mako template 
     194        renderer is setup.  In particular if you want to setup  
     195        a different set of search paths, different encodings, or 
     196        additonal imports, all you need to do is update the 
     197        ``TemplateLookup`` constructor.  
     198         
     199        You can also use your own render_mako function instead of the one 
     200        provided by tg.render.  
     201        """ 
    171202        from mako.lookup import TemplateLookup 
    172203        from tg.render import render_mako 
     
    183214 
    184215    def setup_genshi_renderer(self): 
    185         """Setup a renderer and loader for Genshi templates""" 
     216        """Setup a renderer and loader for Genshi templates 
     217         
     218        Overide this to customize the way that the internationalization 
     219        filter, template loader """ 
    186220        from genshi.template import TemplateLoader 
    187221        from tg.render import render_genshi 
     
    373407            """Create a tg WSGI application and return it 
    374408 
     409            ``wrap_app`` 
     410                a WSGI middleware component which takes the core turbogears 
     411                application and wraps it -- inside all the WSGI-components  
     412                provided by TG and Pylons. This allows you to work with the  
     413                full environ that your tg app would get before anything 
     414                happens in the app itself.  
     415 
    375416            ``global_conf`` 
    376                 The inherited configuration for this application. Normally from 
    377                 the [DEFAULT] section of the Paste ini file. 
     417                The inherited configuration for this application. Normally  
     418                fromthe [DEFAULT] section of the Paste ini file. 
    378419 
    379420            ``full_stack`` 
     
    394435                wrap_app(app) 
    395436            app = self.add_core_middleware(app) 
    396             app = self.add_tosca_middleware(app) 
     437             
     438            if self.use_toscawidgets: 
     439                app = self.add_tosca_middleware(app) 
    397440 
    398441            if self.auth_backend == "sqlalchemy": 
    399442                app = self.add_auth_middleware(app) 
    400  
    401             app = self.add_tm_middleware(app) 
     443             
     444            if self.use_transaction_manager:  
     445                app = self.add_tm_middleware(app) 
     446             
    402447            if self.use_sqlalchemy: 
    403448                if not hasattr(self, 'DBSession'): 
  • trunk/tg/tests/base.py

    r5585 r5650  
    117117 
    118118    def __init__(self, folder, values=None): 
    119  
     119        AppConfig.__init__(self) 
    120120        #First we setup some base values that we know will work 
    121121        self.renderers = ['genshi']  
     
    129129        self.use_legacy_renderer = True 
    130130        self.serve_static = False 
     131         
    131132 
    132133        #Then we overide those values with what was passed in