module rss.rss_simple_server

Inheritance diagram of pyrsslocal.rss.rss_simple_server

Short summary

module pyrsslocal.rss.rss_simple_server

This modules contains a class which implements a simple server.

source on GitHub

Classes

class

truncated documentation

RSSServer

Defines a RSS server dedicated to one specific database. You can read the blog post RSS Reader. …

RSSSimpleHandler

You can read the blog post RSS Reader. Defines a simple …

Static Methods

staticmethod

truncated documentation

run_server

Starts the server.

Methods

method

truncated documentation

__enter__

What to do when creating the class.

__exit__

What to do when removing the instance (close the log file).

__init__

__init__

Regular constructor, an instance is created for each request, do not store any data for a longer time than a request. …

get_javascript_paths

Returns all the location where the server should look for a java script.

interpret_parameter_as_list_int

Interprets a list of parameters, each of them is a list of integer separated by ,.

main_page

Returns the main page (case the server is called with no path).

process_event

Processes an event, it expects a format like the following:

process_event

Processes an event, and log it.

serve_content_web

Functions to overload (executed after serve_content).

Documentation

This modules contains a class which implements a simple server.

source on GitHub

class pyrsslocal.rss.rss_simple_server.RSSServer(server_address, dbfile, RequestHandlerClass=<class 'pyrsslocal.rss.rss_simple_server.RSSSimpleHandler'>, main_page='rss_reader.html', root='somewhere/workspace/pyrsslocal/pyrsslocal_UT_39_std/_doc/sphinxdoc/source/pyrsslocal/rss', logfile=None, fLOG=None)

Bases: ThreadingMixIn, HTTPServer

Defines a RSS server dedicated to one specific database. You can read the blog post RSS Reader.

source on GitHub

Parameters:
  • server_address – address of the server

  • RequestHandlerClass – it should be RSSSimpleHandler

  • dbfile – database filename (SQLlite format)

  • main_page – main page for the service (when requested with no specific file)

  • root – folder when the server will look into for files such as the main page

  • fLOG – logging function

source on GitHub

__enter__()

What to do when creating the class.

source on GitHub

__exit__(exc_type, exc_value, traceback)

What to do when removing the instance (close the log file).

source on GitHub

__init__(server_address, dbfile, RequestHandlerClass=<class 'pyrsslocal.rss.rss_simple_server.RSSSimpleHandler'>, main_page='rss_reader.html', root='somewhere/workspace/pyrsslocal/pyrsslocal_UT_39_std/_doc/sphinxdoc/source/pyrsslocal/rss', logfile=None, fLOG=None)
Parameters:
  • server_address – address of the server

  • RequestHandlerClass – it should be RSSSimpleHandler

  • dbfile – database filename (SQLlite format)

  • main_page – main page for the service (when requested with no specific file)

  • root – folder when the server will look into for files such as the main page

  • fLOG – logging function

source on GitHub

process_event(event)

Processes an event, it expects a format like the following:

type1/uuid/type2/args
Parameters:

event – string to log

source on GitHub

static run_server(server, dbfile, thread=False, port=8080, logfile=None, fLOG=None)

Starts the server.

Parameters:
  • server – None or string, see below

  • dbfile – file to the RSS database (SQLite)

  • thread – if True, the server is run in a thread and the function returns right away, otherwite, it runs the server.

  • port – port to use

  • logfile – file for the log or “stdout” for the standard output

  • fLOG – logging function

Returns:

server if thread is False, the thread otherwise (the thread is started)

About the parameter server:

  • None, it becomes RSSServer(('localhost', 8080), dbfile, RSSSimpleHandler)

  • <server>, it becomes RSSServer((server, 8080), dbfile, RSSSimpleHandler)

Warning

If you kill the python program while the thread is still running, python interpreter might be closed completely.

source on GitHub

class pyrsslocal.rss.rss_simple_server.RSSSimpleHandler(request, client_address, server)

Bases: SimpleHandler

You can read the blog post RSS Reader. Defines a simple handler used by HTTPServer. Firefox works better for local files. This server serves RSS content.

For every section containing a python script, the class will add a local variable dbrss which gives access to the blogs database. That’s why the following section works:

<script type="text/python">
for blogs in dbrss.enumerate_blogs() :
    print (blogs.html())
</script>

Whenever a url is preceded by /logs/click/`, the class will log an event in the logs. The final page will look like this:

../../_images/page11.png

source on GitHub

Regular constructor, an instance is created for each request, do not store any data for a longer time than a request.

source on GitHub

__init__(request, client_address, server)

Regular constructor, an instance is created for each request, do not store any data for a longer time than a request.

source on GitHub

get_javascript_paths()

Returns all the location where the server should look for a java script.

Returns:

list of paths

source on GitHub

interpret_parameter_as_list_int(ps)

Interprets a list of parameters, each of them is a list of integer separated by ,.

Parameters:

ps – something like params.get("blog_selected")

Returns:

list of int

source on GitHub

main_page()

Returns the main page (case the server is called with no path).

Returns:

default page

source on GitHub

process_event(st)

Processes an event, and log it.

Parameters:

st – string to process

source on GitHub

serve_content_web(path, method, params)

Functions to overload (executed after serve_content).

Parameters:
  • path – ParseResult

  • method – GET or POST

  • params – params parsed from the url + others

source on GitHub