2013-08-09 3 views
0

Michael Merickel에게 감사드립니다. 전 세계적으로 IP 주소를 리디렉션 할 수있었습니다. 나는 이것을 주석으로 추가 할 수 있었지만 다른 질문을하기로 결정했다. 그의 코드는 사용자에게 오류 메시지를줍니다. 이런 일이 발생하면 경고를 받고 싶습니다. 간단한 print 문으로 해봤지만 메시지를 두 번 인쇄합니다. 나는 단지 간단한보기 (아무 css 파일도, js, 등등)에 1 개의 요구를 만들고있다. 실제로 두 번 요청하고 있습니까?피라미드에서 전역으로 리디렉션 중 ... 콘솔에 두 번 인쇄 중임

@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? 

답변

2

웹 브라우저를 사용중인 경우 favicon을 요청한 것 같습니다. 요청한 URL을 인쇄하여이를 확인할 수 있습니다.