[pypy-svn] r41708 - in pypy/dist/pypy/translator/js/lib: . test
fijal at codespeak.net
fijal at codespeak.net
Fri Mar 30 16:27:55 CEST 2007
Author: fijal
Date: Fri Mar 30 16:27:49 2007
New Revision: 41708
Modified:
pypy/dist/pypy/translator/js/lib/server.py
pypy/dist/pypy/translator/js/lib/test/test_server_g.py
Log:
Add a possibilty of having an error handler directly on your app.
This opens logging possibility for play1
Modified: pypy/dist/pypy/translator/js/lib/server.py
==============================================================================
--- pypy/dist/pypy/translator/js/lib/server.py (original)
+++ pypy/dist/pypy/translator/js/lib/server.py Fri Mar 30 16:27:49 2007
@@ -323,6 +323,8 @@
data = 'An error has occurred: %s - %s\n\n%s' % (exc, e,
tb_formatted)
headers = {'Content-Type': 'text/plain'}
+ if hasattr(self.application, 'handle_error'):
+ self.application.handle_error(exc, e, tb)
else:
status = 200
if not 'content-type' in [k.lower() for k in headers]:
Modified: pypy/dist/pypy/translator/js/lib/test/test_server_g.py
==============================================================================
--- pypy/dist/pypy/translator/js/lib/test/test_server_g.py (original)
+++ pypy/dist/pypy/translator/js/lib/test/test_server_g.py Fri Mar 30 16:27:49 2007
@@ -16,11 +16,16 @@
def __call__(self, handler, path, query):
return ('text/plain', 'foo')
+def raising_page(handler, path, query):
+ xxx
+raising_page.exposed = True
+
def build_app_structure():
app = Collection()
app.sub = Collection()
app.sub = Collection()
app.sub.index = SomePage()
+ app.error = raising_page
return app
class TestCollection(object):
@@ -102,6 +107,18 @@
def test_get_response_wrong_body(self):
py.test.raises(ValueError, "self.handler.response(200, {}, u'xxx')")
+ def test_handle_error(self):
+ l = []
+ def f(*args):
+ l.append(args)
+ app = build_app_structure()
+ self.handler.application = app
+ self.handler.path = '/error'
+ self.handler.do_GET()
+ self.handler.application.handle_error = f
+ self.handler.do_GET()
+ assert len(l) == 1
+
class TestFsFile(object):
def test_call(self):
temp = py.test.ensuretemp('TestStaticResource.test_handle')
More information about the Pypy-commit
mailing list