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

Version 1 (modified by elvelind@…, 14 years ago) (diff)

--

With TurboGears 0.9 (or svn rev 106) quickstart now uses PasteScript and therefor supports user templates. So lets go ahead and create one of those!

lets say that you have a default.css file that you always include in your webapp.

lets start creating some files and dirs.

mytemplate/ mytemplate/setup.py mytemplate/mytemplate/init.py mytemplate/mytemplate/template/+package+/static/css/default.css

first we will edit the setup.py

from setuptools import setup, find_packages
from turbogears import finddata

setup(name='mytemplate',
      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
      zip_safe=False,
      package_data=finddata.find_package_data(),
      entry_points="""
          [paste.paster_create_template]
              mytemplate = mytemplate:MyTemplate
        """
      )

this setup basicly tells pasterscript that there is an template called mytemplate and it's class is MyTemplate? in the mytemplate module

now lets edit init.py

from paste.script import templates
import pkg_resources

class MyTemplate(templates.Template):

    egg_plugins = ['MyTemplate']
    _template_dir = pkg_resources.resource_filename("mytemplate", "template")
    summary = "my own cute template"

now all you have to do is add anything to the template dir.

now when you can run tg-admin quickstart -t mytemplate and there should be a default.css file in your static/css/ dir!

see  http://pythonpaste.org/script/developer.html#templates for more info

/elvelind grandin