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

« back to all changes in this revision

Viewing changes to ivle/dispatch/request.py

  • Committer: me at id
  • Date: 2009-01-14 22:59:55 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1134
apps/debuginfo: Don't use req.user as a dict, and otherwise make it work
    properly. Also cgi.escape some things that need it.

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
272
267
            # This includes binary strings.
273
268
            self.apache_req.write(string, flush)
274
269
 
275
 
    def logout(self):
276
 
        """Log out the current user by destroying the session state.
277
 
        Then redirect to the top-level IVLE page."""
278
 
        # List of cookies that IVLE uses (to be removed at logout)
279
 
        ivle_cookies = ["ivleforumcookie", "clipboard"]
280
 
        
281
 
        if hasattr(self, 'session'):
282
 
            self.session.invalidate()
283
 
            self.session.delete()
284
 
            # Invalidates all IVLE cookies
285
 
            all_cookies = mod_python.Cookie.get_cookies(self)
286
 
            for cookie in all_cookies:
287
 
                if cookie in ivle_cookies:
288
 
                    self.add_cookie(mod_python.Cookie.Cookie(cookie,'',expires=1,path='/'))
289
 
        self.throw_redirect(ivle.util.make_path('')) 
290
 
 
291
 
 
292
270
    def flush(self):
293
271
        """Flushes the output buffer."""
294
272
        self.apache_req.flush()
332
310
    def add_cookie(self, cookie, value=None, **attributes):
333
311
        """Inserts a cookie into this request object's headers."""
334
312
        if value is None:
335
 
            mod_python.Cookie.add_cookie(self.apache_req, cookie)
 
313
            Cookie.add_cookie(self.apache_req, cookie)
336
314
        else:
337
 
            mod_python.Cookie.add_cookie(self.apache_req, cookie, value, **attributes)
 
315
            Cookie.add_cookie(self.apache_req, cookie, value, **attributes)
338
316
 
339
317
    def get_session(self):
340
318
        """Returns a mod_python Session object for this request.
342
320
        interface if porting away from mod_python."""
343
321
        # Cache the session object and set the timeout to 24 hours.
344
322
        if not hasattr(self, 'session'):
345
 
            self.session = mod_python.Session.FileSession(self.apache_req,
 
323
            self.session = Session.FileSession(self.apache_req,
346
324
                                               timeout = 60 * 60 * 24)
347
325
        return self.session
348
326
 
352
330
        interface if porting away from mod_python."""
353
331
        # Cache the fieldstorage object
354
332
        if not hasattr(self, 'fields'):
355
 
            self.fields = mod_python.util.FieldStorage(self.apache_req)
 
333
            self.fields = util.FieldStorage(self.apache_req)
356
334
        return self.fields
357
335
 
358
336
    def get_cgi_environ(self):