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 4 (modified by anonymous, 14 years ago) (diff)


With TurboGears 0.9 (or svn rev 106) quickstart now uses PasteScript and therefor supports user templates.


Why would you want to do this? Well, if you have your own conventions for applications, this is a way to add those to new TurboGears projects -- documentation templates, testing frameworks, whatever.

Also, if you already have a project started, you can apply run quickstart on it again (perhaps with your new template!) and see how the current project differs, and maybe apply some of the changes.


So let's go ahead and create our own template!

Let's say that you have a default.css file that you always include in your webapp.

Let's start creating some files and dirs.

mytemplate/ mytemplate/ mytemplate/mytemplate/ mytemplate/mytemplate/template/+package+/static/css/default.css

First we will edit the

from setuptools import setup, find_packages
from turbogears import finddata

      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
              mytemplate = mytemplate:MyTemplate

This setup basically tells pastescript that there is an template called mytemplate and its class is MyTemplate? in the mytemplate module

Now let's edit

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 you can run tg-admin quickstart -t mytemplate and there should be a default.css file in your static/css/ dir!

See for more info

/elvelind grandin