Skip to content

Commit

Permalink
Swap MethodView for View in builder.static_from
Browse files Browse the repository at this point in the history
Static views created with `static_from` had no metadata in the OpenAPI
representation.  This is fixed by subclassing our custom View.
There was a circular import problem, which I
have fixed by removing the `import builder` from `__init__.py`
This wasn't used, and only appeared in `__all__`.
It appears that removing the import has changed nothing;
`from labthings.views import *` still imports the `builder` module.
  • Loading branch information
rwb27 committed Jul 1, 2021
1 parent bdfbcba commit 2f12098
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/labthings/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
build_action_schema,
)
from ..utilities import unpack
from . import builder, op

__all__ = ["MethodView", "View", "ActionView", "PropertyView", "op", "builder"]

Expand Down
6 changes: 3 additions & 3 deletions src/labthings/views/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from typing import Type

from flask import abort, send_file
from flask.views import MethodView
from . import View


def static_from(static_folder: str, name=None) -> Type[MethodView]:
def static_from(static_folder: str, name=None) -> Type[View]:
"""
:param static_folder: str:
:param name: (Default value = None)
Expand Down Expand Up @@ -37,6 +37,6 @@ def _get(_, path=""):
return send_file(indexes[0])

# Generate a basic property class
generated_class = type(name, (MethodView, object), {"get": _get})
generated_class = type(name, (View, object), {"get": _get})

return generated_class

0 comments on commit 2f12098

Please sign in to comment.