changeset 1567:2e1aff91a0a5

use 404 instead of ConfigurationError when no config is matched for some URL
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 18 Sep 2006 20:54:52 +0200
parents bc235abefd24
children 8c7b01f187c3
files MoinMoin/error.py MoinMoin/request/__init__.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/error.py	Mon Sep 18 20:43:30 2006 +0200
+++ b/MoinMoin/error.py	Mon Sep 18 20:54:52 2006 +0200
@@ -9,7 +9,6 @@
 import sys
 from MoinMoin import config
 
-
 class Error(Exception):
     """ Base class for moin moin errors
 
@@ -106,3 +105,7 @@
 class InternalError(FatalError):
     """ Raise when internal fatal error is found """
 
+class NoConfigMatchedError(Exception):
+    """ we didn't find a configuration for this URL """
+    pass
+
--- a/MoinMoin/request/__init__.py	Mon Sep 18 20:43:30 2006 +0200
+++ b/MoinMoin/request/__init__.py	Mon Sep 18 20:54:52 2006 +0200
@@ -16,6 +16,7 @@
     from sets import Set as set
 
 from MoinMoin import config, wikiutil, user, caching, error
+from MoinMoin.config import multiconfig
 from MoinMoin.util import IsWin9x
 
 # umask setting --------------------------------------------------------
@@ -164,7 +165,11 @@
             self.clock.start('base__init__')
             # order is important here!
             self.__dict__.update(properties)
-            self._load_multi_cfg()
+            try:
+                self._load_multi_cfg()
+            except error.NoConfigMatchedError:
+                self.makeForbidden(404, 'No wiki configuration matching the URL found!\r\n')
+                return
 
             self.isSpiderAgent = self.check_spider()
 
@@ -323,7 +328,6 @@
         # protect against calling multiple times
         if not hasattr(self, 'cfg'):
             self.clock.start('load_multi_cfg')
-            from MoinMoin.config import multiconfig
             self.cfg = multiconfig.getConfig(self.url)
             self.clock.stop('load_multi_cfg')
 
@@ -1006,6 +1010,7 @@
     def makeForbidden(self, resultcode, msg):
         statusmsg = {
             403: 'FORBIDDEN',
+            404: 'Not found',
             503: 'Service unavailable',
         }
         headers = [