HandlerManager

This module contains the necessary tools to discover and load the handlers for serving HTTPS

class DIRAC.Core.Tornado.Server.HandlerManager.HandlerManager(autoDiscovery=True)

Bases: object

This utility class allows to load the handlers, generate the appropriate route, and discover the handlers based on the CS. In order for a service to be considered as using HTTPS, it must have protocol = https as an option.

Each of the Handler will have one associated route to it:

  • Directly specified as LOCATION in the handler module

  • automatically deduced from the module name, of the form System/Component (e.g. DataManagement/FileCatalog)

__init__(autoDiscovery=True)

Initialization function, you can set autoDiscovery=False to prevent automatic discovery of handler. If disabled you can use loadHandlersByServiceName() to load your handlers or loadHandlerInHandlerManager()

Parameters

autoDiscovery – (default True) Disable the automatic discovery, can be used to choose service we want to load.

discoverHandlers()

Force the discovery of URL, automatic call when we try to get handlers for the first time. You can disable the automatic call with autoDiscovery=False at initialization

getHandlersDict()

Return all handler dictionary

Returns

dictionary with absolute url as key (“/System/Service”) and tornado.web.url object as value

getHandlersURLs()

Get all handler for usage in Tornado, as a list of tornado.web.url If there is no handler found before, it try to find them

Returns

a list of URL (not the string with “https://…” but the tornado object) see http://www.tornadoweb.org/en/stable/web.html#tornado.web.URLSpec

loadHandlersByServiceName(servicesNames)

Load a list of handler from list of service using DIRAC moduleLoader Use DIRAC.Core.Base.private.ModuleLoader

Parameters

servicesNames – list of service, e.g. [‘Framework/Hello’, ‘Configuration/Server’]

DIRAC.Core.Tornado.Server.HandlerManager.urlFinder(module)

Tries to guess the url from module name. The URL would be of the form /System/Component (e.g. DataManagement/FileCatalog) We search something which looks like <...>.<component>System.<...>.<service>Handler

Parameters

module – full module name (e.g. “DIRAC.something.something”)

Returns

the deduced URL or None