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

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

  • Committer: William Grant
  • Date: 2010-02-23 08:48:09 UTC
  • mfrom: (1673 trunk)
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: grantw@unimelb.edu.au-20100223084809-du6dvsxrjhw15ytr
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
    # Make the request object into an IVLE request which can be given to views
127
127
    req = Request(apachereq, config)
128
128
 
 
129
    # Hack? Try and get the user login early just in case we throw an error
 
130
    # (most likely 404) to stop us seeing not logged in even when we are.
 
131
    if not req.publicmode:
 
132
        user = ivle.webapp.security.get_user_details(req)
 
133
 
 
134
        # Don't set the user if it is disabled or hasn't accepted the ToS.
 
135
        if user and user.valid:
 
136
            req.user = user
 
137
 
129
138
    req.publisher = generate_publisher(
130
 
        config.plugin_index[ViewPlugin], ApplicationRoot(req),
 
139
        config.plugin_index[ViewPlugin],
 
140
        ApplicationRoot(req.config, req.store, req.user),
131
141
        publicmode=req.publicmode)
132
142
 
133
143
    try:
191
201
            handle_unknown_exception(req, *sys.exc_info())
192
202
            return req.OK
193
203
        else:
194
 
            # Commit the transaction if we have a store open.
195
 
            req.commit()
 
204
            req.store.commit()
196
205
            return req.OK
197
206
    except Unauthorized, e:
198
207
        # Resolution failed due to a permission check. Display a pretty
210
219
 
211
220
        return req.OK
212
221
    finally:
213
 
        # Make sure we close the store.
214
 
        req.cleanup()
 
222
        req.store.close()
215
223
 
216
224
def handle_unknown_exception(req, exc_type, exc_value, exc_traceback):
217
225
    """
227
235
    logfile = os.path.join(config['paths']['logs'], 'ivle_error.log')
228
236
    logfail = False
229
237
 
230
 
    req.status = mod_python.apache.HTTP_INTERNAL_SERVER_ERROR
 
238
    # XXX: This remains here for ivle.interpret's IVLEErrors. Once we rewrite
 
239
    #      fileservice, req.status should always be 500 (ISE) here.
 
240
    try:
 
241
        httpcode = exc_value.httpcode
 
242
        req.status = httpcode
 
243
    except AttributeError:
 
244
        httpcode = None
 
245
        req.status = mod_python.apache.HTTP_INTERNAL_SERVER_ERROR
231
246
 
232
247
    try:
233
248
        publicmode = req.publicmode