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

Ticket #1640 (closed task: migrated)

Opened 7 years ago

Last modified 4 years ago

Refactor and improve quickstart templates

Reported by: chrisz Owned by: chrisz
Priority: normal Milestone: 1.5
Component: TurboGears Version: 1.0.4b3
Severity: normal Keywords: quickstart templates, tempita. migrate
Cc:

Description (last modified by Chris Arndt) (diff)

The quickstart templates of TG 1.0 should be refactored and improved in TG 1.1.

The problem is that some templates are duplicating others (e.g. root._py_tmpl in tgbig is a copy of controllers.py_tmpl, and the external tggenshi package also copies several templates) which is violating DRY and led to several bugs in the past because people forgot to update the copies (see also ticket #1457). We probably need to change the quickstart template hierarchy to use multiple inheritance for the different aspects of a project (model, view, controller, directory layout etc.).

When the project templates for the views will be properly separated from the rest of the project, it will be also easier to support more than one templating language (e.g. Kid for backward compatibility or Mako for performance).

Another problem is that the choice of names for the quickstart templates, packages and directories in TG 1.0 is very inconsistent and obscuring the connections between them. Currently we have the following mess:

template package entry point name
BaseTemplate qsbase tgbase
TurbogearsTemplate quickstart turbogears
TGBig quickstartbig tgbig
TGWidgetTemplate widget tgwidget

Another idea is to replace the use of Cheetah in the quickstart templates with  Tempita which is pure Python and more lightweight than Cheetah, integrates well with Paste and will probably be required by TG 2.0 anyway, since it is needed by weberror. Then those who don't use Cheetah for web templating will not need to install Cheetah for TG any more.

There are also a lot of DRY issues in the quickstart/update command classes (and probably the other tg-admin commands too) and the template classes are misplaced in quickstart.py, they should live in the qstemplates package. The command.quickstart module should be refactored to amend this.

We also need automated tests for the quickstart command with all its options (this is #792). These tests should not only verify that quickstart creates the proper project layout, but also run the unit tests of the quickstarted projects.

Summary of the suggested tasks:

  • create a better quickstart template hierarchy separating model, view and controller files as well as the project directory layout (small, big)
  • use consistent names for these templates
  • use Tempita instead of Cheetah in all quickstart template
  • maybe support more than one templating engine (e.g. Kid, Genshi, Mako)
  • refactor command.quickstart (and maybe other modules in the command package as well)
  • automated tests for quickstart and quickstarted templates

Change History

comment:1 Changed 7 years ago by Chris Arndt

  • Description modified (diff)

I already started refactoring command.quickstart and hope to check in the results over Christmas.

comment:2 Changed 6 years ago by faide

  • Milestone changed from 1.5 to 1.1

comment:3 Changed 5 years ago by Chris Arndt

  • Type changed from enhancement to task

comment:4 Changed 5 years ago by Chris Arndt

  • Milestone changed from 1.1 to 1.1.x bugfix

Moving to 1.1.x bugfix release in preparation for 1.1rc1 release.

comment:5 Changed 5 years ago by Chris Arndt

Moving to 1.1.x bugfix release in preparation for 1.1rc1 release.

comment:6 Changed 5 years ago by Chris Arndt

  • Owner changed from anonymous to Chris Arndt
  • Status changed from new to assigned
  • Description modified (diff)

comment:7 Changed 5 years ago by Chris Arndt

I created a new branch 1.5-quickstart-refactor) to work on this.

comment:8 Changed 5 years ago by Chris Arndt

Some first cleanup and refactoring in r6928. New layout:

template package entry point name
TGBaseTemplate tgbase tgbase
TGAppTemplate tgapp tgapp
TGBigTemplate tgbig tgbig
TGWidgetTemplate tgwidget tgwidget

comment:9 Changed 5 years ago by Chris Arndt

  • Milestone changed from 1.1.x bugfix to 1.5

comment:10 Changed 4 years ago by chrisz

Not sure if it's relevant, but I found the following page when cleaning up the TG 1.0 MoinMoin wiki, and moved it here.


This is a draft of what I plan to do with names:

Current Internal Structure

Commondefaultbigwidget
classBaseTemplateTurbogearsTemplateTGBigTGWidgetTemplate
templateqsbasequickstartquickstartbigwidget
entry pointtgbaseturbogearstgbigtgwidget
  • where class is the name in turbogears/command/quickstart.py
  • template is a dir in qstemplates
  • and entry point is a line in setup.py

Proposed Internal Structure

For now just rename everything to make it consistent, and try to enforce that.

Commondefaultbigwidget
classBaseTemplateDefaultTemplateBigControllerTemplateWidgetTemplate
templatebasedefaultBigControllerwidget
entry pointtgbasetgdefaulttgBigControllertgwidget

This won't affect anything on the external API but show much cleaner code. I'll also like to suggest taking out the big template and putting it into cogbin.

comment:11 Changed 4 years ago by Chris Arndt

  • Owner changed from Chris Arndt to chrisz
  • Status changed from assigned to new
  • Keywords templates, tempita. migrate added; templates tempita removed

I'm afraid that work I have done on this over a year ago is lost, because I didn't manage to merge it at the time, because we have a very old Subversion version on our server.

Since then, so many changes have happedn to the quickstart templates and quickstart command classes that I wouldn't be able to merge my changes in an easy way and anyway, I can't find the working copy with the code at the moment anyway.

I suggest this ticket be migrated to the new tracker or maybe seperate it into several sub tasks.

comment:12 Changed 4 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to migrated
Note: See TracTickets for help on using tickets.