Skip to content

Commit a12e0a1

Browse files
author
Richard Jones
committed
Load up extensions in the tracker "extensions" directory.
Wrote a proof-of-concept action, is in the wiki. Cleaned up the schema.py file of spaces-at-eol.
1 parent be7659d commit a12e0a1

File tree

4 files changed

+41
-23
lines changed

4 files changed

+41
-23
lines changed

roundup/cgi/client.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.184 2004-07-20 02:07:58 richard Exp $
1+
# $Id: client.py,v 1.185 2004-07-27 02:30:31 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -654,13 +654,19 @@ def handle_action(self):
654654
action = self.form['@action'].value.lower()
655655
else:
656656
return None
657+
657658
try:
658-
# get the action, validate it
659-
for name, action_klass in self.actions:
660-
if name == action:
661-
break
659+
if (hasattr(self.instance, 'cgi_actions') and
660+
self.instance.cgi_actions.has_key(action)):
661+
# tracker-defined action
662+
action_klass = self.instance.cgi_actions[action]
662663
else:
663-
raise ValueError, 'No such action "%s"'%action
664+
# go with a default
665+
for name, action_klass in self.actions:
666+
if name == action:
667+
break
668+
else:
669+
raise ValueError, 'No such action "%s"'%action
664670

665671
# call the mapped action
666672
if isinstance(action_klass, type('')):

roundup/instance.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: instance.py,v 1.17 2004-07-27 00:57:18 richard Exp $
18+
# $Id: instance.py,v 1.18 2004-07-27 02:30:31 richard Exp $
1919

2020
'''Tracker handling (open tracker).
2121
@@ -64,16 +64,22 @@ def open(self, name):
6464
self._load_python('schema.py', vars)
6565
db = vars['db']
6666

67-
detectors_dir = os.path.join(self.tracker_home, 'detectors')
68-
for name in os.listdir(detectors_dir):
69-
if not name.endswith('.py'):
70-
continue
71-
self._load_python(os.path.join('detectors', name), vars)
72-
vars['init'](db)
67+
self.load_extensions(db, 'detectors')
68+
69+
self.load_extensions(self, 'extensions')
7370

7471
db.post_init()
7572
return db
7673

74+
def load_extensions(self, parent, dirname):
75+
dirname = os.path.join(self.tracker_home, dirname)
76+
for name in os.listdir(dirname):
77+
if not name.endswith('.py'):
78+
continue
79+
vars = {}
80+
self._load_python(os.path.join(dirname, name), vars)
81+
vars['init'](parent)
82+
7783
def init(self, adminpw):
7884
db = self.open('admin')
7985
self._load_python('initial_data.py', {'db': db, 'adminpw': adminpw,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This directory is for tracker extensions:
2+
3+
- CGI Actions
4+
- Templating functions
5+
6+
See the customisation doc for more information.

templates/classic/schema.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
# actor = Link('user')
1111

1212
# Priorities
13-
pri = Class(db, "priority",
13+
pri = Class(db, "priority",
1414
name=String(),
1515
order=Number())
1616
pri.setkey("name")
1717

1818
# Statuses
19-
stat = Class(db, "status",
19+
stat = Class(db, "status",
2020
name=String(),
2121
order=Number())
2222
stat.setkey("name")
2323

2424
# Keywords
25-
keyword = Class(db, "keyword",
25+
keyword = Class(db, "keyword",
2626
name=String())
2727
keyword.setkey("name")
2828

@@ -35,11 +35,11 @@
3535

3636
# add any additional database schema configuration here
3737

38-
user = Class(db, "user",
38+
user = Class(db, "user",
3939
username=String(),
4040
password=Password(),
4141
address=String(),
42-
realname=String(),
42+
realname=String(),
4343
phone=String(),
4444
organisation=String(),
4545
alternate_addresses=String(),
@@ -50,16 +50,16 @@
5050

5151
# FileClass automatically gets this property in addition to the Class ones:
5252
# content = String() [saved to disk in <tracker home>/db/files/]
53-
msg = FileClass(db, "msg",
53+
msg = FileClass(db, "msg",
5454
author=Link("user", do_journal='no'),
55-
recipients=Multilink("user", do_journal='no'),
55+
recipients=Multilink("user", do_journal='no'),
5656
date=Date(),
57-
summary=String(),
57+
summary=String(),
5858
files=Multilink("file"),
5959
messageid=String(),
6060
inreplyto=String())
6161

62-
file = FileClass(db, "file",
62+
file = FileClass(db, "file",
6363
name=String(),
6464
type=String())
6565

@@ -69,7 +69,7 @@
6969
# files = Multilink("file")
7070
# nosy = Multilink("user")
7171
# superseder = Multilink("issue")
72-
issue = IssueClass(db, "issue",
72+
issue = IssueClass(db, "issue",
7373
assignedto=Link("user"),
7474
topic=Multilink("keyword"),
7575
priority=Link("priority"),

0 commit comments

Comments
 (0)