Skip to content

Commit

Permalink
fqn shouldn't contains ":", only dots to the class
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Sep 1, 2023
1 parent c5722a9 commit 393839a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 7 additions & 11 deletions htagweb/appserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@
from .webbase import findfqn


def fqn2hr(fqn:str,js:str,init,session):
if ":" in fqn:
# no ambiguity
klass=getClass(fqn)
else:
if fqn.endswith(".App"):
# ensure compat (module.App -> module:App)
klass=getClass(fqn[:-4]+":App")
else:
klass=getClass(fqn+":App")
def fqn2hr(fqn:str,js:str,init,session): # fqn is a "full qualified name", full !
if ":" not in fqn:
# replace last "." by ":"
fqn="".join( reversed("".join(reversed(fqn)).replace(".",":",1)))

klass=getClass(fqn)

return HRenderer( klass, js, init=init, session = session)

Expand Down Expand Up @@ -144,7 +140,7 @@ async def handleHome(request):
self.add_route( '/', handleHome )

async def serve(self, request, obj, **NONUSED ) -> HTMLResponse:
fqn=findfqn(obj,":")
fqn=findfqn(obj)
protocol = "wss" if self.ssl else "ws"
if self.parano:
jsparano = crypto.JSCRYPTO
Expand Down
4 changes: 2 additions & 2 deletions htagweb/webbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def send_wrapper(message: Message) -> None:



def findfqn(x,separator=".") -> str:
def findfqn(x) -> str:
if isinstance(x,str):
if ("." not in x) and (":" not in x):
raise Exception(f"'{x}' is not a 'full qualified name' (expected 'module.name') of an App (htag.Tag class)")
Expand All @@ -130,7 +130,7 @@ def findfqn(x,separator=".") -> str:
else:
raise Exception(f"!!! wtf ({x}) ???")

return tagClass.__module__+separator+tagClass.__qualname__
return tagClass.__module__+"."+tagClass.__qualname__


class WebBase(Starlette):
Expand Down

0 comments on commit 393839a

Please sign in to comment.