--- a/map.py Thu Feb 12 01:53:21 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-"""
- Handles mapping URLs to request handlers
-"""
-
-from qmsk.web import http, handler
-
-class MapperError (http.ResponseError) :
- """
- URL could not be mapped
- """
-
- def __init__ (self, url) :
- super(MapperError, self).__init__("URL not found: %s" % (url, ), status='404 Not Found')
-
-class Mapper (handler.RequestHandler) :
- """
- Looks up the handler to use based on the URL
- """
-
- def handle_request (self, request) :
- """
- Map the given request
- """
-
- abstract
-
-class Mapping (object) :
- """
- A mapping object for StaticMapping
- """
-
- def test (self, request) :
- """
- Either return a handler, or None
- """
-
- abstract
-
-class RegexpMapping (object) :
- """
- A mapping object that uses regular expressions
- """
-
- def __init__ (self, regexp, handler) :
- pass
-
- def test (self, request) :
- xxx
-
-class SimpleMapping (object) :
- """
- A mapping object that uses simple expressions
- """
-
- def __init__ (self, expression, handler) :
- pass
-
- def test (self, request) :
- xxx
-
-class StaticMapper (Mapper) :
- """
- Translates requests to handlers using a list of pre-determined Mapping's
- """
-
- def __init__ (self, mappings) :
- # store
- self.mappings = mappings
-
- def handle_request (self, request) :
- """
- Returns the appropriate handler
- """
-
- # find handler to use
- handler = None
-
- # just test each mapping in turn
- for mapping in self.mappings :
- handler = mapping.test(request)
-
- if handler :
- break
-
- if not handler :
- # fail, not found
- raise MapperError(request.get_page_name())
-
- # passthrough
- return handler.handle_request(request)
-
-# "friendly" names
-map = SimpleMapping
-mapre = RegexpMapping
-
--- a/urltree.py Thu Feb 12 01:53:21 2009 +0200
+++ b/urltree.py Thu Feb 12 22:51:08 2009 +0200
@@ -5,7 +5,7 @@
import re
import os.path
-from qmsk.web import map
+from qmsk.web import handler
class URLError (Exception) :
"""
@@ -870,7 +870,7 @@
def __str__ (self) :
return "%s/[%s]" % (self.label, ','.join(str(child) for child in self.children))
-class URLTree (map.Mapper) :
+class URLTree (handler.RequestHandler) :
"""
Map requests to handlers, using a defined tree of URLs
"""