changeset 4154:fbbc33a3d40a

New isSpiderAgent property on RequestContext(and fixed some copy'n'paste messup)
author Florian Krupicka <florian.krupicka@googlemail.com>
date Mon, 09 Jun 2008 17:45:29 +0200
parents 75b0b7f32423
children 7e59a7989b23
files MoinMoin/web/contexts.py MoinMoin/wsgiapp.py
diffstat 2 files changed, 14 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/contexts.py	Mon Jun 09 17:39:28 2008 +0200
+++ b/MoinMoin/web/contexts.py	Mon Jun 09 17:45:29 2008 +0200
@@ -15,6 +15,7 @@
 
 from MoinMoin.request import RequestBase
 from MoinMoin.web.request import Request
+from MoinMoin.web.utils import check_spider
 from MoinMoin.web.exceptions import Forbidden, SurgeProtection
 
 from MoinMoin import log
@@ -75,6 +76,19 @@
                    503: SurgeProtection }
         raise status[resultcode](msg)
 
+    def is_spideragent(self):
+        if hasattr(self, '_is_spideragent'):
+            return self._is_spideragent
+        if getattr(self, 'cfg', None) is not None:
+            self._is_spideragent = check_spider(self.user_agent, self.cfg)
+            return self._is_spideragent
+        else:
+            return False
+    is_spideragent = property(is_spideragent)
+
+    # legacy compatibility
+    isSpiderAgent = is_spideragent
+
 class XMLRPCContext(RequestContext):
     pass
 
@@ -219,21 +233,3 @@
    if isinstance(item, FunctionType):
        setattr(RequestBase, name, _logfunc(item))
 del name, item, FunctionType, _logfunc
-
-
-
-
- 
- from MoinMoin.request import RequestBase
- from MoinMoin.web.request import Request
- 
- from MoinMoin import log
- logging = log.getLogger(__name__)
-@@ -65,6 +68,26 @@
-             return self._parent.data
-         else:
-             return self._parent.input_stream.read(n)
-
- 
- class XMLRPCContext(RequestContext):
-     pass
--- a/MoinMoin/wsgiapp.py	Mon Jun 09 17:39:28 2008 +0200
+++ b/MoinMoin/wsgiapp.py	Mon Jun 09 17:45:29 2008 +0200
@@ -36,8 +36,6 @@
     except error.NoConfigMatchedError:
         raise NotFound('<p>No wiki configuration matching the URL found!</p>')
 
-    request.isSpiderAgent = check_spider(request.user_agent, request.cfg)
-    
     request.action = request.form.get('action', 'show')
     
     try: