[z3-checkins] r55553 - z3/deliverance/sandboxes/paul/environ
paul at codespeak.net
paul at codespeak.net
Wed Jun 4 15:08:22 CEST 2008
Author: paul
Date: Wed Jun 4 15:08:19 2008
New Revision: 55553
Added:
z3/deliverance/sandboxes/paul/environ/dvrun.sh
z3/deliverance/sandboxes/paul/environ/dvserve.ini
z3/deliverance/sandboxes/paul/environ/dvswitcher.py
z3/deliverance/sandboxes/paul/environ/example.html
z3/deliverance/sandboxes/paul/environ/rules.xml
Modified:
z3/deliverance/sandboxes/paul/environ/README.txt
Log:
Adapted example to work with Deliverance
Modified: z3/deliverance/sandboxes/paul/environ/README.txt
==============================================================================
--- z3/deliverance/sandboxes/paul/environ/README.txt (original)
+++ z3/deliverance/sandboxes/paul/environ/README.txt Wed Jun 4 15:08:19 2008
@@ -9,6 +9,21 @@
2) Execute ``PYTHONPATH=. paster serve serve.ini``
+
+Running Deliverance Themeswitcher
+--------------------------------------
+
+The files prefixed with ``dv`` connote the adaption of this to
+actually do Deliverance themeswitching middleware:
+
+1) ``sh dvrun.sh``
+
+2) Go to ``http://localhost:8080/example.html``
+
+You might have to reload that URL a second time to get it to take
+affect. Note that this example doesn't switch rule files, but that's
+easy (just call ``set_rule_uri``).
+
Purpose
--------------
Added: z3/deliverance/sandboxes/paul/environ/dvrun.sh
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/environ/dvrun.sh Wed Jun 4 15:08:19 2008
@@ -0,0 +1,2 @@
+
+PYTHONPATH=.:/Users/paul/projects/deliverance/trunk paster serve dvserve.ini
\ No newline at end of file
Added: z3/deliverance/sandboxes/paul/environ/dvserve.ini
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/environ/dvserve.ini Wed Jun 4 15:08:19 2008
@@ -0,0 +1,21 @@
+[server:main]
+use = egg:Paste#http
+
+[pipeline:main]
+pipeline = egg:Paste#evalerror
+ egg:Paste#httpexceptions
+ themeswitcher
+ deliverance
+ content
+
+[app:content]
+use = egg:Paste#static
+document_root = %(here)s
+
+[filter:themeswitcher]
+paste.filter_app_factory = dvswitcher:make_themeswitcher
+
+[filter:deliverance]
+paste.filter_app_factory = deliverance.wsgimiddleware:make_filter
+theme_uri = http://repoze.org/index.html
+rule_uri = file:///%(here)s/rules.xml
\ No newline at end of file
Added: z3/deliverance/sandboxes/paul/environ/dvswitcher.py
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/environ/dvswitcher.py Wed Jun 4 15:08:19 2008
@@ -0,0 +1,21 @@
+"""WSGI middleware to switch Deliverance themes"""
+
+from deliverance.utils import set_theme_uri
+
+class ThemeSwitcher:
+
+ def __init__(self, app):
+ self.app = app
+ print "Creating ThemeSwitcher filter"
+
+ def __call__(self, environ, start_response):
+ newuri = "http://www.w3.org"
+ print "Calling Switcher.__call__ to set_theme_uri to", newuri
+ set_theme_uri(environ, newuri)
+ response_iter = self.app(environ, start_response)
+ return response_iter
+
+def make_themeswitcher(app, global_conf, **kw):
+ """Choose which Deliverance theme should be used"""
+
+ return ThemeSwitcher(app)
Added: z3/deliverance/sandboxes/paul/environ/example.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/environ/example.html Wed Jun 4 15:08:19 2008
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Title from example.html</title>
+ <link rel="stylesheet" type="text/css" href="theme.css"/>
+ </head>
+ <body>
+ <div id="content">
+ <h1>Content from the theme</h1>
+ <p>From the content file (example.html), not the
+ theme. No. </p>
+ </div>
+ </body>
+</html>
Added: z3/deliverance/sandboxes/paul/environ/rules.xml
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/environ/rules.xml Wed Jun 4 15:08:19 2008
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<rules xmlns="http://www.plone.org/deliverance">
+ <append-or-replace theme="/html/head" content="/html/head/title"/>
+ <replace theme="/html/body//div[@id='content']" content="/html/body//div[@id='content']"/>
+</rules>
More information about the z3-checkins
mailing list