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

« back to all changes in this revision

Viewing changes to ivle/dispatch/request.py

Began implementing new dispatch framework (with Will Grant and Nick Chadwick).
Added package: ivle.webapp. This contains 'base', with some base class
    implementations for the new Plugins and Views, and 'admin', with 'user'
    (part of 'userservice') re-implemented for the new framework in a RESTful
    way.
dispatch: Added code to partly handle the new plugin system, then fall back to
    the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
object.
26
26
"""
27
27
 
28
 
try:
29
 
    import mod_python.Session
30
 
    import mod_python.Cookie
31
 
    import mod_python.util
32
 
except ImportError:
33
 
    # This needs to be importable from outside Apache.
34
 
    pass
 
28
import mod_python
 
29
from mod_python import (util, Session, Cookie)
35
30
 
36
31
import ivle.util
37
32
import ivle.conf
282
277
            self.session.invalidate()
283
278
            self.session.delete()
284
279
            # Invalidates all IVLE cookies
285
 
            all_cookies = mod_python.Cookie.get_cookies(self)
 
280
            all_cookies = Cookie.get_cookies(self)
286
281
            for cookie in all_cookies:
287
282
                if cookie in ivle_cookies:
288
 
                    self.add_cookie(mod_python.Cookie.Cookie(cookie,'',expires=1,path='/'))
 
283
                    self.add_cookie(Cookie.Cookie(cookie,'',expires=1,path='/'))
289
284
        self.throw_redirect(ivle.util.make_path('')) 
290
285
 
291
286
 
332
327
    def add_cookie(self, cookie, value=None, **attributes):
333
328
        """Inserts a cookie into this request object's headers."""
334
329
        if value is None:
335
 
            mod_python.Cookie.add_cookie(self.apache_req, cookie)
 
330
            Cookie.add_cookie(self.apache_req, cookie)
336
331
        else:
337
 
            mod_python.Cookie.add_cookie(self.apache_req, cookie, value, **attributes)
 
332
            Cookie.add_cookie(self.apache_req, cookie, value, **attributes)
338
333
 
339
334
    def get_session(self):
340
335
        """Returns a mod_python Session object for this request.
342
337
        interface if porting away from mod_python."""
343
338
        # Cache the session object and set the timeout to 24 hours.
344
339
        if not hasattr(self, 'session'):
345
 
            self.session = mod_python.Session.FileSession(self.apache_req,
 
340
            self.session = Session.FileSession(self.apache_req,
346
341
                                               timeout = 60 * 60 * 24)
347
342
        return self.session
348
343
 
352
347
        interface if porting away from mod_python."""
353
348
        # Cache the fieldstorage object
354
349
        if not hasattr(self, 'fields'):
355
 
            self.fields = mod_python.util.FieldStorage(self.apache_req)
 
350
            self.fields = util.FieldStorage(self.apache_req)
356
351
        return self.fields
357
352
 
358
353
    def get_cgi_environ(self):