]> git.ipfire.org Git - people/shoehn/ipfire.org.git/commitdiff
Replace hostname replacement function and make it better accessible
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Mar 2015 20:56:10 +0000 (21:56 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Mar 2015 20:56:10 +0000 (21:56 +0100)
webapp/handlers_base.py

index 4051ced089898fb0a1bfed45651dfbc93f243638..b6ccdff51fc87f44c66cab00956a57cbd260e34a 100644 (file)
@@ -22,23 +22,25 @@ class BaseHandler(tornado.web.RequestHandler):
 
        def get_user_locale(self):
                # The planet is always in english.
-               if self.request.host == "planet.ipfire.org":
+               if self.hostname == "planet.ipfire.org":
                        return tornado.locale.get("en_US")
 
                # Otherwise take the browser locale.
                return self.get_browser_locale()
 
+       @property
+       def hostname(self):
+               # Remove the development prefix
+               return self.request.host.replace(".dev.", ".")
+
        @property
        def render_args(self):
                today = datetime.date.today()
 
-               # Get the requested host and remove the development prefix
-               hostname = self.request.host.replace(".dev.", ".")
-
                return {
                        "format_size" : backend.util.format_size,
                        "format_time" : backend.util.format_time,
-                       "hostname" : hostname,
+                       "hostname" : self.hostname,
                        "lang" : self.locale.code[:2],
                        "rss_url" : self.rss_url,
                        "year" : today.year,