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

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

  • Committer: Matt Giuca
  • Date: 2009-05-19 02:54:08 UTC
  • mfrom: (1258 trunk)
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: matt.giuca@gmail.com-20090519025408-19c7cjl7w6ot6frm
MergedĀ fromĀ trunk.

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.conf
 
43
import ivle.config
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
 
def generate_route_mapper(view_plugins, attr):
 
50
config = ivle.config.Config()
 
51
 
 
52
def generate_router(view_plugins, attr):
51
53
    """
52
54
    Build a Mapper object for doing URL matching using 'routes', based on the
53
55
    given plugin registry.
71
73
    @param apachereq: An Apache request object.
72
74
    """
73
75
    # Make the request object into an IVLE request which can be given to views
74
 
    req = Request(apachereq)
 
76
    req = Request(apachereq, config)
75
77
 
76
78
    # Hack? Try and get the user login early just in case we throw an error
77
79
    # (most likely 404) to stop us seeing not logged in even when we are.
82
84
        if user and user.valid:
83
85
            req.user = user
84
86
 
85
 
    conf = ivle.config.Config()
86
 
    req.config = conf
87
 
 
88
87
    if req.publicmode:
89
 
        req.mapper = generate_route_mapper(conf.plugin_index[PublicViewPlugin],
90
 
                                           'public_urls')
 
88
        req.mapper = generate_router(config.plugin_index[PublicViewPlugin],
 
89
                                    'public_urls')
91
90
    else:
92
 
        req.mapper = generate_route_mapper(conf.plugin_index[ViewPlugin],
93
 
                                           'urls')
 
91
        req.mapper = generate_router(config.plugin_index[ViewPlugin], 'urls')
94
92
 
95
93
    matchdict = req.mapper.match(req.uri)
96
94
    if matchdict is not None:
155
153
    the IVLE request is created.
156
154
    """
157
155
    req.content_type = "text/html"
158
 
    logfile = os.path.join(ivle.conf.log_path, 'ivle_error.log')
 
156
    logfile = os.path.join(config['paths']['logs'], 'ivle_error.log')
159
157
    logfail = False
160
158
    try:
161
159
        httpcode = exc_value.httpcode