diff taginthemiddle/middleware.py @ 19:57ca873ed9bf default tip

make this a pluggable system and start reorging infrastructure for that
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 25 May 2010 07:48:53 -0700
parents 1701e5b0b0eb
children
line wrap: on
line diff
--- a/taginthemiddle/middleware.py	Mon May 24 07:48:48 2010 -0700
+++ b/taginthemiddle/middleware.py	Tue May 25 07:48:53 2010 -0700
@@ -1,12 +1,11 @@
 """
-request dispatcher:
-data persisting across requests should go here
+apply and display tags via WSGI middleware;
+request dispatcher component
 """
 
 import os
 
 from handlers import TagCloud, ViewTags, PostTags
-from model import Tags
 
 from genshi.template import TemplateLoader
 from lxmlmiddleware import LXMLMiddleware
@@ -20,10 +19,10 @@
     defaults = { 'auto_reload': 'False',
                  'template_dirs': '',
                  'patterns': '*', # glob pattern: all URLs by default
-                 'tags_file': None, 
                  'tags_url': 'tags', # base URL for viewing tags
                  'post_url': '.tags', # sub-URL for posting tags
                  'author': None, # for RSS
+                 'engine': None
                  }
 
     def __init__(self, app, **kw):
@@ -33,8 +32,6 @@
         for key in self.defaults:
             setattr(self, key, kw.get(key, self.defaults[key]))
         self.auto_reload = self.auto_reload.lower() == 'true'
-        assert self.tags_file is not None
-        self.tags = Tags(self.tags_file)
         self.patterns = self.patterns.strip().split()
 
         # request handlers
@@ -46,6 +43,9 @@
         self.loader = TemplateLoader(self.template_dirs,
                                      auto_reload=self.auto_reload)
 
+        # tag engine
+        assert self.engine is not None, 'Must specify a tag.engine'
+
     def __call__(self, environ, start_response):
 
         # get a request object