From paul at codespeak.net Wed Jul 5 18:09:58 2006 From: paul at codespeak.net (paul at codespeak.net) Date: Wed, 5 Jul 2006 18:09:58 +0200 (CEST) Subject: [z3-checkins] r29645 - in z3/deliverance/branches: . namespaced Message-ID: <20060705160958.CB71F1005A@code0.codespeak.net> Author: paul Date: Wed Jul 5 18:09:57 2006 New Revision: 29645 Added: z3/deliverance/branches/ z3/deliverance/branches/namespaced/ Log: Moving the namespaced stuff over From paul at codespeak.net Wed Jul 5 20:50:30 2006 From: paul at codespeak.net (paul at codespeak.net) Date: Wed, 5 Jul 2006 20:50:30 +0200 (CEST) Subject: [z3-checkins] r29651 - in z3/deliverance/branches/namespaced: . content doc etc themes themes/simple Message-ID: <20060705185030.9507C100AC@code0.codespeak.net> Author: paul Date: Wed Jul 5 20:50:26 2006 New Revision: 29651 Added: z3/deliverance/branches/namespaced/README.txt z3/deliverance/branches/namespaced/content/ z3/deliverance/branches/namespaced/content/localhello.html z3/deliverance/branches/namespaced/deliverance.py z3/deliverance/branches/namespaced/doc/ z3/deliverance/branches/namespaced/doc/NOTES.rst z3/deliverance/branches/namespaced/etc/ z3/deliverance/branches/namespaced/etc/appmap.xml z3/deliverance/branches/namespaced/etc/themecontent.xml z3/deliverance/branches/namespaced/etc/themerules.xml z3/deliverance/branches/namespaced/modpython.conf z3/deliverance/branches/namespaced/modpython.py z3/deliverance/branches/namespaced/renderer.xsl z3/deliverance/branches/namespaced/themecompiler.xsl z3/deliverance/branches/namespaced/themes/ z3/deliverance/branches/namespaced/themes/simple/ z3/deliverance/branches/namespaced/themes/simple/sampletheme.xml z3/deliverance/branches/namespaced/themes/simple/simpletheme.css Log: First commit of refactored Deliverance, sans the content publishing part Added: z3/deliverance/branches/namespaced/README.txt ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/README.txt Wed Jul 5 20:50:26 2006 @@ -0,0 +1,15 @@ +======================================= +Deliverancy, high-speed themes for Zope +======================================= + +Quick Start +----------- + +1) Install lxml. + +2) cd to the directory containing this README. + +3) python ./deliverance.py + +This runs the timeit function, showing average time to apply a simple theme. + Added: z3/deliverance/branches/namespaced/content/localhello.html ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/content/localhello.html Wed Jul 5 20:50:26 2006 @@ -0,0 +1,12 @@ + + + + + Hello World + + +

Hello title

+

Hello world

