Skip to content

Commit

Permalink
Make DemoServer require an App
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed Jun 21, 2024
1 parent 4919a13 commit 0732c00
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions betty/extension/demo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
Project,
)
from betty.serve import Server, NoPublicUrlBecauseServerNotStartedError
from betty.warnings import deprecate

if TYPE_CHECKING:
from betty.model import Entity
Expand Down Expand Up @@ -508,18 +507,12 @@ class DemoServer(Server):

def __init__(
self,
*,
app: App | None = None,
app: App,
):
super().__init__(localizer=DEFAULT_LOCALIZER)
self._app = app
self._server: Server | None = None
self._exit_stack = AsyncExitStack()
if app is None:
deprecate(
f"Initializing {type(self)} with a project ID is deprecated as of Betty 0.3.2, and will be removed in Betty 0.4.x. Instead, set {type(self)}.configuration.name.",
stacklevel=2,
)

@override
@classmethod
Expand All @@ -539,15 +532,10 @@ async def start(self) -> None:

await super().start()
project = Demo.project()
if self._app is None:
isolated_app_factory = App.new_from_environment(
project=project,
)
else:
isolated_app_factory = App.new_from_app(
self._app,
project=project,
)
isolated_app_factory = App.new_from_app(
self._app,
project=project,
)
try:
isolated_app = await self._exit_stack.enter_async_context(
isolated_app_factory
Expand Down

0 comments on commit 0732c00

Please sign in to comment.