• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

修訂1c5e1064d1e582647f5dab23a5e5a7f3b3eef1c7 (tree)
時間2011-04-30 02:08:36
作者Rick Copeland <rcopeland@geek...>
CommiterRick Copeland

Log Message

[#1831] update with[out]_trailing_slash to give HTTPMovedPermanently rather than HTTPFound

Signed-off-by: Rick Copeland <rcopeland@geek.net>

Change Summary

差異

--- a/Allura/tg/decorators.py
+++ b/Allura/tg/decorators.py
@@ -3,6 +3,7 @@ from formencode import schema
33 import ew.render
44
55 from .tg_globals import c, request, response
6+from .util import moved
67
78 class _tg_deco(object):
89 def __init__(self, *args, **kwargs):
@@ -21,20 +22,18 @@ def override_template(func, template):
2122 c.override_template = template
2223
2324 def without_trailing_slash(func):
24- from tg import redirect
2525 def _check_path(params):
2626 if request.method != 'GET': return
2727 if request.path.endswith('/'):
28- redirect(request.url.replace(request.path, request.path[:-1], 1))
28+ moved(request.url.replace(request.path, request.path[:-1], 1))
2929 before_validate(_check_path)(func)
3030 return func
3131
3232 def with_trailing_slash(func):
33- from tg import redirect
3433 def _check_path(params):
3534 if request.method != 'GET': return
3635 if not request.path.endswith('/'):
37- redirect(request.url.replace(request.path, request.path + '/', 1))
36+ moved(request.url.replace(request.path, request.path + '/', 1))
3837 before_validate(_check_path)(func)
3938 return func
4039
--- a/Allura/tg/util.py
+++ b/Allura/tg/util.py
@@ -43,6 +43,10 @@ def redirect(*args, **kwargs):
4343 found = exc.HTTPFound(location=url(*args, **kwargs))
4444 raise found.exception
4545
46+def moved(*args, **kwargs):
47+ moved = exc.HTTPMovedPermanently(location=url(*args, **kwargs))
48+ raise moved.exception
49+
4650 def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
4751 """
4852 Returns a bytestring version of 's', encoded as specified in 'encoding'.