Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
BridgeDB
Commits
336eb625
Unverified
Commit
336eb625
authored
Jan 24, 2014
by
Isis Lovecruft
Browse files
Merge branch 'fix/6127-render_GET-traceback' into develop
parents
99cbe98d
aa2885b7
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/bridgedb/HTTPServer.py
View file @
336eb625
...
...
@@ -292,11 +292,32 @@ class WebResource(twisted.web.resource.Resource):
rtl
=
rtl
)
class
WebRoot
(
twisted
.
web
.
resource
.
Resource
):
"""The parent resource of all other documents hosted by the webserver."""
isLeaf
=
True
def
render_GET
(
self
,
request
):
"""Handles requests for the webserver root document.
For example, this function handles requests for
https://bridges.torproject.org/.
:type request: :api:`twisted.web.server.Request`
:param request: An incoming request.
"""
rtl
=
False
try
:
rtl
=
usingRTLLang
(
request
)
except
Exception
as
err
:
logging
.
exception
(
err
)
logging
.
error
(
"The gettext files were not properly installed."
)
logging
.
info
(
"To install translations, try doing `python "
\
"setup.py compile_catalog`."
)
return
lookup
.
get_template
(
'index.html'
).
render
(
rtl
=
rtl
)
def
addWebServer
(
cfg
,
dist
,
sched
):
"""Set up a web server.
cfg -- a configuration object from Main. We use these options:
...
...
@@ -359,8 +380,7 @@ def addWebServer(cfg, dist, sched):
return
site
def
usingRTLLang
(
request
):
"""
Check if we should translate the text into a RTL language
"""Check if we should translate the text into a RTL language
Retrieve the headers from the request. Obtain the Accept-Language header
and decide if we need to translate the text. Install the requisite
...
...
@@ -368,8 +388,11 @@ def usingRTLLang(request):
support. Choose the first language from the header that we support and
return True if it is a RTL language, else return False.
:param request twisted.web.server.Request: Incoming request
:returns bool: Language is right-to-left
:type request: :api:`twisted.web.server.Request`
:param request: An incoming request.
:rtype: bool
:returns: ``True`` if the preferred language is right-to-left; ``False``
otherwise.
"""
langs
=
setLocaleFromRequestHeader
(
request
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment