debug: log every product_edit view hit + use /opt path for log

The /tmp/mps-pricing-debug.log file didn't appear after fox triggered
a save attempt. Two changes to narrow down why:

1. Move the debug log to /opt/make_post_sell/pricing-debug.log (where
   uwsgi has owner write access) with /tmp as fallback. PrivateTmp or
   permissions might be blocking /tmp writes on this systemd setup.

2. Add an ENTER log line at the top of product_edit() that fires for
   every request — GET, POST, save, etc. If this line never appears,
   the view itself isn't being reached and the form is going somewhere
   else. If it appears but the pricing_mode line doesn't, the submit
   field is missing from params.
This commit is contained in:
russell@unturf.com 2026-05-10 20:06:24 -04:00
parent 5c2694d7ae
commit a186b4d000
No known key found for this signature in database

View file

@ -255,6 +255,30 @@ def product_edit(request):
product_modified = False
product = request.product
# TEMPORARY DEBUG: log every product_edit hit so we can confirm the
# view is even being reached when fox attempts to save pricing_mode.
import os as _os_dbg
import time as _time_dbg
for _path_dbg in (
"/opt/make_post_sell/pricing-debug.log",
"/tmp/mps-pricing-debug.log",
):
try:
with open(_path_dbg, "a") as _f_dbg:
_f_dbg.write(
f"{_time_dbg.time():.3f} pid={_os_dbg.getpid()} ENTER product_edit "
f"product={product.uuid_str} method={request.method} "
f"submit={'submit' in request.params} "
f"pricing_mode={request.params.get('pricing_mode')!r}\n"
)
try:
_os_dbg.chmod(_path_dbg, 0o644)
except Exception:
pass
break
except Exception:
continue
title = request.params.get("title", product.title).strip()
description = request.params.get("description", product.description).strip()
price = request.params.get("price", product.price)
@ -330,19 +354,33 @@ def product_edit(request):
)
except Exception:
pass
try:
import time as _time
with open("/tmp/mps-pricing-debug.log", "a") as _f:
_f.write(
f"{_time.time():.3f} product={product.uuid_str} "
f"current={product.pricing_mode} "
f"pricing_mode={request.params.get('pricing_mode')!r} "
f"all_modes={list(request.params.getall('pricing_mode')) if hasattr(request.params, 'getall') else 'no-getall'} "
f"submit={request.params.get('submit')!r} "
f"all_keys={sorted(request.params.keys())}\n"
)
except Exception:
pass
# Write to a path under /opt/make_post_sell where uwsgi has
# write access; /tmp may be sandboxed under PrivateTmp on some
# systemd configurations. World-readable so fox can tail without sudo.
import os as _os
import time as _time
for _path in (
"/opt/make_post_sell/pricing-debug.log",
"/tmp/mps-pricing-debug.log",
):
try:
with open(_path, "a") as _f:
_f.write(
f"{_time.time():.3f} pid={_os.getpid()} "
f"product={product.uuid_str} "
f"current={product.pricing_mode} "
f"pricing_mode={request.params.get('pricing_mode')!r} "
f"all_modes={list(request.params.getall('pricing_mode')) if hasattr(request.params, 'getall') else 'no-getall'} "
f"submit={request.params.get('submit')!r} "
f"all_keys={sorted(request.params.keys())}\n"
)
try:
_os.chmod(_path, 0o644)
except Exception:
pass
break
except Exception:
continue
try:
new_mode = int(request.params.get("pricing_mode", product.pricing_mode))
except (TypeError, ValueError):