나는 간단한 TurboGears 2 스크립트라는 app.py 있습니다 : "안녕하세요 세계"나는 app.py을 실행하고 http://localhost:5000/all__things를 방문 할 때, 내가 볼TurboGears는 URL에서 어떤 문자를 대체합니까?
#!/usr/bin/env python3
from wsgiref.simple_server import make_server
from tg import expose, TGController, AppConfig
class RootController(TGController):
@expose()
def all__things(self):
return "Hello world!"
config = AppConfig(minimal=True, root_controller=RootController())
print("Serving on port 5000...")
httpd = make_server('', 5000, config.make_wsgi_app())
httpd.serve_forever()
을 예상대로 그러나 이러한 URL도 작동 :
http://localhost:5000/all--things
http://localhost:5000/[email protected]@things
http://localhost:5000/all$$things
http://localhost:5000/all++things
http://localhost:5000/all..things
http://localhost:5000/all,,things
을뿐만 아니라 조합과 같이
http://localhost:5000/all-_things
http://localhost:5000/all_-things
http://localhost:5000/[email protected]
http://localhost:5000/[email protected]
http://localhost:5000/[email protected]
http://localhost:5000/[email protected]$things
기타 등등 ...
TurboGears에 밑줄을 대체 할 수있는 문자의 전체 목록은 무엇URL?
또한이 기능을 일부 문자 만 대체하도록 제한 할 수 있습니까? 이상적으로는 대시 (http://localhost:5000/all--things)가있는 URL이 작동하고 밑줄이있는 URL (http://localhost:5000/all__things) 또는 다른 이상한 문자가 작동하지 않는 것이 좋습니다.
'config.dispatch_path_translator = False'를 설정하면 프로그램이 충돌하지만'config.dispatch_path_translator = None'이 작동합니다. 결국 나는 다음과 같이 결정했다. 'config.dispatch_path_translator = lambda path_piece : path_piece.replace ('-', '_') path_piece에 '_'이 없으면 else '' ' 도움을 주셔서 감사합니다. –
아, 죄송합니다. 참/없음/기능입니다. 반사 (True)의 반대로 False를 썼습니다 : D 답변이 업데이트되었습니다. – amol