Skip to content

Commit

Permalink
fix(www): Allow www to support dict module
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Oct 24, 2023
1 parent 51e14d1 commit adc43a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion trame/tools/widgets/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def create_base_structure(ref_path, config, output):
file.write("\n\n")

all_class_names = []
for (class_name, class_info) in config[name][sub_name][
for class_name, class_info in config[name][sub_name][
module
].items():
if class_name == "directives":
Expand Down
15 changes: 9 additions & 6 deletions trame/tools/www.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@ def add_protocol_to_configure(self, *args, **kwargs):
pass

def enable_module(self, module, **kwargs):
# Make sure definitions is a dict
definitions = module if isinstance(module, dict) else module.__dict__

load_remaining = False
if "setup" in module.__dict__:
if "setup" in definitions:
try:
module.setup(self)
definitions.get("setup")(self)
load_remaining = True
except TypeError:
pass # Skip incompatible modules
else:
load_remaining = True

if load_remaining:
if "serve" in module.__dict__:
self.serve.update(module.serve)
if "serve" in definitions:
self.serve.update(definitions.get("serve"))

if "www" in module.__dict__:
self.www = module.www
if "www" in definitions:
self.www = definitions.get("www")

def enable_modules(self, *names):
for module_name in names:
Expand Down

0 comments on commit adc43a3

Please sign in to comment.