53
# XXX List of plugins, which will eventually be read in from conf
55
'ivle.webapp.core#Plugin',
56
'ivle.webapp.admin.user#Plugin',
57
'ivle.webapp.tutorial#Plugin',
58
'ivle.webapp.admin.subject#Plugin',
59
'ivle.webapp.filesystem.browser#Plugin',
60
'ivle.webapp.filesystem.diff#Plugin',
61
'ivle.webapp.filesystem.svnlog#Plugin',
62
'ivle.webapp.filesystem.serve#Plugin',
63
'ivle.webapp.groups#Plugin',
64
'ivle.webapp.console#Plugin',
65
'ivle.webapp.security#Plugin',
66
'ivle.webapp.media#Plugin',
67
'ivle.webapp.forum#Plugin',
68
'ivle.webapp.help#Plugin',
69
'ivle.webapp.tos#Plugin',
70
'ivle.webapp.userservice#Plugin',
73
52
def generate_route_mapper(view_plugins, attr):
75
54
Build a Mapper object for doing URL matching using 'routes', based on the
86
65
m.connect(routex, view=view_class, **kwargs_dict)
89
def get_plugin(pluginstr):
90
plugin_path, classname = pluginstr.split('#')
91
# Load the plugin module from somewhere in the Python path
92
# (Note that plugin_path is a fully-qualified Python module name).
94
getattr(__import__(plugin_path, fromlist=[classname]), classname))
97
69
"""Handles a request which may be to anywhere in the site except media.
98
70
Intended to be called by mod_python, as a handler.
137
109
if user and user.valid:
112
conf = ivle.config.Config()
140
115
### BEGIN New plugins framework ###
141
# XXX This should be done ONCE per Python process, not per request.
143
req.plugins = dict([get_plugin(pluginstr) for pluginstr in plugins_HACK])
144
# Index the plugins by base class
145
req.plugin_index = {}
146
for plugin in req.plugins.values():
147
# Getmro returns a tuple of all the super-classes of the plugin
148
for base in inspect.getmro(plugin):
149
if base not in req.plugin_index:
150
req.plugin_index[base] = []
151
req.plugin_index[base].append(plugin)
152
req.reverse_plugins = dict([(v, k) for (k, v) in req.plugins.items()])
154
116
if req.publicmode:
155
req.mapper = generate_route_mapper(req.plugin_index[PublicViewPlugin],
117
req.mapper = generate_route_mapper(conf.plugin_index[PublicViewPlugin],
158
req.mapper = generate_route_mapper(req.plugin_index[ViewPlugin],
120
req.mapper = generate_route_mapper(conf.plugin_index[ViewPlugin],
161
123
matchdict = req.mapper.match(req.uri)
382
344
msg = exc_value.message
383
345
# Prepend the exception type
384
346
if exc_type != util.IVLEError:
385
msg = exc_type.__name__ + ": " + msg
347
msg = exc_type.__name__ + ": " + repr(msg)
387
349
tb = ''.join(traceback.format_exception(exc_type, exc_value,