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 ferenda-build.py
tool, you don’t need to directly call any of these methods –
ferenda-build.py
calls run()
, which calls everything
else, for you.
-
class
ferenda.manager.
MarshallingHandler
(records)[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).
Parameters: Returns: 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.
Parameters:
-
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).Parameters: - 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.
Parameters: - inifile (str) – The full path to a
ferenda.ini
configuration file - **kwargs – Configuration values for the wsgi app, overrides those in inifile.
Returns: A WSGI application
Return type: callable
- inifile (str) – The full path to a
-
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.
Parameters:
-
ferenda.manager.
shutdown_logger
()[source]¶ Shuts down the configured logger. In particular, closes any FileHandlers, which is needed on win32 (and is a good idea on all platforms).
-
ferenda.manager.
run
(argv, 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).
-
ferenda.manager.
enable
(classname)[source]¶ 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") 'base' >>> 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
-
ferenda.manager.
runsetup
()[source]¶ Runs
setup()
and exits with a non-zero status if setup failed in any wayNote
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)
Parameters: