source: trunk/src/allmydata/web/storage_plugins.py

Last change on this file was 1cfe843d, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-22T23:40:25Z

more python2 removal

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"""
2This module implements a resource which has as children the web resources
3of all enabled storage client plugins.
4
5Ported to Python 3.
6"""
7
8from twisted.web.resource import (
9    Resource,
10    NoResource,
11)
12
13class StoragePlugins(Resource, object):
14    """
15    The parent resource of all enabled storage client plugins' web resources.
16    """
17    def __init__(self, client):
18        """
19        :param _Client client: The Tahoe-LAFS client node object which will be
20            used to find the storage plugin web resources.
21        """
22        Resource.__init__(self)
23        self._client = client
24
25    def getChild(self, segment, request):
26        """
27        Get an ``IResource`` from the loaded, enabled plugin with a name that
28        equals ``segment``.
29
30        :see: ``twisted.web.iweb.IResource.getChild``
31        """
32        resources = self._client.get_client_storage_plugin_web_resources()
33        try:
34            # Technically client could be using some other encoding?
35            result = resources[segment.decode("utf-8")]
36        except KeyError:
37            result = NoResource()
38        self.putChild(segment, result)
39        return result
Note: See TracBrowser for help on using the repository browser.