~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

  • Committer: William Grant
  • Date: 2009-03-01 23:22:05 UTC
  • Revision ID: grantw@unimelb.edu.au-20090301232205-wc78lxf5s8p269fc
Remove some unused functions from groups.js.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
import routes
41
41
 
42
42
from ivle import util
43
 
import ivle.config
 
43
import ivle.conf
44
44
from ivle.dispatch.request import Request
45
45
import ivle.webapp.security
46
46
from ivle.webapp.base.plugins import ViewPlugin, PublicViewPlugin
47
47
from ivle.webapp.base.xhtml import XHTMLView, XHTMLErrorView
48
48
from ivle.webapp.errors import HTTPError, Unauthorized, NotFound
49
49
 
50
 
config = ivle.config.Config()
51
 
 
52
 
def generate_router(view_plugins, attr):
 
50
def generate_route_mapper(view_plugins, attr):
53
51
    """
54
52
    Build a Mapper object for doing URL matching using 'routes', based on the
55
53
    given plugin registry.
73
71
    @param apachereq: An Apache request object.
74
72
    """
75
73
    # Make the request object into an IVLE request which can be given to views
76
 
    req = Request(apachereq, config)
 
74
    req = Request(apachereq)
77
75
 
78
76
    # Hack? Try and get the user login early just in case we throw an error
79
77
    # (most likely 404) to stop us seeing not logged in even when we are.
84
82
        if user and user.valid:
85
83
            req.user = user
86
84
 
 
85
    conf = ivle.config.Config()
 
86
    req.config = conf
 
87
 
87
88
    if req.publicmode:
88
 
        req.mapper = generate_router(config.plugin_index[PublicViewPlugin],
89
 
                                    'public_urls')
 
89
        req.mapper = generate_route_mapper(conf.plugin_index[PublicViewPlugin],
 
90
                                           'public_urls')
90
91
    else:
91
 
        req.mapper = generate_router(config.plugin_index[ViewPlugin], 'urls')
 
92
        req.mapper = generate_route_mapper(conf.plugin_index[ViewPlugin],
 
93
                                           'urls')
92
94
 
93
95
    matchdict = req.mapper.match(req.uri)
94
96
    if matchdict is not None:
126
128
                return req.OK
127
129
            else:
128
130
                return e.code
129
 
        except mod_python.apache.SERVER_RETURN:
130
 
            # A mod_python-specific Apache error.
131
 
            # XXX: We need to raise these because req.throw_error() uses them.
132
 
            # Remove this after Google Code issue 117 is fixed.
133
 
            raise
134
131
        except Exception, e:
135
132
            # A non-HTTPError appeared. We have an unknown exception. Panic.
136
133
            handle_unknown_exception(req, *sys.exc_info())
153
150
    the IVLE request is created.
154
151
    """
155
152
    req.content_type = "text/html"
156
 
    logfile = os.path.join(config['paths']['logs'], 'ivle_error.log')
 
153
    logfile = os.path.join(ivle.conf.log_path, 'ivle_error.log')
157
154
    logfail = False
158
155
    try:
159
156
        httpcode = exc_value.httpcode