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

« back to all changes in this revision

Viewing changes to ivle/dispatch/request.py

ivle.dispatch{,.{login,request}}: Fix mod_python imports to ensure that we can
    be imported from outside Apache.

Show diffs side-by-side

added added

removed removed

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