annotate roundup/scripts/roundup_demo.py @ 4587:a2eb4fb3e6d8

New Chameleon templating engine, engine is now configurable. We now have two configurable templating engines, the old Zope TAL templates (called zopetal in the config) and the new Chameleon (called chameleon in the config). A new config-option "template_engine" under [main] can take these config-options, the default is zopetal. Thanks to Cheer Xiao for the idea of making this configurable *and* for the actual implementation! Cheer Xiao commit log: - The original TAL engine ported from Zope is thereafter referred to as "zopetal", in speech and in code - A new option "template_engine" under [main] introduced - Zopetal-specific code stripped from cgi/templating.py to form the new cgi/engine_zopetal.py - Interface to Chameleon in cgi/engine_chameleon.py - Engines are supposed to provide a Templates class that mimics the behavior of the old cgi.templating.Templates. The Templates class is preferably subclassed from cgi.templating.TemplatesBase. - New function cgi.templating.get_templates to get the appropriate engine's Templates instance according to the engine name
author Ralf Schlatterbeck <rsc@runtux.com>
date Thu, 23 Feb 2012 18:10:03 +0100
parents 01e8be352fb8
children 86ef4ab17dc5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2777
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
1 #! /usr/bin/env python
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
2 #
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
3 # Copyright 2004 Richard Jones (richard@mechanicalcat.net)
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
4 #
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
5
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
6 import sys
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
7
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
8 from roundup import admin, configuration, demo, instance
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
9 from roundup.i18n import _
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
10
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
11 DEFAULT_HOME = './demo'
4108
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
12 DEFAULT_TEMPLATE = 'classic'
2777
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
13
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
14 def run():
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
15 home = DEFAULT_HOME
4108
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
16 template = DEFAULT_TEMPLATE
2777
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
17 nuke = sys.argv[-1] == 'nuke'
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
18 # if there is no tracker in home, force nuke
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
19 try:
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
20 instance.open(home)
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
21 except configuration.NoConfigError:
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
22 nuke = 1
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
23 # if we are to create the tracker, prompt for home
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
24 if nuke:
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
25 if len(sys.argv) > 2:
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
26 backend = sys.argv[-2]
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
27 else:
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
28 backend = 'anydbm'
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
29 # FIXME: i'd like to have an option to abort the tracker creation
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
30 # say, by entering a single dot. but i cannot think of
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
31 # appropriate prompt for that.
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
32 home = raw_input(
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
33 _('Enter directory path to create demo tracker [%s]: ') % home)
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
34 if not home:
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
35 home = DEFAULT_HOME
4108
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
36 templates = admin.AdminTool().listTemplates().keys()
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
37 template = raw_input(
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
38 _('Enter tracker template to use (one of (%s)) [%s]: ') %
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
39 (','.join(templates),template))
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
40 if not template:
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
41 template = DEFAULT_TEMPLATE
2777
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
42 # install
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
43 demo.install_demo(home, backend,
4108
01e8be352fb8 Allow user to choose the tracker template for demo.
Stefan Seefeld <stefan@seefeld.name>
parents: 2777
diff changeset
44 admin.AdminTool().listTemplates()[template]['path'])
2777
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
45 # run
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
46 demo.run_demo(home)
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
47
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
48 if __name__ == '__main__':
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
49 run()
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
50
baaf90070dc4 instant-gratification script for binary distributions
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
51 # vim: set et sts=4 sw=4 :

Roundup Issue Tracker: http://roundup-tracker.org/