Skip to content

Commit 5391b78

Browse files
committed
🎨 Refactor permalink factory key to use PROJECT_PERMALINK_FACTORY for consistency
1 parent c29bfb5 commit 5391b78

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

services/web/server/src/simcore_service_webserver/projects/_permalink_service.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import logging
3-
from typing import Protocol, cast
3+
from typing import Final, Protocol, cast
44

55
from aiohttp import web
66
from models_library.api_schemas_webserver.permalinks import ProjectPermalink
@@ -10,7 +10,6 @@
1010
from .exceptions import PermalinkFactoryError, PermalinkNotAllowedError
1111
from .models import ProjectDict
1212

13-
_PROJECT_PERMALINK = f"{__name__}"
1413
_logger = logging.getLogger(__name__)
1514

1615

@@ -24,15 +23,20 @@ async def __call__(
2423
) -> ProjectPermalink: ...
2524

2625

26+
_PROJECT_PERMALINK_FACTORY_APPKEY: Final = web.AppKey(
27+
"PROJECT_PERMALINK_FACTORY", CreateLinkCoroutine
28+
)
29+
30+
2731
def register_factory(app: web.Application, factory_coro: CreateLinkCoroutine):
28-
if _create := app.get(_PROJECT_PERMALINK):
32+
if _create := app.get(_PROJECT_PERMALINK_FACTORY_APPKEY):
2933
msg = f"Permalink factory can only be set once: registered {_create}"
3034
raise PermalinkFactoryError(msg)
31-
app[_PROJECT_PERMALINK] = factory_coro
35+
app[_PROJECT_PERMALINK_FACTORY_APPKEY] = factory_coro
3236

3337

3438
def _get_factory(app: web.Application) -> CreateLinkCoroutine:
35-
if _create := app.get(_PROJECT_PERMALINK):
39+
if _create := app.get(_PROJECT_PERMALINK_FACTORY_APPKEY):
3640
return cast(CreateLinkCoroutine, _create)
3741

3842
msg = "Undefined permalink factory. Check plugin initialization."

0 commit comments

Comments
 (0)