changeset 5535:ac5dc19e0a0e

web.contexts: http_user_agent and http_referer to EnvironProxy added
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 14 Feb 2010 01:01:33 +0100
parents 6698d5db825a
children 01dbe5f901e4
files MoinMoin/web/contexts.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/contexts.py	Sat Feb 13 21:13:00 2010 +0100
+++ b/MoinMoin/web/contexts.py	Sun Feb 14 01:01:33 2010 +0100
@@ -144,7 +144,7 @@
     def isSpiderAgent(self):
         """ Simple check if useragent is a spider bot. """
         cfg = self.cfg
-        user_agent = self.environ.get('HTTP_USER_AGENT')
+        user_agent = self.http_user_agent
         if user_agent and cfg.cache.ua_spiders:
             return cfg.cache.ua_spiders.search(user_agent) is not None
         return False
@@ -270,6 +270,14 @@
         """ Raise a simple redirect exception. """
         abort(redirect(url, code=code))
 
+    def http_user_agent(self):
+        return self.environ.get('HTTP_USER_AGENT', '')
+    http_user_agent = EnvironProxy(http_user_agent)
+
+    def http_referer(self):
+        return self.environ.get('HTTP_REFERER', '')
+    http_referer = EnvironProxy(http_referer)
+
     # the output related methods
     def write(self, *data):
         """ Write to output stream. """