fix: use app handler to render error string, when progress fails
This commit is contained in:
parent
171e9f7488
commit
c2efc1cd1a
|
@ -44,7 +44,7 @@ dependencies = [
|
||||||
"pyramid_tm",
|
"pyramid_tm",
|
||||||
"waitress",
|
"waitress",
|
||||||
"WebHelpers2",
|
"WebHelpers2",
|
||||||
"WuttJamaican[db]>=0.19.0",
|
"WuttJamaican[db]>=0.19.1",
|
||||||
"zope.sqlalchemy>=1.5",
|
"zope.sqlalchemy>=1.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ class SessionProgress(ProgressBase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, request, key, success_msg=None, success_url=None, error_url=None):
|
def __init__(self, request, key, success_msg=None, success_url=None, error_url=None):
|
||||||
|
self.request = request
|
||||||
|
self.config = self.request.wutta_config
|
||||||
|
self.app = self.config.get_app()
|
||||||
self.key = key
|
self.key = key
|
||||||
self.success_msg = success_msg
|
self.success_msg = success_msg
|
||||||
self.success_url = success_url
|
self.success_url = success_url
|
||||||
|
@ -137,7 +140,7 @@ class SessionProgress(ProgressBase):
|
||||||
"""
|
"""
|
||||||
self.session.load()
|
self.session.load()
|
||||||
self.session['error'] = True
|
self.session['error'] = True
|
||||||
self.session['error_msg'] = str(error)
|
self.session['error_msg'] = self.app.render_error(error)
|
||||||
self.session['error_url'] = error_url or self.error_url
|
self.session['error_url'] = error_url or self.error_url
|
||||||
self.session.save()
|
self.session.save()
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ from unittest import TestCase
|
||||||
from pyramid import testing
|
from pyramid import testing
|
||||||
from beaker.session import Session as BeakerSession
|
from beaker.session import Session as BeakerSession
|
||||||
|
|
||||||
|
from wuttjamaican.testing import ConfigTestCase
|
||||||
|
|
||||||
from wuttaweb import progress as mod
|
from wuttaweb import progress as mod
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,10 +33,11 @@ class TestGetProgressSession(TestCase):
|
||||||
self.assertEqual(session.id, 'mockid.progress.foo')
|
self.assertEqual(session.id, 'mockid.progress.foo')
|
||||||
|
|
||||||
|
|
||||||
class TestSessionProgress(TestCase):
|
class TestSessionProgress(ConfigTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.request = testing.DummyRequest()
|
self.setup_config()
|
||||||
|
self.request = testing.DummyRequest(wutta_config=self.config)
|
||||||
self.request.session.id = 'mockid'
|
self.request.session.id = 'mockid'
|
||||||
|
|
||||||
def test_error_url(self):
|
def test_error_url(self):
|
||||||
|
|
Loading…
Reference in a new issue