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 4 and Version 5 of NonPackagedKidTemplates


Ignore:
Timestamp:
08/08/06 05:03:24 (13 years ago)
Author:
robinbryce
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NonPackagedKidTemplates

    v4 v5  
    1818    # bigsitesupport is the name you gave your turbogears application when you set it up (tg-admin quickstart) 
    1919 
    20     @expose(template='bigsitesupport/kid/welcome') 
     20    @expose(template='bigsitesupport.tg/kid/welcome') 
    2121    def index(self): 
    2222        import time 
     
    3535from kid.importer import import_template 
    3636 
    37 log = logging.getLogger('bigsitesupport.kidimport') 
     37log = logging.getLogger('bigsitesupport.tg.kidimport') 
    3838 
    3939class _Importer(object): 
     
    120120        ] 
    121121    package_dir = os.path.abspath( 
    122         pkg_resources.resource_filename('bigsitesupport', '' 
     122        pkg_resources.resource_filename('bigsitesupport.tg', '' 
    123123            )[:-1].replace('\\','/')) 
    124124    configdata = ConfigObj(unrepr=True) 
     
    138138        kidimport.Importer_factory(configdata)) 
    139139    # may the force be with you luke 
    140     from bigsitesupport.controllers import Root 
     140    from bigsitesupport.tg.controllers import Root 
    141141    turbogears.start_server(Root()) 
    142142  
     
    148148== The critical trick == 
    149149 
    150 The problem not addressed so far is how to prevent TruboKid from complaining about your non packaged kid template file. And indeed,  how to prevent it from blowing up when it encounters 'bigsitesupport/kid/welcome' as a template name. With the import hook installed this turns out to be pretty simple: in your tg-app.cfg file add `kid.precompiled=True` to the `[global]` section. If your config file was generated by runing tg-admin quickstart then after this change the first few lines of this file should look like: 
     150The problem not addressed so far is how to prevent TruboKid from complaining about your non packaged kid template file. And indeed,  how to prevent it from blowing up when it encounters 'bigsitesupport.tg/kid/welcome' as a template name. With the import hook installed this turns out to be pretty simple: in your tg-app.cfg file add `kid.precompiled=True` to the `[global]` section. If your config file was generated by runing tg-admin quickstart then after this change the first few lines of this file should look like: 
    151151 
    152152{{{ 
     
    164164 
    165165This works because when you tell TurboKid your template files are 'precompiled', TurboKid relies on pythons standard `__import__` machinery to load the template. By lying to turbokid about the 'precompiled' nature of your kid template you by pass all the 'is this kid file a proper pkg_resource' checks and instead go directly to your import hook. 
    166