Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 2 and Version 3 of NonPackagedKidTemplates


Ignore:
Timestamp:
08/08/06 04:21:35 (13 years ago)
Author:
robinbryce
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NonPackagedKidTemplates

    v2 v3  
    9797}}} 
    9898 
     99== The custom start script == 
    99100 
     101It is necessary to customise the way you start your turbogears application to enable the import hook. It '''may''' be possible to avoid this customisation. However, it's likely that if you want NonPackagedKidTemplates you will also be customising your turbogears startup process. This script shows you where to enable the hook and how to customise `top_source_dir` to cause `[/static]` to resolve to an arbitrary file system location. 
    100102 
     103{{{ 
     104#!/usr/bin/env python 
     105import os 
     106def run_turbogears(): 
     107    import pkg_resources 
     108    pkg_resources.require("TurboGears") 
     109    from configobj import ConfigObj 
     110    import turbogears, cherrypy 
     111    cherrypy.lowercase_api = True 
     112    from bigsitesupport import kidimport 
     113    TOP_LEVEL_DIR='/var/www/bigsite' 
     114    tg_cfgfiles=[ # order is important 
     115        'conf/tg-dev.cfg', 
     116        'conf/tg-log.cfg', 
     117        'conf/tg-app.cfg' 
     118        ] 
     119    package_dir = os.path.abspath( 
     120        pkg_resources.resource_filename('bigsitesupport', '' 
     121            )[:-1].replace('\\','/')) 
     122    configdata = ConfigObj(unrepr=True) 
     123    defaults = turbogears.config.config_defaults() 
     124    defaults.update( 
     125            top_level_dir=TOP_LEVEL_DIR, 
     126            package_dir=package_dir) 
     127    configdata.merge(dict(DEFAULT=defaults)) 
     128    for f in tg_cfgfiles: 
     129        cfgmerge=ConfigObj(f, unrepr=True) 
     130        cfgmerge.merge(dict(DEFAULT=defaults)) 
     131        configdata.merge(cfgmerge) 
     132    configdict=configdata.dict() 
     133    turbogears.config.configure_loggers(configdict) 
     134    turbogears.config.update(configdict) 
     135    kidimport.install_import_hook( 
     136        kidimport.Importer_factory(configdata)) 
     137    # may the force be with you luke 
     138    from bigsitesupport.controllers import Root 
     139    turbogears.start_server(Root()) 
     140  
     141if __name__=='__main__': 
     142    run_turbogears() 
     143}}} 
     144