+ + \ No newline at end of file Added: z3/deliverance/branches/namespaced/deliverance.py ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/deliverance.py Wed Jul 5 20:50:26 2006 @@ -0,0 +1,156 @@ + +import os +from lxml import etree +from time import time +from lxml.etree import Namespace, ElementBase + + +nsmap = { + "dv": "http://www.plone.org/deliverance", + "html": "http://www.w3.org/1999/xhtml", + "xsl": "http://www.w3.org/1999/XSL/Transform", + "at": "http://plone.org/archetypes", + } + +class AppMap: + + def __init__(self): + + # Open the appmap file, make a tree, and process XIncludes + self.module_dir = os.path.dirname(os.path.abspath(__file__)) + layoutsfn = os.path.join(self.module_dir, "etc/appmap.xml") + self.tree = etree.ElementTree(file=layoutsfn) + self.tree.xinclude() + + # Make a themeprocessor to style all outgoing pages. Note that the + # .processor attribute comes from an lxml namespace binding, meaning it is + # defined via a custom Python class defined below (class LayoutElement) + root = self.tree.getroot() + layout = root.xpath("dv:layouts/dv:layout", nsmap)[0] + self.themeprocessor = layout.processor + + + def publish(self, xmlstring): + """Given a string of XML, theme it""" + + # Stage 1 and 2, get an etree for the rendered resource + resource = etree.XML(xmlstring) + + # Stage 3, apply theme + response = str(self.themeprocessor(resource)) + + return response + +# The following are extensions based on lxml namespace extensions. It +# adds Python behavior to XML nodes. + +class DVRuleBase(ElementBase): + + def getThemeNode(self): + """Get a node in the theme doc""" + + # Current node is a rule, get xpath from the @theme attr + themedoc = self.xpath("../../dv:theme", nsmap)[0][0] + xpath = self.get("theme") + try: + themenode = themedoc.xpath(xpath, nsmap)[0] + except IndexError: + msg = "Themedoc has no node at: %s" % xpath + print msg + themenode = None + + return themenode + + +class LayoutElement(ElementBase): + + def processor(self): + """Make XSLT processor by changing theme based on rules""" + + # Apply all the rules + for rule in self.xpath("./dv:rules/*", nsmap): + rule.apply() + + # Merge applied rules into compilerdoc + compilerroot = self.xpath("../dv:compiler/xsl:stylesheet", nsmap)[0] + themeroot = self.xpath("dv:theme/html:html", nsmap)[0] + target = compilerroot.xpath("xsl:template[@match='/']", nsmap)[0] + target.append(themeroot) + + #print etree.tostring(compilerroot) + + return etree.XSLT(compilerroot) + + processor = property(processor) + + +class RuleReplaceElement(DVRuleBase): + + def apply(self): + # TODO: Someething here + themenode = self.getThemeNode() + if themenode is None: + return + del(themenode[:]) + themenode.text = None + xslvalueof = etree.SubElement(themenode, + "{%s}value-of" % nsmap["xsl"]) + xslvalueof.set("select", self.get("content")) + + +class RuleCopyElement(DVRuleBase): + + def apply(self): + themenode = self.getThemeNode() + if themenode is None: + return + del(themenode[:]) + themenode.text = None + xslvalueof = etree.SubElement(themenode, + "{%s}apply-templates" % nsmap["xsl"]) + xslvalueof.set("select", self.get("content")) + + +class RuleAppendElement(DVRuleBase): + + def apply(self): + themenode = self.getThemeNode() + if themenode is None: + return + xslvalueof = etree.SubElement(themenode, + "{%s}apply-templates" % nsmap["xsl"]) + xslvalueof.set("select", self.get("content")) + + +# lxml Namespace support +namespace = Namespace(nsmap['dv']) +namespace['layout'] = LayoutElement +namespace['replace'] = RuleReplaceElement +namespace['copy'] = RuleCopyElement +namespace['append'] = RuleAppendElement + + +def testit(xmlstring): + + appmap = AppMap() + result = appmap.publish(xmlstring) + + return result + +def timeit(xmlstring): + appmap = AppMap() + start = time() + iters = 50 + for i in range(iters): + result = appmap.publish(xmlstring) + print result[0:2000] + print "Average time:", (time() - start) / iters + +def main(): + xmlstring = open("content/localhello.html").read() + timeit(xmlstring) + #testit(path1) + +if __name__ == "__main__": + result = main() + print result Added: z3/deliverance/branches/namespaced/doc/NOTES.rst ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/doc/NOTES.rst Wed Jul 5 20:50:26 2006 @@ -0,0 +1,43 @@ +=============== +Random Notes +=============== + +This file collects random points to weave into other document docs. + +0) You can do runtime creation of themes from remote URLs. This is a lot easier than +you'd think. It could be possible to even build a reasonably smart, productive web +front end for finding the plug points on each side. (About the only part that would +take some thinking is URL rewriting for stuff that keeps getting served by another +host, such as images and CSS.) + +1) The mod_python integration is done as a handler rather than a filter. This is just +historical: In something else, am currently using the module to also resolve certain +URLs that are managed in an XML "map". + +2) For the XML "map" stuff, xml:id support is what makes it so fast. However, this +imposes some limitations. For example, you can't have slashes in xml:id values. + +3) Yeh, it doesn't have tests, other than the timeit function at the bottom +of deliverance.py. I'm not yet much of a programmer. I hope to fix this deficiency +during downtime in July. + +4) Neat point: Because of XInclude, the appmap XML document has everything it +needs, including the generated stuff, in a view-source friendly format. Want to +see what's happening? Just dump the XML document and look at it. + +5) The theme doesn't have to be well-formed XML. The HTMLParser can handle garbage as +input and generate well-formed (though perhaps not valid) stuff on output. + +6) The append rule in etc/themerules.xml shows that you can easily copy page-specific +CSS, JS, etc. from the content document's into the resulting . + +7) Extensibility is provided through XML namespaces and lxml's namespace binding +support. Want a new rule? Just add it and bind a Python handler to it. + +8) The "compilation" step provides a nice opportunity to accomplish two goals: + +a. Make things simple. Deliverance doesn't expose XSLT to users. Other things +can be hidden as well. + +b. Optimize. If there are calculations that are dynamic, but only calculated +once, they can be moved into this little pipeline. Added: z3/deliverance/branches/namespaced/etc/appmap.xml ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/etc/appmap.xml Wed Jul 5 20:50:26 2006 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + Added: z3/deliverance/branches/namespaced/etc/themecontent.xml ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/etc/themecontent.xml Wed Jul 5 20:50:26 2006 @@ -0,0 +1,12 @@ + + + + + + + + + + + + Added: z3/deliverance/branches/namespaced/etc/themerules.xml ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/etc/themerules.xml Wed Jul 5 20:50:26 2006 @@ -0,0 +1,8 @@ + + + + + + + Added: z3/deliverance/branches/namespaced/modpython.conf ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/modpython.conf Wed Jul 5 20:50:26 2006 @@ -0,0 +1,12 @@ +# This module can be pointed to from your main Apache +# configuration file to apply a theme to certain parts of your +# URL space + +LoadModule python_module modules/mod_python.so + + + AddHandler mod_python .py + PythonHandler modpython + PythonDebug On + + Added: z3/deliverance/branches/namespaced/modpython.py ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/modpython.py Wed Jul 5 20:50:26 2006 @@ -0,0 +1,25 @@ +""" +Deliverance publisher for mod_python + +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. +""" + +from mod_python import apache +from deliverance import AppMap +appmap = AppMap() + +def handler(req): + """Basic handler 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 Added: z3/deliverance/branches/namespaced/renderer.xsl ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/renderer.xsl Wed Jul 5 20:50:26 2006 @@ -0,0 +1,67 @@ + + + + localhello + /sandboxes/trois/trunk/deliverance/examples/plonenet.py + + + + + + <xsl:value-of select="$contentnode/@title"/> + + + + +
+ + +
+ + + +
+ +
+

