Module common

Base class of all the publishers

Imports:
configobj, nagare, paste, random
Classes:
Publisher(object): Base class of all the publishers
Methods:
serve_file(filename): Create a WSGI application that return a static file

Class common.Publisher

Back to common

Bases:
object

Base class of all the publishers

Methods:
__init__(self): Initialisation
_validate_conf(self, filename, conf, error): Validate the configuration read from the publisher configuration file
get_registered_applications(self): Return all the applications registered on this publisher
on_new_process(self): The publisher has started a new process
register_application(self, app_name, name, app, wsgi_pipe): Register an application to launch
register_static(self, name, get_file): Register a WSGI application to serve static contents
serve(self, filename, conf, error): Run the publisher
Attributes:
default_port = 8080
spec = { }

Method common.Publisher._validate_conf

Back to common.Publisher

Arguments:
self, filename, conf, error

Validate the configuration read from the publisher configuration file

In:
  • filename -- the path to the configuration file
  • conf -- the ConfigObj object, created from the configuration file
  • error -- the function to call in case of configuration errors
Return:
  • the tuple:
    • hostname to listen to
    • port to listen to
    • conf object

Method common.Publisher.register_application

Back to common.Publisher

Arguments:
self, app_name, name, app, wsgi_pipe

Register an application to launch

In:
  • app_name -- name of the application
  • name -- url of the application
  • app -- the WSGI application
  • wsgi_pipe -- the pipe of WSGI "middlewares"

Method common.Publisher.register_static

Back to common.Publisher

Arguments:
self, name, get_file

Register a WSGI application to serve static contents

In:
  • name -- the URL of the contents will be prefix by /static/<name>/
  • get_file -- function that will received the URL of the static content and will return its filename
Return:
  • URL prefix (/static/<name>/)

Method common.Publisher.serve

Back to common.Publisher

Arguments:
self, filename, conf, error

Run the publisher

In:
  • filename -- the path to the configuration file
  • conf -- the ConfigObj object, created from the configuration file
  • error -- the function to call in case of configuration errors

Method common.serve_file

Back to common

Arguments:
filename

Create a WSGI application that return a static file

In:
  • filename -- path of the file to serve
Return:
  • a WSGI application