Line | |
---|
1 | """ |
---|
2 | This module implements a resource which has as children the web resources |
---|
3 | of all enabled storage client plugins. |
---|
4 | |
---|
5 | Ported to Python 3. |
---|
6 | """ |
---|
7 | |
---|
8 | from twisted.web.resource import ( |
---|
9 | Resource, |
---|
10 | NoResource, |
---|
11 | ) |
---|
12 | |
---|
13 | class 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.