sitenav

+ + +
+
+ + +
    +
  • Item one
  • + +
  • + +
  • +
    +
+
+ + +

+ +

+
+ + + + + +
Added: z3/deliverance/branches/namespaced/themecompiler.xsl ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/themecompiler.xsl Wed Jul 5 20:50:26 2006 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + Added: z3/deliverance/branches/namespaced/themes/simple/sampletheme.xml ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/themes/simple/sampletheme.xml Wed Jul 5 20:50:26 2006 @@ -0,0 +1,24 @@ + + + + + Theme Title + + + +
+ Banjos + enfold | zea +
+
+

Theme Title

+ +
This gets replaced because it is theme content.
+ +
+ + Added: z3/deliverance/branches/namespaced/themes/simple/simpletheme.css ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/themes/simple/simpletheme.css Wed Jul 5 20:50:26 2006 @@ -0,0 +1,26 @@ + +body { + font-size: 0.9em; + font-family: Helvetica; + margin: 0; +} + +#agiheader { + height: 3.5em; + background-color: lightgray; + padding: 0.5em; +} + +#pageframe { + margin: 2em; +} + +#agifooter { + position: fixed; + bottom: 0; + left: 0; + height: 1.8em; + width: 100%; + background-color:yellow; + padding: 0.4em; +} From paul at codespeak.net Wed Jul 5 20:53:29 2006 From: paul at codespeak.net (paul at codespeak.net) Date: Wed, 5 Jul 2006 20:53:29 +0200 (CEST) Subject: [z3-checkins] r29652 - z3/deliverance/branches/namespaced Message-ID: <20060705185329.7F851100AD@code0.codespeak.net> Author: paul Date: Wed Jul 5 20:53:28 2006 New Revision: 29652 Modified: z3/deliverance/branches/namespaced/README.txt Log: First commit of refactored Deliverance, sans the content publishing part Modified: z3/deliverance/branches/namespaced/README.txt ============================================================================== --- z3/deliverance/branches/namespaced/README.txt (original) +++ z3/deliverance/branches/namespaced/README.txt Wed Jul 5 20:53:28 2006 @@ -13,3 +13,18 @@ This runs the timeit function, showing average time to apply a simple theme. + +How Does This Work? +------------------- + +There are proposals on zope.org and other places that explain the idea. Here's +the short version: + +1) A configuration "map" points at a pile of HTML artifacts that look the +way you'd like your site to look. Let's call this a "theme". + +2) A rule file defines boxes in that theme that should get filled by boxes +coming from the dynamic side. + +3) At startup, a one-time compilation processes turns the theme into a +high-speed XSLT transform. From jwashin at codespeak.net Thu Jul 6 04:26:56 2006 From: jwashin at codespeak.net (jwashin at codespeak.net) Date: Thu, 6 Jul 2006 04:26:56 +0200 (CEST) Subject: [z3-checkins] r29661 - in z3/jsonserver/trunk: . jsolait tests Message-ID: <20060706022656.EA9B8100B0@code0.codespeak.net> Author: jwashin Date: Thu Jul 6 04:26:50 2006 New Revision: 29661 Modified: z3/jsonserver/trunk/CHANGES.txt z3/jsonserver/trunk/README.txt z3/jsonserver/trunk/configure.zcml z3/jsonserver/trunk/interfaces.py z3/jsonserver/trunk/jsolait/install_jsolait.py z3/jsonserver/trunk/jsoncomponent.py z3/jsonserver/trunk/jsonrpc.py z3/jsonserver/trunk/minjson.py z3/jsonserver/trunk/tests/test_json.py z3/jsonserver/trunk/tests/test_jsonrpcpublication.py Log: updates for 3.3 Modified: z3/jsonserver/trunk/CHANGES.txt ============================================================================== --- z3/jsonserver/trunk/CHANGES.txt (original) +++ z3/jsonserver/trunk/CHANGES.txt Thu Jul 6 04:26:50 2006 @@ -17,4 +17,8 @@ Upgrade to this version of jsolait using the installer is optional. 20060511 Removed gzip support, since that can be done more elegantly by other - means. Preliminary support for json-rpc 1.1. \ No newline at end of file + means. Preliminary support for json-rpc 1.1. + +20060619 Fixed a few license headers. Everything is pure ZPL now. Updated + to match trunk, particularly ctheune's method from xmlrpc for removing proxies. + \ No newline at end of file Modified: z3/jsonserver/trunk/README.txt ============================================================================== --- z3/jsonserver/trunk/README.txt (original) +++ z3/jsonserver/trunk/README.txt Thu Jul 6 04:26:50 2006 @@ -18,8 +18,9 @@ Dependencies: ------------- -This package will work with (unreleased) zope3 version 3.2 or greater, currently -the development version available at svn://svn.zope.org/repos/main/Zope3/trunk +This package will work with Zope 3 version 3.3 or greater. The svn version of +jsonserver tries hard to keep up with Zope 3's development version available at +svn://svn.zope.org/repos/main/Zope3/trunk. jsolait from http://jsolait.net is the recommended client-side javascript library. Installation of jsolait is covered in the README.txt file in this @@ -136,7 +137,7 @@ or other json implementations have functions for reading and writing JSON objects. -The text of a JSON-RPC request looks like: +The text of a JSON-RPC request (v1.0) looks like: :: @@ -166,6 +167,17 @@ reader. Hint: Use the minjson.write(object) and minjson.read(string) methods for conversion before and after transport. +Dojo +---- + +JSON-RPC in Dojo should work out-of-the-box with jsonserver, since it provides the +proper content-type, application/jsonrpc. A preliminary package that serves a +per-object ".smd" file is available at dojosupport. + +Dojo is available at http://dojotoolkit.org. + +dojosupport is available at http://zif.hill-street.net/dojosupport + Page Templates, Form Variables, and Named Parameters: _______________________________________________________ Modified: z3/jsonserver/trunk/configure.zcml ============================================================================== --- z3/jsonserver/trunk/configure.zcml (original) +++ z3/jsonserver/trunk/configure.zcml Thu Jul 6 04:26:50 2006 @@ -55,6 +55,21 @@ permission="zope.Public" /> + + + + + + - - + + - + Modified: z3/jsonserver/trunk/interfaces.py ============================================================================== --- z3/jsonserver/trunk/interfaces.py (original) +++ z3/jsonserver/trunk/interfaces.py Thu Jul 6 04:26:50 2006 @@ -16,6 +16,8 @@ #2005-08-16 A few changes needed after a zope3 trunk change #2005-11-07 Allowed IDefaultBrowserLayer in JSONRPCRequest. This permits skin # lookups +#2006-06-19 Removed reference to IPresentation and added interface for +# Premarshaller jmw from zope.publisher.interfaces import IPublishTraverse from zope.publisher.interfaces.http import IHTTPApplicationRequest,\ @@ -67,12 +69,12 @@ # the one in zope.app.publisher.xmlrpc # """ -class IJSONRPCPresentation(IPresentation): - """JSONRPC Presentation - like zope.app.publisher.interfaces.xmlrpc.IXMLRPCPresentation - """ - -class IJSONRPCView(IJSONRPCPresentation,IView): +class IJSONRPCView(IView): """JSONRPC View like zope.app.publisher.interfaces.xmlrpc.IXMLRPCView """ + +class IJSONRPCPremarshaller(Interface): + """Premarshaller to remove security proxies""" + def __call__(): + """return the object without proxies""" Modified: z3/jsonserver/trunk/jsolait/install_jsolait.py ============================================================================== --- z3/jsonserver/trunk/jsolait/install_jsolait.py (original) +++ z3/jsonserver/trunk/jsolait/install_jsolait.py Thu Jul 6 04:26:50 2006 @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (c) 2005 Jim Washington and Contributors. +# Copyright (c) 2005 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, Modified: z3/jsonserver/trunk/jsoncomponent.py ============================================================================== --- z3/jsonserver/trunk/jsoncomponent.py (original) +++ z3/jsonserver/trunk/jsoncomponent.py Thu Jul 6 04:26:50 2006 @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (c) 2005 Jim Washington and Contributors. +# Copyright (c) 2005 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, Modified: z3/jsonserver/trunk/jsonrpc.py ============================================================================== --- z3/jsonserver/trunk/jsonrpc.py (original) +++ z3/jsonserver/trunk/jsonrpc.py Thu Jul 6 04:26:50 2006 @@ -21,12 +21,13 @@ #2005-10-09 unicode handling update #2006-03-09 enabled gzip compression for large responses #2006-05-10 removed gzip compression and (prematurely) enabled json-rpc 1.1 jmw +#2006-06-19 updated with ctheune's xmlrpc solution for removing proxies jmw __docformat__ = 'restructuredtext' from zope.app.publication.http import BaseHTTPPublication from interfaces import IMethodPublisher, IJSONRPCView, IJSONRPCPublisher,\ - IJSONRPCRequest, IJSONReader, IJSONWriter + IJSONRPCRequest, IJSONReader, IJSONWriter, IJSONRPCPremarshaller from zope.interface import implements #from zope.publisher.http import IResult from zope.location.location import Location @@ -239,30 +240,69 @@ logger.log(DEBUG,"Exception: %s" % result) self.setStatus(200) -def premarshal_dict(data): - """return a non-proxied dict""" - return dict([(premarshal(k), premarshal(v)) - for (k, v) in data.items()]) - -def premarshal_list(data): - """return a non-proxied list""" - return map(premarshal, data) - -#note: no dates or datetimes in json, though supported by xmlrpc -premarshal_dispatch_table = { - dict: premarshal_dict, - list: premarshal_list, - tuple: premarshal_list, - } +# premarshal code adapted from zope.publisher.xmlrpc.py 20060619 +# should just use XMLRPC premarshaling after we do not have to worry about +# code not being in the standard library. This probably will originate in 3.3. + +class PreMarshallerBase(object): + """Abstract base class for pre-marshallers.""" + implements(IJSONRPCPremarshaller) -premarshal_dispatch = premarshal_dispatch_table.get + def __init__(self, data): + self.data = data + + def __call__(self): + raise Exception, "Not implemented" + +class DictPreMarshaller(PreMarshallerBase): + """Pre-marshaller for dicts""" + + def __call__(self): + return dict([(premarshal(k), premarshal(v)) + for (k, v) in self.data.items()]) + +class ListPreMarshaller(PreMarshallerBase): + """Pre-marshaller for list""" + + def __call__(self): + return map(premarshal, self.data) def premarshal(data): - premarshaller = premarshal_dispatch(data.__class__) + """Premarshal data before handing it to xmlrpclib for marhalling + + The initial purpose of this function is to remove security proxies + without resorting to removeSecurityProxy. This way, we can avoid + inadvertently providing access to data that should be protected. + """ + premarshaller = IJSONRPCPremarshaller(data, alternate=None) if premarshaller is not None: - return premarshaller(data) + return premarshaller() return data +#def premarshal_dict(data): + #"""return a non-proxied dict""" + #return dict([(premarshal(k), premarshal(v)) + #for (k, v) in data.items()]) + +#def premarshal_list(data): + #"""return a non-proxied list""" + #return map(premarshal, data) + +##note: no dates or datetimes in json, though supported by xmlrpc +#premarshal_dispatch_table = { + #dict: premarshal_dict, + #list: premarshal_list, + #tuple: premarshal_list, + #} + +#premarshal_dispatch = premarshal_dispatch_table.get + +#def premarshal(data): + #premarshaller = premarshal_dispatch(data.__class__) + #if premarshaller is not None: + #return premarshaller(data) + #return data + class JSONRPCView(object): """A base JSON-RPC view that can be used as mix-in for JSON-RPC views. Modified: z3/jsonserver/trunk/minjson.py ============================================================================== --- z3/jsonserver/trunk/minjson.py (original) +++ z3/jsonserver/trunk/minjson.py Thu Jul 6 04:26:50 2006 @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (c) 2005 Jim Washington and Contributors. +# Copyright (c) 2005 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, Modified: z3/jsonserver/trunk/tests/test_json.py ============================================================================== --- z3/jsonserver/trunk/tests/test_json.py (original) +++ z3/jsonserver/trunk/tests/test_json.py Thu Jul 6 04:26:50 2006 @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2005 Jim Washington and Contributors. +# Copyright (c) 2005 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, Modified: z3/jsonserver/trunk/tests/test_jsonrpcpublication.py ============================================================================== --- z3/jsonserver/trunk/tests/test_jsonrpcpublication.py (original) +++ z3/jsonserver/trunk/tests/test_jsonrpcpublication.py Thu Jul 6 04:26:50 2006 @@ -15,6 +15,8 @@ modified from zope.app.publication.tests.test_xmlrpcpublication.py jwashin 2005-06-06 +removed references to JSONRPCPresentation 20060619 jmw + """ import unittest @@ -25,7 +27,6 @@ from zope.interface import Interface, implements from zope.proxy import removeAllProxies from zope.publisher.interfaces import NotFound -from jsonserver.interfaces import IJSONRPCPresentation from jsonserver.interfaces import IJSONRPCRequest from jsonserver.interfaces import IJSONRPCPublisher from jsonserver.jsonrpc import TestRequest @@ -71,19 +72,19 @@ class V(object): def __init__(self, context, request): pass - implements(IJSONRPCPresentation) + implements(IJSONRPCPublisher) ob = C() r = self._createRequest('/foo', pub) - ztapi.provideView(I, IJSONRPCPresentation, Interface, 'view', V) - ztapi.setDefaultViewName(I, 'view', type=IJSONRPCPresentation) + ztapi.provideView(I, IJSONRPCPublisher, Interface, 'view', V) + ztapi.setDefaultViewName(I, 'view', type=IJSONRPCPublisher) self.assertRaises(NotFound, pub.traverseName, r, ob, 'foo') def testTraverseNameView(self): pub = self.klass(self.db) - + from jsonserver.jsonrpc import IJSONRPCPublisher class I(Interface): pass @@ -95,7 +96,7 @@ class V(object): def __init__(self, context, request): pass - implements(IJSONRPCPresentation) + implements(IJSONRPCPublisher) # Register the simple traverser so we can traverse without @@ From paul at codespeak.net Fri Jul 7 09:22:32 2006 From: paul at codespeak.net (paul at codespeak.net) Date: Fri, 7 Jul 2006 09:22:32 +0200 (CEST) Subject: [z3-checkins] r29713 - z3/deliverance/branches/namespaced/doc Message-ID: <20060707072232.189A810087@code0.codespeak.net> Author: paul Date: Fri Jul 7 09:22:28 2006 New Revision: 29713 Added: z3/deliverance/branches/namespaced/doc/INSTALL.txt z3/deliverance/branches/namespaced/doc/INTRO.txt z3/deliverance/branches/namespaced/doc/NOTES.txt z3/deliverance/branches/namespaced/doc/NewWorld.txt z3/deliverance/branches/namespaced/doc/meldXREADME.txt Log: Need to rewrite all this stuff...for now, just putting it in one place Added: z3/deliverance/branches/namespaced/doc/INSTALL.txt ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/doc/INSTALL.txt Fri Jul 7 09:22:28 2006 @@ -0,0 +1,80 @@ +====================== +Setting up Deliverance +====================== + +The whole idea of Deliverance is that it *shouldn't* be a system. +It's just a thin approach that leverages some serious work being done +by others. In this case, Deliverance gets most of its value from: + + o Apache. Don't fight it, love it! Yeh, baby! + + o mod_python for both handlers and filters. + + o lxml and thus libxml2/libxslt. This is 90% of the value + proposition. + +mod_python +---------- + +1) Grab mod_python. + +2) Make sure you can do this: + + http://www.modpython.org/live/current/doc-html/inst-testing.html + +3) Make sure Apache can read/write to the Deliverance examples directory. + + +lxml +----- + +1) Get 0.6 or later of lxml: + + http://codespeak.net/lxml + +2) Make sure you can run some of the tests. + +3) Make sure you install it using the same Python used in mod_python. + To confirm, put: + + import lxml.etree + +...in the mptest.py module used in the mod_python Testing example. + + +Deliverance +----------- + +1) Put a line like this: + + Include /Users/paul/projects/deliverance/examples/plonenet/etc/plonenet.conf + +...in your Apache http.conf file. + +2) Edit that plonenet.conf file: + + a. Change the Alias and Location lines to something meaningful. + + b. Makes sure the LoadModule points at the right mod_python. + + c. Fix the PythonPath line. + +3) Restart Apache. + +4) Go to the URL you put for the Location in the conf file and add + "/echo123" on the URL. + +You should see the sample file (content/echo123.xml) with the plonenet +theme. If not, check the Apache error log for details. Possibly the +web page will return a useful error message. + +5) If you make changes to the theme file + (e.g. content/plonenettheme.xml), you currently have to "compile" + it manually: + + a. cd to the plonenet/lib directory. + + b. run sh ./compiletheme.sh + + c. Restart Apache. + Added: z3/deliverance/branches/namespaced/doc/INTRO.txt ============================================================================== --- (empty file) +++ z3/deliverance/branches/namespaced/doc/INTRO.txt Fri Jul 7 09:22:28 2006 @@ -0,0 +1,330 @@ +============================== +Deliverance +============================== +Content deliver for CMS systems +------------------------------ + +*Note: Work in progress. Some of the ideas, particulary the content + map, are in flux.* + +CMS systems, particularly in Zope, excel at the structured environment +of content *production*. This area places a strong emphasis on +security, workflow, metadata, and other content services. + +For content *delivery* on public sites, though, some of this machinery +is overkill. The framework for content production has a nasty side +effect of killing performance for content delivery, making reliability +and debugging a challenge, and forcing other audiences (like web +designers in charge of look-and-feel) to learn another way to do +things. + +For this reason, many ECM packages make a formal distinction between +content production and content delivery. + +Deliverance is a lightweight, semi-static system for content delivery +of CMS resources. It runs in mod_python, generating branded pages and +navigation elements, giving high-performance throughput to anonymous +visitors. Its primary benefits: + + o High performance + + o Simple re-branding + + o Trusted stack + + o Extreme productivity + +It is focused on audiencces that want: + + o Predictable delivery to anonymous visitors + + o Some portion of an airgap (logical/physical) between the CMS and + the live site + + o Integration with mainstream systems and technologies + +This document discusses how the system works, then revisits the +benefits in detail. + +Overview +--------- + +Deliverance has two major parts: + + o *Themes*. These apply a consistent look-and-feel to content that + streams through Apache. This content can be on the filesystem, in + Zope with mod_proxy, or using the other part of Deliverance. In a + nutshell, a theme is an HTML file (plus the CSS, images, etc.) + containing boxes that get filled by content. + + o *Content maps*. A description of the content on a site, including + metadata and different organization schemes. The content map also + has views that, inside Deliverance, can generate HTML for navigation + and other purposes. + +Each of these can be used without the other. + + +How It Works +----------- + +In a nutshell, Deliverance gets an XML map describing all the +published content at a point in time. It uses this map to draw +navigation elements and issue HTTP requests for content of single +resources. Finally, a "theme" provides the HTML to return with named +boxes to be filled by rules. + +Let's first introduce some major concepts, then walk a request through +from start to finish, using these concepts. + +1) *Theme*. Web designers don't want to learn anything new. ZPT +tried to embrace this, but by the time the ZPT developer has injected +all the tal and refactored everything into macros, the web designer +can't possible continue. + +A theme is the corporate identity for a site. It is *not* a template, +as it has zero stuff in it beyond HTML. + +A theme is created by saving the customer's home page and identifying +the boxes to be replaced. For example,