parent
ee61843183
commit
60bb9febd9
2
app.py
2
app.py
|
@ -400,6 +400,7 @@ def get_institution(entity, other):
|
||||||
@app.route("/item/Q<int:item_id>")
|
@app.route("/item/Q<int:item_id>")
|
||||||
def item_page(item_id):
|
def item_page(item_id):
|
||||||
qid = f'Q{item_id}'
|
qid = f'Q{item_id}'
|
||||||
|
g.qid = qid
|
||||||
item = artwork.Artwork(qid)
|
item = artwork.Artwork(qid)
|
||||||
from_redirect = qid in session and session.pop(qid) == 'from redirect'
|
from_redirect = qid in session and session.pop(qid) == 'from redirect'
|
||||||
entity = mediawiki.get_entity_with_cache(qid, refresh=not from_redirect)
|
entity = mediawiki.get_entity_with_cache(qid, refresh=not from_redirect)
|
||||||
|
@ -423,6 +424,7 @@ def item_page(item_id):
|
||||||
label = label_and_language['label']
|
label = label_and_language['label']
|
||||||
else:
|
else:
|
||||||
label = None
|
label = None
|
||||||
|
g.label = label
|
||||||
other = get_other(item.entity)
|
other = get_other(item.entity)
|
||||||
|
|
||||||
people = human.from_name(label) if label else None
|
people = human.from_name(label) if label else None
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
import logging
|
import logging
|
||||||
from logging.handlers import SMTPHandler
|
from logging.handlers import SMTPHandler
|
||||||
from logging import Formatter
|
from logging import Formatter
|
||||||
from flask import request
|
from flask import request, g
|
||||||
|
|
||||||
PROJECT = 'depicts'
|
PROJECT = 'depicts'
|
||||||
|
|
||||||
class MatcherSMTPHandler(SMTPHandler):
|
class MatcherSMTPHandler(SMTPHandler):
|
||||||
def getSubject(self, record): # noqa: N802
|
def getSubject(self, record): # noqa: N802
|
||||||
return (f'{PROJECT} error: {record.exc_info[0].__name__}'
|
subject = (f'{PROJECT} error: {record.exc_info[0].__name__}'
|
||||||
if (record.exc_info and record.exc_info[0])
|
if (record.exc_info and record.exc_info[0])
|
||||||
else f'{PROJECT} error: {record.pathname}:{record.lineno:d}')
|
else f'{PROJECT} error: {record.pathname}:{record.lineno:d}')
|
||||||
|
|
||||||
|
if qid := getattr(g, 'qid', None):
|
||||||
|
subject += f' {qid}'
|
||||||
|
|
||||||
|
if label := getattr(g, 'label', None):
|
||||||
|
subject += f': {label}'
|
||||||
|
|
||||||
|
return subject
|
||||||
|
|
||||||
class RequestFormatter(Formatter):
|
class RequestFormatter(Formatter):
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
|
|
Loading…
Reference in a new issue