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

« back to all changes in this revision

Viewing changes to ivle/dispatch/request.py

  • Committer: William Grant
  • Date: 2010-02-26 02:35:30 UTC
  • Revision ID: grantw@unimelb.edu.au-20100226023530-0m5t99dwf0prfowv
Move PotentiallySecureFileSession into the try/export import block, so ivle.dispatch.request can be imported from outside Apache.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    import mod_python.Cookie
31
31
    import mod_python.util
32
32
    import mod_python.apache
 
33
 
 
34
    class PotentiallySecureFileSession(mod_python.Session.FileSession):
 
35
        """A mod_python FileSession that sets secure cookie when appropriate.
 
36
 
 
37
        A secure cookie will be set if the request itself is over HTTPS, or if
 
38
        a proxy in front has set X-Forwarded-Proto: https. Otherwise the cookie
 
39
        will be insecure.
 
40
        """
 
41
        def make_cookie(self):
 
42
            cookie = super(PotentiallySecureFileSession, self).make_cookie()
 
43
            if (self._req.is_https() or
 
44
                self._req.headers_in.get('X-Forwarded-Proto') == 'https'):
 
45
                cookie.secure = True
 
46
            return cookie
33
47
except ImportError:
34
48
    # This needs to be importable from outside Apache.
35
49
    pass
42
56
import ivle.webapp.security
43
57
 
44
58
 
45
 
class PotentiallySecureFileSession(mod_python.Session.FileSession):
46
 
    """A mod_python FileSession that sets secure cookie when appropriate.
47
 
 
48
 
    A secure cookie will be set if the request itself is over HTTPS, or if
49
 
    a proxy in front has set X-Forwarded-Proto: https. Otherwise the cookie
50
 
    will be insecure.
51
 
    """
52
 
    def make_cookie(self):
53
 
        cookie = super(PotentiallySecureFileSession, self).make_cookie()
54
 
        if (self._req.is_https() or
55
 
            self._req.headers_in.get('X-Forwarded-Proto') == 'https'):
56
 
            cookie.secure = True
57
 
        return cookie
58
 
 
59
 
 
60
59
class Request:
61
60
    """An IVLE request object. This is presented to the IVLE apps as a way of
62
61
    interacting with the web server and the dispatcher.