Package gluon :: Module globals :: Class Response
[hide private]
[frames] | no frames]

Class Response

source code

 object --+        
          |        
       dict --+    
              |    
storage.Storage --+
                  |
                 Response

Defines the response object and the default values of its members response.write( ) can be used to write in the output html

Instance Methods [hide private]
new empty dictionary

__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
write(self, data, escape=True) source code
 
render(self, *a, **b) source code
 
include_meta(self) source code
 
include_files(self, extensions=None)
Caching method for writing out files.
source code
 
stream(self, stream, chunk_size=65536, request=None, attachment=False, filename=None)
If in a controller function::
source code
 
download(self, request, db, chunk_size=65536, attachment=True, download_filename=None)
Example of usage in controller:
source code
 
json(self, data, default=None) source code
 
xmlrpc(self, request, methods)
assuming:
source code
 
toolbar(self) source code

Inherited from storage.Storage: __copy__, __delattr__, __getattr__, __getitem__, __getstate__, __repr__, __setattr__, getfirst, getlast, getlist

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __format__, __reduce__, __reduce_ex__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

include_files(self, extensions=None)

source code 

Caching method for writing out files. By default, caches in ram for 5 minutes. To change, response.cache_includes = (cache_method, time_expire). Example: (cache.disk, 60) # caches to disk for 1 minute.

stream(self, stream, chunk_size=65536, request=None, attachment=False, filename=None)

source code 

If in a controller function::

    return response.stream(file, 100)

the file content will be streamed at 100 bytes at the time

Args:
    stream: filename or read()able content
    chunk_size(int): Buffer size
    request: the request object
    attachment(bool): prepares the correct headers to download the file
        as an attachment. Usually creates a pop-up download window
        on browsers
    filename(str): the name for the attachment

Note:
    for using the stream name (filename) with attachments
    the option must be explicitly set as function parameter (will
    default to the last request argument otherwise)

download(self, request, db, chunk_size=65536, attachment=True, download_filename=None)

source code 

Example of usage in controller:

   def download():
       return response.download(request, db)

Downloads from http://..../download/filename

xmlrpc(self, request, methods)

source code 

assuming:

   def add(a, b):
       return a+b

if a controller function "func":

   return response.xmlrpc(request, [add])

the controller will be able to handle xmlrpc requests for the add function. Example:

   import xmlrpclib
   connection = xmlrpclib.ServerProxy(
       'http://hostname/app/contr/func')
   print connection.add(3, 4)