forked from goodboy/tractor
1
0
Fork 0

Add `NamespacePath._ns` todo for `self:<ns.meth>` support

modden_spawn_from_client_req
Tyler Goodlet 2024-02-20 15:28:11 -05:00
parent f568fca98f
commit 179d7d2b04
1 changed files with 15 additions and 2 deletions

View File

@ -58,6 +58,11 @@ class NamespacePath(str):
''' '''
_ref: object | type | None = None _ref: object | type | None = None
# TODO: support providing the ns instance in
# order to support 'self.<meth>` style to make
# `Portal.run_from_ns()` work!
# _ns: ModuleType|type|None = None
def load_ref(self) -> object | type: def load_ref(self) -> object | type:
if self._ref is None: if self._ref is None:
self._ref = resolve_name(self) self._ref = resolve_name(self)
@ -100,5 +105,13 @@ class NamespacePath(str):
fqnp: tuple[str, str] = cls._mk_fqnp(ref) fqnp: tuple[str, str] = cls._mk_fqnp(ref)
return cls(':'.join(fqnp)) return cls(':'.join(fqnp))
def to_tuple(self) -> tuple[str, str]: def to_tuple(
return self._mk_fqnp(self.load_ref()) self,
# TODO: could this work re `self:<meth>` case from above?
# load_ref: bool = True,
) -> tuple[str, str]:
return self._mk_fqnp(
self.load_ref()
)