Skip to content

Commit

Permalink
fix #653
Browse files Browse the repository at this point in the history
  • Loading branch information
wang0618 committed Feb 14, 2025
1 parent 185333a commit c348d0a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pywebio/platform/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import urllib.parse
from collections import namedtuple
from collections.abc import Mapping, Sequence
from functools import lru_cache
from functools import partial
import functools
from os import path, environ

from tornado import template
Expand Down Expand Up @@ -57,7 +56,7 @@ def render_page(app, protocol, cdn):
css_file=meta.css_file or [], theme=theme, manifest=manifest)


@lru_cache(maxsize=64)
@functools.lru_cache(maxsize=64)
def check_theme(theme):
"""check theme file existence"""
if not theme:
Expand Down Expand Up @@ -336,14 +335,18 @@ def __init__(self):

def __call__(self, func):
self.called = True

@functools.wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)

try:
func = partial(func) # to make a copy of the function
for key, val in configs.items():
if val:
setattr(func, '_pywebio_%s' % key, val)
setattr(wrapper, '_pywebio_%s' % key, val)
except Exception:
pass
return func
return wrapper

def __del__(self): # if not called as decorator, set the config to global
if self.called:
Expand Down

0 comments on commit c348d0a

Please sign in to comment.