Mercurial > p > roundup > code
comparison roundup/instance.py @ 4083:bbab97f8ffb2
XMLRPC improvements:
* Add support for actions to XMLRPC interface.
* Provide bridge so user actions may be executed
either via CGI or XMLRPC.
* Adjust XMLRPC tests to recent work.
* Cleanup.
| author | Stefan Seefeld <stefan@seefeld.name> |
|---|---|
| date | Fri, 27 Feb 2009 17:46:47 +0000 |
| parents | 74aebbbea305 |
| children | 61cf00ca920a |
comparison
equal
deleted
inserted
replaced
| 4082:5eb5f7e66c37 | 4083:bbab97f8ffb2 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: instance.py,v 1.37 2006-12-11 23:36:15 richard Exp $ | 18 |
| 19 | 19 """Tracker handling (open tracker). |
| 20 '''Tracker handling (open tracker). | |
| 21 | 20 |
| 22 Backwards compatibility for the old-style "imported" trackers. | 21 Backwards compatibility for the old-style "imported" trackers. |
| 23 ''' | 22 """ |
| 24 __docformat__ = 'restructuredtext' | 23 __docformat__ = 'restructuredtext' |
| 25 | 24 |
| 26 import os | 25 import os |
| 27 import sys | 26 import sys |
| 28 from roundup import configuration, mailgw | 27 from roundup import configuration, mailgw |
| 29 from roundup import hyperdb, backends | 28 from roundup import hyperdb, backends, actions |
| 30 from roundup.cgi import client, templating | 29 from roundup.cgi import client, templating |
| 30 from roundup.cgi import actions as cgi_actions | |
| 31 | 31 |
| 32 class Vars: | 32 class Vars: |
| 33 def __init__(self, vars): | 33 def __init__(self, vars): |
| 34 self.__dict__.update(vars) | 34 self.__dict__.update(vars) |
| 35 | 35 |
| 45 | 45 |
| 46 """ | 46 """ |
| 47 self.tracker_home = tracker_home | 47 self.tracker_home = tracker_home |
| 48 self.optimize = optimize | 48 self.optimize = optimize |
| 49 self.config = configuration.CoreConfig(tracker_home) | 49 self.config = configuration.CoreConfig(tracker_home) |
| 50 self.actions = {} | |
| 50 self.cgi_actions = {} | 51 self.cgi_actions = {} |
| 51 self.templating_utils = {} | 52 self.templating_utils = {} |
| 52 self.load_interfaces() | 53 self.load_interfaces() |
| 53 self.templates = templating.Templates(self.config["TEMPLATES"]) | 54 self.templates = templating.Templates(self.config["TEMPLATES"]) |
| 54 self.backend = backends.get_backend(self.get_backend_name()) | 55 self.backend = backends.get_backend(self.get_backend_name()) |
| 180 file = os.path.join(self.tracker_home, file) | 181 file = os.path.join(self.tracker_home, file) |
| 181 execfile(file, vars) | 182 execfile(file, vars) |
| 182 return vars | 183 return vars |
| 183 | 184 |
| 184 def registerAction(self, name, action): | 185 def registerAction(self, name, action): |
| 185 self.cgi_actions[name] = action | 186 |
| 187 # The logic here is this: | |
| 188 # * if `action` derives from actions.Action, | |
| 189 # it is executable as a generic action. | |
| 190 # * if, moreover, it also derives from cgi.actions.Bridge, | |
| 191 # it may in addition be called via CGI | |
| 192 # * in all other cases we register it as a CGI action, without | |
| 193 # any check (for backward compatibility). | |
| 194 if issubclass(action, actions.Action): | |
| 195 self.actions[name] = action | |
| 196 if issubclass(action, cgi_actions.Bridge): | |
| 197 self.cgi_actions[name] = action | |
| 198 else: | |
| 199 self.cgi_actions[name] = action | |
| 186 | 200 |
| 187 def registerUtil(self, name, function): | 201 def registerUtil(self, name, function): |
| 188 self.templating_utils[name] = function | 202 self.templating_utils[name] = function |
| 189 | 203 |
| 190 class TrackerError(Exception): | 204 class TrackerError(Exception): |
