@subscriber('pyramid.events.NewRequest')
def newrequest(event):
request = event.request
if request.remote_addr.startswith('66.'):
print 'hey, we got one...',
raise SomeException('my custom message')
@view_config(context=SomeException, renderer='string')
def exc_view(exc, request):
print 'and another'
return exc.message
Result:
hey, we got one...and another
hey, we got one...and another # why the extra line?
答案 0 :(得分:2)
如果你在网络浏览器中,那么它可能是对favicon的请求。您可以通过打印出请求的网址来检查这一点。