Repository: pypi/warehouse

Issue:
Move Filesystems out of the registry
Currently our filesystem access goes through an object that's stored on the registry. This is probably less than ideal. We should investigate other methods (services? Unsure) which don't rely on reaching into the registry as much.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -70,12 +70,10 @@
         "alembic>=0.7.0",
         "Babel",
         "bcrypt",
-        "boto",  # Needed for hosting Documentation on S3
         "boto3",
         "celery>=3.1",
         "click",
         "eventlet",
-        "fs",
         "gunicorn",
         "hiredis",
         "html5lib",
diff --git a/warehouse/config.py b/warehouse/config.py
--- a/warehouse/config.py
+++ b/warehouse/config.py
@@ -14,7 +14,6 @@
 import os
 import shlex
 
-import fs.opener
 import pyramid_services
 import transaction
 import zope.interface
@@ -169,7 +168,6 @@ def configure(settings=None):
     maybe_set(settings, "camo.url", "CAMO_URL")
     maybe_set(settings, "camo.key", "CAMO_KEY")
     maybe_set(settings, "docs.url", "DOCS_URL")
-    maybe_set(settings, "dirs.documentation", "DOCS_DIR")
     maybe_set_compound(settings, "files", "backend", "FILES_BACKEND")
     maybe_set_compound(settings, "origin_cache", "backend", "ORIGIN_CACHE")
 
@@ -333,15 +331,6 @@ def configure(settings=None):
     # sent via POST.
     config.add_tween("warehouse.config.require_https_tween_factory")
 
-    # Configure the filesystems we use.
-    config.registry["filesystems"] = {}
-    for key, path in {
-            k[5:]: v
-            for k, v in config.registry.settings.items()
-            if k.startswith("dirs.")}.items():
-        config.registry["filesystems"][key] = \
-            fs.opener.fsopendir(path, create_dir=True)
-
     # Enable Warehouse to service our static files
     config.add_static_view(
         name="static",


Test patch:
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -12,7 +12,6 @@
 
 from unittest import mock
 
-import fs.opener
 import pretend
 import pytest
 import zope.interface
@@ -231,10 +230,6 @@ def test_find_service_factory(monkeypatch, factory):
     ],
 )
 def test_configure(monkeypatch, settings, environment):
-    fs_obj = pretend.stub()
-    opener = pretend.call_recorder(lambda path, create_dir: fs_obj)
-    monkeypatch.setattr(fs.opener, "fsopendir", opener)
-
     json_renderer_obj = pretend.stub()
     json_renderer_cls = pretend.call_recorder(lambda **kw: json_renderer_obj)
     monkeypatch.setattr(renderers, "JSON", json_renderer_cls)
@@ -419,7 +414,6 @@ def __init__(self):
         pretend.call("warehouse.config.content_security_policy_tween_factory"),
         pretend.call("warehouse.config.require_https_tween_factory"),
     ]
-    assert configurator_obj.registry["filesystems"] == {"packages": fs_obj}
     assert configurator_obj.add_static_view.calls == [
         pretend.call(
             name="static",
@@ -433,9 +427,6 @@ def __init__(self):
     assert configurator_obj.scan.calls == [
         pretend.call(ignore=["warehouse.migrations.env", "warehouse.wsgi"]),
     ]
-    assert opener.calls == [
-        pretend.call("/srv/data/pypi/packages/", create_dir=True),
-    ]
     assert configurator_obj.add_renderer.calls == [
         pretend.call("json", json_renderer_obj),
         pretend.call("xmlrpc", xmlrpc_renderer_obj),