##// END OF EJS Templates
core: handle bogus GET params so we don't crash on translate subscriber.
marcink -
r3132:fb303e8b default
parent child Browse files
Show More
@@ -19,15 +19,15 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 import io
20 import io
21 import re
21 import re
22 import os
22 import datetime
23 import datetime
23 import logging
24 import logging
24 import Queue
25 import Queue
25 import subprocess32
26 import subprocess32
26 import os
27
27
28
28
29 from dateutil.parser import parse
29 from dateutil.parser import parse
30 from pyramid.i18n import get_localizer
30 from pyramid.httpexceptions import HTTPBadRequest
31 from pyramid.threadlocal import get_current_request
31 from pyramid.threadlocal import get_current_request
32 from pyramid.interfaces import IRoutesMapper
32 from pyramid.interfaces import IRoutesMapper
33 from pyramid.settings import asbool
33 from pyramid.settings import asbool
@@ -61,7 +61,19 b' def add_renderer_globals(event):'
61
61
62 def add_localizer(event):
62 def add_localizer(event):
63 request = event.request
63 request = event.request
64 localizer = request.localizer
64 try:
65 localizer = request.localizer
66 except Exception:
67 log.exception('Failed to get localizer')
68 # NOTE(marcink): Handle bug in pyramid by malformed GET params could crash
69 # this resulting on various odd errors on missing translators
70 # see: https://github.com/Pylons/pyramid/issues/3399
71
72 def dummy_translate(*args, **kwargs):
73 return ''.join(args)
74 request.translate = tsf
75 request.plularize = dummy_translate
76 raise HTTPBadRequest()
65
77
66 def auto_translate(*args, **kwargs):
78 def auto_translate(*args, **kwargs):
67 return localizer.translate(tsf(*args, **kwargs))
79 return localizer.translate(tsf(*args, **kwargs))
General Comments 0
You need to be logged in to leave comments. Login now