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

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

  • Committer: me at id
  • Date: 2009-01-14 23:21:43 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1140
ivle.conf, ivle.dispatch: Redo some of Nick's changes made between the
    creation of the 'setup-refactor' branch and its merging into trunk.

svn merge support is absolutely awful and decided to clobber those
    changes without bothering to tell anybody. Thankyou Subversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
from request import Request
49
49
import plugins.console # XXX: Relies on www/ being in the Python path.
50
50
 
51
 
# List of cookies that IVLE uses (to be removed at logout)
52
 
ivle_cookies = ["ivleforumcookie", "clipboard"]
53
 
 
54
51
def handler(req):
55
52
    """Handles a request which may be to anywhere in the site except media.
56
53
    Intended to be called by mod_python, as a handler.
93
90
 
94
91
    # Check req.app to see if it is valid. 404 if not.
95
92
    if req.app is not None and req.app not in ivle.conf.apps.app_url:
96
 
        # Maybe it is a special app!
97
 
        if req.app == 'logout':
98
 
            logout(req)
99
 
        else:
100
 
            req.throw_error(Request.HTTP_NOT_FOUND,
101
 
                "There is no application called %s." % repr(req.app))
 
93
        req.throw_error(Request.HTTP_NOT_FOUND,
 
94
            "There is no application called %s." % repr(req.app))
102
95
 
103
96
    # Special handling for public mode - only allow the public app, call it
104
97
    # and get out.
170
163
    # Use req.throw_error to do that.
171
164
    return req.OK
172
165
 
173
 
def logout(req):
174
 
    """Log out the current user (if any) by destroying the session state.
175
 
    Then redirect to the top-level IVLE page."""
176
 
    session = req.get_session()
177
 
    session.invalidate()
178
 
    session.delete()
179
 
    # Invalidates all IVLE cookies
180
 
    all_cookies = Cookie.get_cookies(req)
181
 
    for cookie in all_cookies:
182
 
        if cookie in ivle_cookies:
183
 
            req.add_cookie(Cookie.Cookie(cookie,'',expires=1,path='/'))
184
 
    req.throw_redirect(util.make_path('')) 
185
 
 
186
166
def handle_unknown_exception(req, exc_type, exc_value, exc_traceback):
187
167
    """
188
168
    Given an exception that has just been thrown from IVLE, print its details