summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b1f15bf)
raw | patch | inline | side by side (parent: b1f15bf)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 13 Nov 2003 04:12:10 +0000 (04:12 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 13 Nov 2003 04:12:10 +0000 (04:12 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1984 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/admin.py | patch | blob | history | |
roundup/init.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index c26a27c87033c6a2709b7270044f5abd441d08c9..4cd4ff72e2e226742c296d4c349654708173355c 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- all RDBMS backends now have indexes on several columns
- Change nosymessage and send_message to accept msgid=None (RFE #707235).
- Handle Resent-From: headers (sf bug 841151)
+- Existing trackers (ie. live ones) may be used as templates for new
+ trackers - the TEMPLATE-INFO.txt name entry has the tracker's dir name
+ appended (so the demo tracker's template name is "classic-demo")
Fixed:
- mysql documentation fixed to note requirement of 4.0+ and InnoDB
diff --git a/roundup/admin.py b/roundup/admin.py
index 107e639b0c0774e099bccf3b0d5d99dd0d01eee4..9ae6ba3eb5cb04ea625aeb7076ef262c14e95f81 100644 (file)
--- a/roundup/admin.py
+++ b/roundup/admin.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: admin.py,v 1.60 2003-11-11 00:35:13 richard Exp $
+# $Id: admin.py,v 1.61 2003-11-13 04:12:10 richard Exp $
'''Administration commands for maintaining Roundup trackers.
'''
path = os.path.dirname(path)
tdir = os.path.join(path, 'share', 'roundup', 'templates')
if os.path.isdir(tdir):
- templates = listTemplates(tdir)
+ templates = init.listTemplates(tdir)
break
# OK, now try as if we're in the roundup source distribution
path = os.path.dirname(path)
tdir = os.path.join(path, 'templates')
if os.path.isdir(tdir):
- templates.update(listTemplates(tdir))
+ templates.update(init.listTemplates(tdir))
# Try subdirs of the current dir
- templates.update(listTemplates(os.getcwd()))
+ templates.update(init.listTemplates(os.getcwd()))
# Finally, try the current directory as a template
- template = loadTemplate(os.getcwd())
+ template = init.loadTemplateInfo(os.getcwd())
if template:
templates[template['name']] = template
if self.db:
self.db.close()
-
-def listTemplates(dir):
- ''' List all the Roundup template directories in a given directory.
-
- Find all the dirs that contain a TEMPLATE-INFO.txt and parse it.
-
- Return a list of dicts of info about the templates.
- '''
- ret = {}
- for idir in os.listdir(dir):
- idir = os.path.join(dir, idir)
- ti = loadTemplate(idir)
- if ti:
- ret[ti['name']] = ti
- return ret
-
-def loadTemplate(dir):
- ''' Attempt to load a Roundup template from the indicated directory.
-
- Return None if there's no template, otherwise a template info
- dictionary.
- '''
- ti = os.path.join(dir, 'TEMPLATE-INFO.txt')
- if not os.path.exists(ti):
- return None
-
- # load up the template's information
- m = rfc822.Message(open(ti))
- ti = {}
- ti['name'] = m['name']
- ti['description'] = m['description']
- ti['intended-for'] = m['intended-for']
- ti['path'] = dir
- return ti
-
if __name__ == '__main__':
tool = AdminTool()
sys.exit(tool.main())
diff --git a/roundup/init.py b/roundup/init.py
index 804ed3184757493925107a6db4a80ff211129934..25668c5a49ab6b80164ee9e3228a368ad6f5d2d6 100644 (file)
--- a/roundup/init.py
+++ b/roundup/init.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: init.py,v 1.27 2003-07-28 23:19:21 richard Exp $
+# $Id: init.py,v 1.28 2003-11-13 04:12:10 richard Exp $
__doc__ = """
Init (create) a roundup instance.
"""
-import os, sys, errno
+import os, sys, errno, rfc822
import roundup.instance, password
from roundup import install_util
# At the moment, it's just a copy
copytree(template, instance_home)
+ # rename the tempate in the TEMPLATE-INFO.txt file
+ ti = loadTemplateInfo(instance_home)
+ ti['name'] = ti['name'] + '-' + os.path.split(instance_home)[1]
+ saveTemplateInfo(instance_home, ti)
+
+
+def listTemplates(dir):
+ ''' List all the Roundup template directories in a given directory.
+
+ Find all the dirs that contain a TEMPLATE-INFO.txt and parse it.
+
+ Return a list of dicts of info about the templates.
+ '''
+ ret = {}
+ for idir in os.listdir(dir):
+ idir = os.path.join(dir, idir)
+ ti = loadTemplateInfo(idir)
+ if ti:
+ ret[ti['name']] = ti
+ return ret
+
+def loadTemplateInfo(dir):
+ ''' Attempt to load a Roundup template from the indicated directory.
+
+ Return None if there's no template, otherwise a template info
+ dictionary.
+ '''
+ ti = os.path.join(dir, 'TEMPLATE-INFO.txt')
+ if not os.path.exists(ti):
+ return None
+
+ # load up the template's information
+ f = open(ti)
+ try:
+ m = rfc822.Message(open(ti))
+ ti = {}
+ ti['name'] = m['name']
+ ti['description'] = m['description']
+ ti['intended-for'] = m['intended-for']
+ ti['path'] = dir
+ finally:
+ f.close()
+ return ti
+
+def writeHeader(name, value):
+ ''' Write an rfc822-compatible header line, making it wrap reasonably
+ '''
+ out = [name.capitalize() + ':']
+ n = len(out[0])
+ for word in value.split():
+ if len(word) + n > 74:
+ out.append('\n')
+ n = 0
+ out.append(' ' + word)
+ n += len(out[-1])
+ return ''.join(out) + '\n'
+
+def saveTemplateInfo(dir, info):
+ ''' Save the template info (dict of values) to the TEMPLATE-INFO.txt
+ file in the indicated directory.
+ '''
+ ti = os.path.join(dir, 'TEMPLATE-INFO.txt')
+ f = open(ti, 'w')
+ try:
+ for name in 'name description intended-for path'.split():
+ f.write(writeHeader(name, info[name]))
+ finally:
+ f.close()
+
def write_select_db(instance_home, backend):
''' Write the file that selects the backend for the tracker
'''