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

« back to all changes in this revision

Viewing changes to www/dispatch/__init__.py

  • Committer: wagrant
  • Date: 2008-07-21 23:53:43 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:927
browser, console: Rewrite and extend the Help pages. How does Matt
      manage to conflict with this when they hadn't been edited for 3.5
      months before last night!?

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
# Then passes the request along to the appropriate ivle app.
28
28
 
29
29
import mod_python
30
 
from mod_python import apache, Cookie
 
30
from mod_python import apache
31
31
 
32
32
import sys
33
33
import os
48
48
import plugins.console
49
49
import logging
50
50
import socket
51
 
import time
52
 
 
53
 
# List of cookies that IVLE uses (to be removed at logout)
54
 
ivle_cookies = ["ivleforumcookie", "clipboard"]
55
51
 
56
52
def handler(req):
57
53
    """Handles a request which may be to anywhere in the site except media.
90
86
    """
91
87
    # Hack? Try and get the user login early just in case we throw an error
92
88
    # (most likely 404) to stop us seeing not logged in even when we are.
93
 
    if not req.publicmode:
94
 
        req.user = login.get_user_details(req)
 
89
    req.user = login.get_user_details(req)
95
90
 
96
91
    # Check req.app to see if it is valid. 404 if not.
97
92
    if req.app is not None and req.app not in conf.apps.app_url:
102
97
            req.throw_error(Request.HTTP_NOT_FOUND,
103
98
                "There is no application called %s." % repr(req.app))
104
99
 
105
 
    # Special handling for public mode - only allow the public app, call it
106
 
    # and get out.
 
100
    # Special handling for public mode - just call public app and get out
107
101
    # NOTE: This will not behave correctly if the public app uses
108
102
    # write_html_head_foot, but "serve" does not.
109
103
    if req.publicmode:
110
 
        if req.app != conf.apps.public_app:
111
 
            req.throw_error(Request.HTTP_FORBIDDEN,
112
 
                "This application is not available on the public site.")
113
104
        app = conf.apps.app_url[conf.apps.public_app]
114
105
        apps.call_app(app.dir, req)
115
106
        return req.OK
136
127
        # Well, it's a fine idea, but it creates considerable grief in the
137
128
        # concurrent update department, so instead, we'll just make the
138
129
        # sessions not time out.
139
 
        req.get_session().unlock()
140
 
 
 
130
        
141
131
        # If user did not specify an app, HTTP redirect to default app and
142
132
        # exit.
143
133
        if req.app is None:
178
168
    session = req.get_session()
179
169
    session.invalidate()
180
170
    session.delete()
181
 
    # Invalidates all IVLE cookies
182
 
    all_cookies = Cookie.get_cookies(req)
183
 
    for cookie in all_cookies:
184
 
        if cookie in ivle_cookies:
185
 
            req.add_cookie(Cookie.Cookie(cookie,'',expires=1,path='/'))
186
 
    req.throw_redirect(util.make_path('')) 
 
171
    req.add_cookie(forumutil.invalidated_forum_cookie())
 
172
    req.throw_redirect(util.make_path(''))
187
173
 
188
174
def handle_unknown_exception(req, exc_type, exc_value, exc_traceback):
189
175
    """
221
207
 
222
208
    # Log File
223
209
    try:
224
 
        for h in logging.getLogger().handlers:
225
 
            logging.getLogger().removeHandler(h)
226
210
        logging.basicConfig(level=logging.INFO,
227
211
            format='%(asctime)s %(levelname)s: ' +
228
212
                '(HTTP: ' + str(req.status) +
250
234
        # HTML wrappers).
251
235
        
252
236
        req.write_html_head_foot = True
253
 
        req.write_javascript_settings = False
254
237
        req.write('<div id="ivle_padding">\n')
255
238
        try:
256
239
            codename, msg = req.get_http_codename(httpcode)
277
260
            req.write("<p>Warning: Could not open Error Log: '%s'</p>\n"
278
261
                %cgi.escape(logfile))
279
262
        req.write('</div>\n')
280
 
        html.write_html_foot(req)
281
263
    else:
282
264
        # A "bad" error message. We shouldn't get here unless IVLE
283
265
        # misbehaves (which is currently very easy, if things aren't set up
314
296
        # Logging
315
297
        logging.error('%s\n%s'%(str(msg), tb))
316
298
 
317
 
        req.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"                 
318
 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">                                      
319
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
299
        req.write("""<html>
320
300
<head><title>IVLE Internal Server Error</title></head>
321
301
<body>
322
302
<h1>IVLE Internal Server Error""")
340
320
        if logfail:
341
321
            req.write("<p>Warning: Could not open Error Log: '%s'</p>\n"
342
322
                %cgi.escape(logfile))
343
 
        req.write("</body></html>")
 
323
        req.write("</body>")