Package advene :: Package server :: Module webcherry :: Class Common
[hide private]
[frames] | no frames]

Class Common

source code

Known Subclasses:

Common functionalities for all cherrypy nodes.

Instance Methods [hide private]
 
__init__(self, controller=None) source code
 
_cpOnError(self)
Error message handling.
source code
string
location_bar(self)
Returns a string representing the active location bar.
source code
 
no_cache(self)
Write the cache-control headers in the response.
source code
 
start_html(self, title='', headers=None, head_section=None, body_attributes='', mode=None, mimetype=None, duplicate_title=False, cache=False)
Starts writing a HTML response (header + common body start).
source code
 
send_no_content(self)
Sends a No Content (204) response.
source code
 
send_redirect(self, location)
Sends a redirect response.
source code
 
send_error(self, status=404, message=None)
Sends an error response.
source code
string
image_type(self, o)
Return the image type (mime) of the object.
source code
Method Details [hide private]

location_bar(self)

source code 

Returns a string representing the active location bar.

This method will use the current URL path, and return an HTML string where the different components of the path are linked to their URL.

Returns: string
a HTML string

no_cache(self)

source code 

Write the cache-control headers in the response.

This method sends cache-control headers to ensure that the browser does not cache the response, as it may vary from one call to another.

Returns:
nothing

start_html(self, title='', headers=None, head_section=None, body_attributes='', mode=None, mimetype=None, duplicate_title=False, cache=False)

source code 

Starts writing a HTML response (header + common body start).

Parameters:
  • title (string) - Title of the HTML document (default : "")
  • headers (a list of tuples (keyword, value)) - additional headers to add
  • head_section (string) - additional HTML code to add in the <head></head> section
  • body_attributes (string) - attributes added to the body tag
  • mode (string) - presentation mode (navigation, raw). Default: navigation
  • duplicate_title (boolean) - duplicate title as HTML header (h1)
  • cache (boolean) - make the document cacheable. Default: False
Returns:
nothing

send_no_content(self)

source code 

Sends a No Content (204) response.

Mainly used in /media handling.

send_redirect(self, location)

source code 

Sends a redirect response.

As this method generates headers, it must be called before other headers or content.

Parameters:
  • location (string (URL)) - the URL to redirect to.

send_error(self, status=404, message=None)

source code 

Sends an error response.

Parameters:
  • message (string) - the error message

image_type(self, o)

source code 

Return the image type (mime) of the object.

This method examines the content of the given object, and returns either a mime-type if it is an image, None if it is not.

Parameters:
  • o (any) - an object
Returns: string
the content-type if o is an image, else None