Skip to content

Commit

Permalink
Bugfixes (#806)
Browse files Browse the repository at this point in the history
* Fix fails on Python 3.7

The "encoding" argument of logging.basicConfig() was added in Python 3.9
This fix don't change any features.

* Fix translation in _scaffold app

The function T() must get translated string BEFORE any string
interpolations.
  • Loading branch information
Sukhichev committed Aug 30, 2023
1 parent 55645f1 commit 76247ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/_scaffold/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
@action.uses("index.html", auth, T)
def index():
user = auth.get_user()
message = T("Hello {first_name}".format(**user) if user else "Hello")
message = T("Hello {first_name}").format(**user) if user else T("Hello")
actions = {"allowed_actions": auth.param.allowed_actions}
return dict(message=message, actions=actions)
25 changes: 11 additions & 14 deletions py4web/server_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,18 @@ def logging_conf(level, log_file="server-py4web.log"):

log_dir = os.environ.get("PY4WEB_LOGS", None)

log_param = (
{
"filename": os.path.join(log_dir, log_file),
"filemode": "w",
"format": "%(message)s > %(threadName)s",
"encoding": "utf-8",
"level": check_level(level),
log_param = {
"format":"%(threadName)s | %(message)s",
"level":check_level(level),
}
if log_dir
else {
"format": "%(message)s > %(threadName)s",
"encoding": "utf-8",
"level": check_level(level),
}
)

if log_dir:
h = logging.FileHandler(
os.path.join( log_dir, log_file),
mode = "w",
encoding = "utf-8"
)
log_param.update( {"handlers": [h]} )

logging.basicConfig(**log_param)

Expand Down

0 comments on commit 76247ae

Please sign in to comment.