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

« back to all changes in this revision

Viewing changes to www/dispatch/request.py

  • Committer: mattgiuca
  • Date: 2008-01-29 23:52:19 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:329
Converted Console from an "app" into a "plugin". It can now be plugged in to
any app.
Added "plugins" directory in www. Added "console" plugin. This contains all of
the functionality of what was previously the console app, but modularized so
it can be imported by another app.

apps/console: Removed most of the logic (moved to plugins/console). Replaced
with a simple import of the console plugin. Should behave exactly the same.
apps/tutorial: As proof of concept, imported the console plugin. It now
appears at the bottom of the page (yet to make it have "pop up" behaviour).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
import common.util
27
27
import mod_python
28
 
from mod_python import (util, Session, Cookie)
 
28
from mod_python import (util, Session)
29
29
import conf
30
30
 
31
31
class Request:
224
224
 
225
225
        if not self.headers_written:
226
226
            self.__writeheaders()
227
 
        if isinstance(string, unicode):
228
 
            # Encode unicode strings as UTF-8
229
 
            # (Otherwise cannot handle being written to a bytestream)
230
 
            self.apache_req.write(string.encode('utf8'), flush)
231
 
        else:
232
 
            # 8-bit clean strings just get written directly.
233
 
            # This includes binary strings.
234
 
            self.apache_req.write(string, flush)
 
227
        self.apache_req.write(string, flush)
235
228
 
236
229
    def flush(self):
237
230
        """Flushes the output buffer."""
271
264
        """
272
265
        mod_python.util.redirect(self.apache_req, location)
273
266
 
274
 
    def add_cookie(self, cookie, value=None, **attributes):
275
 
        """Inserts a cookie into this request object's headers."""
276
 
        if value is None:
277
 
            Cookie.add_cookie(self.apache_req, cookie)
278
 
        else:
279
 
            Cookie.add_cookie(self.apache_req, cookie, value, **attributes)
280
 
 
281
267
    def get_session(self):
282
268
        """Returns a mod_python Session object for this request.
283
269
        Note that this is dependent on mod_python and may need to change
284
270
        interface if porting away from mod_python."""
285
 
        # Cache the session object and set the timeout to 24 hours.
 
271
        # Cache the session object
286
272
        if not hasattr(self, 'session'):
287
 
            self.session = Session.FileSession(self.apache_req,
288
 
                                               timeout = 60 * 60 * 24)
 
273
            self.session = Session.Session(self.apache_req)
289
274
        return self.session
290
275
 
291
276
    def get_fieldstorage(self):