2019-07-24 19:37:24 +00:00
|
|
|
"""
|
|
|
|
This module implements a resource which has as children the web resources
|
|
|
|
of all enabled storage client plugins.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from twisted.web.resource import (
|
|
|
|
Resource,
|
|
|
|
NoResource,
|
|
|
|
)
|
|
|
|
|
2019-08-19 15:26:32 +00:00
|
|
|
class StoragePlugins(Resource, object):
|
2019-07-24 19:37:24 +00:00
|
|
|
"""
|
|
|
|
The parent resource of all enabled storage client plugins' web resources.
|
|
|
|
"""
|
|
|
|
def __init__(self, client):
|
|
|
|
"""
|
|
|
|
:param _Client client: The Tahoe-LAFS client node object which will be
|
|
|
|
used to find the storage plugin web resources.
|
|
|
|
"""
|
|
|
|
Resource.__init__(self)
|
|
|
|
self._client = client
|
|
|
|
|
|
|
|
def getChild(self, segment, request):
|
|
|
|
"""
|
|
|
|
Get an ``IResource`` from the loaded, enabled plugin with a name that
|
|
|
|
equals ``segment``.
|
|
|
|
|
|
|
|
:see: ``twisted.web.iweb.IResource.getChild``
|
|
|
|
"""
|
|
|
|
resources = self._client.get_client_storage_plugin_web_resources()
|
|
|
|
try:
|
2019-11-19 17:56:38 +00:00
|
|
|
result = resources[segment]
|
2019-07-24 19:37:24 +00:00
|
|
|
except KeyError:
|
2019-11-19 17:56:38 +00:00
|
|
|
result = NoResource()
|
|
|
|
self.putChild(segment, result)
|
|
|
|
return result
|