SVN: r22388 - trunk/quixote

Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Wed, 03 Sep 2003 11:40:47 -0400
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Author: nascheme
Date: 2003-09-03 11:40:47 -0400 (Wed, 03 Sep 2003)
New Revision: 22388

Modified:
   trunk/quixote/util.py
Log:
Add 'Redirector' helper class.


Modified: trunk/quixote/util.py
===================================================================
--- trunk/quixote/util.py	2003-09-02 22:56:04 UTC (rev 22387)
+++ trunk/quixote/util.py	2003-09-03 15:40:47 UTC (rev 22388)
@@ -236,3 +236,22 @@
             if self.use_cache:
                 self.cache[name] = item
         return item
+
+
+class Redirector:
+    """
+    A simple class that can be used from inside _q_lookup() to redirect
+    requests.
+    """
+
+    _q_exports = []
+
+    def __init__(self, location, permanent=0):
+        self.location = location
+        self.permanent = permanent
+
+    def _q_lookup(self, request, component):
+        return self
+
+    def __call__(self, request):
+        return request.redirect(self.location, self.permanent)