[z3-checkins] r34290 - in z3/deliverance: branches/namespaced trunk/Attic
cabraham at codespeak.net
cabraham at codespeak.net
Mon Nov 6 17:37:51 CET 2006
Author: cabraham
Date: Mon Nov 6 17:37:46 2006
New Revision: 34290
Added:
z3/deliverance/trunk/Attic/mpfilter.py
- copied unchanged from r34289, z3/deliverance/branches/namespaced/mpfilter.py
Removed:
z3/deliverance/branches/namespaced/mpfilter.py
Log:
moved old source
Deleted: /z3/deliverance/branches/namespaced/mpfilter.py
==============================================================================
--- /z3/deliverance/branches/namespaced/mpfilter.py Mon Nov 6 17:37:46 2006
+++ (empty file)
@@ -1,70 +0,0 @@
-"""
-Deliverance theming for mod_python filters
-
-Deliverance applies a theme to content. This mod_python module acts as an
-Apache "filter", transforming content as it passes through Apache.
-
-This module gets imported by mod_python during its startup. Thus, the
-appmap instance becomes a global, computed only once. If you need to
-recompute the theme, for example, restart the Apache.
-"""
-import time
-from cStringIO import StringIO
-
-from mod_python import apache
-from deliverance import AppMap
-appmap = AppMap() # Theme is generated once at module import time
-
-def outputfilter(filter):
- if not hasattr(filter.req, 'notheme'):
- # Check for a flag to not apply theme
- args = filter.req.args
- if args and args.find("notheme") > -1:
- filter.req.notheme = True
- else:
- filter.req.notheme = False
-
- try:
- streambuffer = filter.req.streambuffer
- except AttributeError:
- if filter.req.notheme:
- # pass on if no theme
- filter.pass_on()
- return
- elif not filter.req.headers_out.has_key("content-type"):
- # pass on if no content type specified
- filter.pass_on()
- return
- elif not filter.req.headers_out["content-type"].startswith("text/html"):
- # pass on if not HTML
- filter.pass_on()
- return
-
- filter.req.streambuffer = StringIO()
- streambuffer = filter.req.streambuffer
-
- streamlet = filter.readline()
- while streamlet:
- streambuffer.write(streamlet)
- streamlet = filter.readline()
-
- if streamlet is None:
- output = appmap.publish(streambuffer.getvalue())
- filter.req.headers_out["Content-Length"] = str(len(output))
- filter.write(output)
- filter.close()
-
-
-def handler(req):
- """Basic filter applying to all mime types it is registered for"""
-
- # Get the path, strip off leading slash, and convert to a
- # dotted notation for xml:id compatibility
- path_info = req.path_info[1:]
- dotted_path = path_info.replace("/", ".")
-
- response = appmap.publish(dotted_path)
- req.content_type = "text/html"
- req.write(response)
-
- return apache.OK
More information about the z3-checkins
mailing list