The manager module

Utility functions for running various ferenda tasks from the command line, including registering classes in the configuration file. If you’re using the DocumentRepository API directly in your code, you’ll probably only need makeresources(), frontpage() and possibly setup_logger(). If you’re using the tool, you don’t need to directly call any of these methods – calls run(), which calls everything else, for you.

class ferenda.manager.MarshallingHandler(records)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

exception ferenda.manager.ParseErrorWrapper[source]
ferenda.manager.makeresources(repos, resourcedir='data/rsrc', combine=False, cssfiles=[], jsfiles=[], imgfiles=[], staticsite=False, legacyapi=False, sitename='MySite', sitedescription='Just another Ferenda site', url='http://localhost:8000/')[source]

Creates the web assets/resources needed for the web app (concatenated and minified js/css files, resources.xml used by most XSLT stylesheets, etc).

  • repos (list) – The repositories to create resources for, as instantiated and configured docrepo objects
  • combine (bool) – whether to combine and compact/minify CSS and JS files
  • resourcedir (str) – where to put generated/copied resources

All created/copied css, js and resources.xml files

Return type:

dict of lists

ferenda.manager.frontpage(repos, path='data/index.html', stylesheet='xsl/frontpage.xsl', sitename='MySite', staticsite=False, develurl=None, removeinvalidlinks=True)[source]

Create a suitable frontpage.

  • repos (list) – The repositories to list on the frontpage, as instantiated and configured docrepo objects
  • path (str) – the filename to create.
ferenda.manager.runserver(repos, config=None, port=8000, documentroot='data', apiendpoint='/api/', searchendpoint='/search/', url='http://localhost:8000/', develurl=None, indextype='WHOOSH', indexlocation='data/whooshindex', legacyapi=False)[source]

Starts up a internal webserver and runs the WSGI app (see make_wsgi_app()) using all the specified document repositories. Runs forever (or until interrupted by keyboard).

  • repos (list) – Object instances for the repositories that should be served over HTTP
  • port (int) – The port to use
  • documentroot (str) – The root document, used to locate files not directly handled by any repository
  • apiendpoint (str) – The part of the URI space handled by the API functionality
  • searchendpoint (str) – The part of the URI space handled by the search functionality
ferenda.manager.status(repo, samplesize=3)[source]

Prints out some basic status information about this repository.

ferenda.manager.make_wsgi_app(inifile=None, config=None, **kwargs)[source]

Creates a callable object that can act as a WSGI application by mod_wsgi, gunicorn, the built-in webserver, or any other WSGI-compliant webserver.

  • inifile (str) – The full path to a ferenda.ini configuration file
  • **kwargs – Configuration values for the wsgi app, overrides those in inifile.

A WSGI application

Return type:


ferenda.manager.setup_logger(level='INFO', filename=None, logformat='%(asctime)s %(name)s %(levelname)s %(message)s (%(filename)s:%(lineno)d)', datefmt='%H:%M:%S')[source]

Sets up the logging facilities and creates the module-global log object as a root logger.

  • name (str) – The name of the logger (used in log messages)
  • level (str) – ‘DEBUG’,’INFO’,’WARNING’,’ERROR’ or ‘CRITICAL’
  • filename (str) – The name of the file to log to. If None, log to stdout

Shuts down the configured logger. In particular, closes any FileHandlers, which is needed on win32 (and is a good idea on all platforms)., config=None, subcall=False)[source]

Runs a particular action for either a particular class or all enabled classes.

Parameters:argv – a sys.argv-style list of strings specifying the class to load, the action to run, and additional parameters. The first parameter is either the name of the class-or-alias, or the special value “all”, meaning all registered classes in turn. The second parameter is the action to run, or the special value “all” to run all actions in correct order. Remaining parameters are either configuration parameters (if prefixed with --, e.g. --loglevel=INFO, or positional arguments to the specified action).

Registers a class by creating a section for it in the configuration file (ferenda.ini). Returns the short-form alias for the class.

>>> enable("ferenda.DocumentRepository")
>>> os.unlink("ferenda.ini")
Parameters:classname (str) – The fully qualified name of the class
Returns:The short-form alias for the class
Return type:str

Runs setup() and exits with a non-zero status if setup failed in any way


The ferenda-setup script that gets installed with ferenda is a tiny wrapper around this function.

ferenda.manager.setup(argv=None, force=False, verbose=False, unattended=False)[source]

Creates a project, complete with configuration file and ferenda-build tool.

Checks to see that all required python modules and command line utilities are present. Also checks which triple store(s) are available and selects the best one (in order of preference: Sesame, Fuseki, RDFLib+Sleepycat, RDFLib+SQLite), and checks which fulltextindex(es) are available and selects the best one (in order of preference: ElasticSearch, Whoosh)

  • argv (list) – a sys.argv style command line
  • force (bool) –
  • verbose (bool) –
  • unattended (bool) –
ferenda.manager.runbuildclient(clientname, serverhost, serverport, authkey, processes)[source]
ferenda.manager.runbuildqueue(serverport, authkey)[source]