Log error if registry has no rattail config

not clear if this is even possible, but if so i want to know about it

trying to figure out the occasional error email we get, latest being
from collectd/curl pinging the /login page, but request.has_perm()
call fails with missing attr?!

seems like either the rattail config is empty, or else the subscriber
events aren't firing (in the correct order) ?
This commit is contained in:
Lance Edgar 2024-05-31 12:04:11 -05:00
parent 49cd050272
commit 9b88f01378
2 changed files with 5 additions and 2 deletions

View file

@ -132,8 +132,7 @@ def make_pyramid_config(settings, configure_csrf=True):
settings.setdefault('pyramid_deform.template_search_path', 'tailbone:templates/deform') settings.setdefault('pyramid_deform.template_search_path', 'tailbone:templates/deform')
config = Configurator(settings=settings, root_factory=Root) config = Configurator(settings=settings, root_factory=Root)
# add rattail config directly to registry # add rattail config directly to registry, for access throughout the app
# TODO: why on earth do we do this again?
config.registry['rattail_config'] = rattail_config config.registry['rattail_config'] = rattail_config
# configure user authorization / authentication # configure user authorization / authentication

View file

@ -80,11 +80,14 @@ def new_request(event):
* A shortcut method for permission checking, as ``has_perm()``. * A shortcut method for permission checking, as ``has_perm()``.
""" """
log.debug("new request: %s", event)
request = event.request request = event.request
rattail_config = request.registry.settings.get('rattail_config') rattail_config = request.registry.settings.get('rattail_config')
# TODO: why would this ever be null? # TODO: why would this ever be null?
if rattail_config: if rattail_config:
request.rattail_config = rattail_config request.rattail_config = rattail_config
else:
log.error("registry has no rattail_config ?!")
def user(request): def user(request):
user = None user = None
@ -158,6 +161,7 @@ def before_render(event):
""" """
Adds goodies to the global template renderer context. Adds goodies to the global template renderer context.
""" """
log.debug("before_render: %s", event)
request = event.get('request') or threadlocal.get_current_request() request = event.get('request') or threadlocal.get_current_request()
rattail_config = request.rattail_config rattail_config = request.rattail_config