From ldr at codespeak.net Mon Jul 5 20:11:36 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Mon, 5 Jul 2010 20:11:36 +0200 (CEST) Subject: [z3-checkins] r75852 - in z3/xdv/branches/multistage-compiler: . lib/xdv lib/xdv/tests/modify-theme Message-ID: <20100705181136.363C0282BFC@codespeak.net> Author: ldr Date: Mon Jul 5 20:11:33 2010 New Revision: 75852 Added: z3/xdv/branches/multistage-compiler/lib/xdv/dummy.html z3/xdv/branches/multistage-compiler/lib/xdv/identity.xsl Modified: z3/xdv/branches/multistage-compiler/buildout.cfg z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl z3/xdv/branches/multistage-compiler/lib/xdv/boilerplate.xsl z3/xdv/branches/multistage-compiler/lib/xdv/defaults.xsl z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl z3/xdv/branches/multistage-compiler/lib/xdv/rules.py z3/xdv/branches/multistage-compiler/lib/xdv/tests/modify-theme/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/utils.py Log: All but the output doctype test passes now. Probably still some whitespace problems (untested as the tests pretty print). Some stray xmlns should probably be stripped out so never making it into the compiled output. Modified: z3/xdv/branches/multistage-compiler/buildout.cfg ============================================================================== --- z3/xdv/branches/multistage-compiler/buildout.cfg (original) +++ z3/xdv/branches/multistage-compiler/buildout.cfg Mon Jul 5 20:11:33 2010 @@ -12,3 +12,4 @@ [test] recipe = zc.recipe.testrunner eggs = xdv +defaults = ['--auto-color'] Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl Mon Jul 5 20:11:33 2010 @@ -3,6 +3,7 @@ xmlns:dyn="http://exslt.org/dynamic" xmlns:esi="http://www.edge-delivery.org/esi/1.0" xmlns:exsl="http://exslt.org/common" + xmlns:str="http://exslt.org/strings" xmlns:xdv="http://namespaces.plone.org/xdv" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" @@ -78,7 +79,7 @@ - + @@ -105,7 +106,7 @@ - + @@ -117,7 +118,7 @@ " wait="yes" - + @@ -129,7 +130,7 @@ - + ERROR: Unknown includemode or @method attribute Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl Mon Jul 5 20:11:33 2010 @@ -1,6 +1,7 @@ + exclude-result-prefixes="exsl str dv xhtml"> - + + + + + + + + + + + - - - - - - - - - - - - - - - + + - - - - + + - + - + + - - - - - - - - - - - - - + + + - + @@ -140,7 +141,7 @@ - + Added: z3/xdv/branches/multistage-compiler/lib/xdv/identity.xsl ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/identity.xsl Mon Jul 5 20:11:33 2010 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file Modified: z3/xdv/branches/multistage-compiler/lib/xdv/rules.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/rules.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Mon Jul 5 20:11:33 2010 @@ -15,14 +15,14 @@ from urlparse import urljoin from xdv.cssrules import convert_css_selectors -from xdv.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE +from xdv.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, CustomResolver logger = logging.getLogger('xdv') IMPORT_STYLESHEET = re.compile(r'''(@import\s+(?:url\(['"]?|['"]))(.+)(['"]?\)|['"])''', re.IGNORECASE) -def pkg_xsl(name): - return etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name))) +def pkg_xsl(name, parser=None): + return etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name), parser=parser)) update_transform = pkg_xsl('update-namespace.xsl') normalize_rules = pkg_xsl('normalize-rules.xsl') @@ -31,7 +31,6 @@ apply_rules = pkg_xsl('apply-rules.xsl') emit_stylesheet = pkg_xsl('emit-stylesheet.xsl') - def update_namespace(rules_doc): """Convert old namespace to new namespace in place """ @@ -58,6 +57,10 @@ return rules_doc def apply_absolute_prefix(theme_doc, absolute_prefix): + if not absolute_prefix: + return + if not absolute_prefix.endswith('/'): + absolute_prefix = absolute_prefix + '/' for node in theme_doc.xpath('//*[@src]'): url = urljoin(absolute_prefix, node.get('src')) node.set('src', url) @@ -88,11 +91,24 @@ root.append(element) return rules_doc +def set_parser(stylesheet, parser, compiler_parser=None): + dummy_doc = etree.parse(pkg_resources.resource_filename('xdv', 'dummy.html'), parser=parser) + name = 'file:///__xdv__' + resolver = CustomResolver({name: stylesheet}) + if compiler_parser is None: + compiler_parser = etree.XMLParser() + compiler_parser.resolvers.add(resolver) + identity = pkg_xsl('identity.xsl', compiler_parser) + output_doc = identity(dummy_doc, docurl="'%s'"%name) + compiler_parser.resolvers.remove(resolver) + return output_doc + def process_rules(rules, theme=None, extra=None, trace=None, css=True, xinclude=True, absolute_prefix=None, includemode=None, update=True, parser=None, rules_parser=None, compiler_parser=None, access_control=None): if rules_parser is None: rules_parser = etree.XMLParser(recover=False) rules_doc = etree.parse(rules, parser=rules_parser) - + if parser is None: + parser = etree.HTMLParser() if xinclude: rules_doc.xinclude() if update: @@ -106,11 +122,12 @@ includemode = 'document' includemode = "'%s'" % includemode rules_doc = normalize_rules(rules_doc, includemode=includemode) + #import pdb; pdb.set_trace() rules_doc = annotate_themes(rules_doc) rules_doc = annotate_rules(rules_doc) rules_doc = apply_rules(rules_doc) compiled_doc = emit_stylesheet(rules_doc) - #import pdb; pdb.set_trace() + compiled_doc = set_parser(etree.tostring(compiled_doc), parser, compiler_parser) return compiled_doc Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/modify-theme/rules.xml ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/modify-theme/rules.xml (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/modify-theme/rules.xml Mon Jul 5 20:11:33 2010 @@ -12,7 +12,7 @@

- + + + + + + + + + + + + + + + + + + + + + + + + Link + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/rules.xml Tue Jul 6 16:33:21 2010 @@ -0,0 +1,4 @@ + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/options.cfg Tue Jul 6 16:33:21 2010 @@ -0,0 +1,2 @@ +[xdvtest] +absolute-prefix = /abs Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/output.html Tue Jul 6 16:33:21 2010 @@ -0,0 +1,38 @@ + + + + + Absolute prefix + + + + + + + + + + + + + + + + + + + + + + + + Link + + Deleted: /z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute_rules.xml ============================================================================== --- /z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute_rules.xml Tue Jul 6 16:33:21 2010 +++ (empty file) @@ -1,4 +0,0 @@ - - - - Deleted: /z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute_theme.html ============================================================================== --- /z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute_theme.html Tue Jul 6 16:33:21 2010 +++ (empty file) @@ -1,44 +0,0 @@ - - - - Absolute prefix - - - - - - - - - - + + + + + + + + + + + + + + + + + Link + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/output.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/output.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/output.html Tue Jul 6 16:40:30 2010 @@ -4,13 +4,13 @@ Absolute prefix + @import "/abs/foo.css"; + @import url("/abs/foo.css"); + @import url('/abs/foo.css'); + @import url('/foo.css'); + @import url('/foo.css'); + @import url('http://site.com/foo.css'); + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/theme.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/theme.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/theme.html Tue Jul 6 16:40:30 2010 @@ -1,44 +1,38 @@ - - - Absolute prefix - - - - - - - - - - + + + + + + + + + + + + + + + + + Link + From ldr at codespeak.net Tue Jul 6 17:33:32 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Tue, 6 Jul 2010 17:33:32 +0200 (CEST) Subject: [z3-checkins] r75926 - z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang Message-ID: <20100706153332.73CB1282C05@codespeak.net> Author: ldr Date: Tue Jul 6 17:33:30 2010 New Revision: 75926 Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/theme.html Log: XDV 0.3 seems to get confused with lang and xml:lang on the theme. Somehow this got fixed along the way. Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/content.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/content.html Tue Jul 6 17:33:30 2010 @@ -0,0 +1 @@ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/output.html Tue Jul 6 17:33:30 2010 @@ -0,0 +1,9 @@ + + + + + + + Check that xml:lang is not duplicated. + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/rules.xml Tue Jul 6 17:33:30 2010 @@ -0,0 +1,4 @@ + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/theme.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/theme.html Tue Jul 6 17:33:30 2010 @@ -0,0 +1,9 @@ + + + + + + + Check that xml:lang is not duplicated. + + From ldr at codespeak.net Tue Jul 6 17:48:31 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Tue, 6 Jul 2010 17:48:31 +0200 (CEST) Subject: [z3-checkins] r75929 - in z3/xdv/branches/multistage-compiler/lib/xdv: . tests/html-xml-lang-2 Message-ID: <20100706154831.C7F32282C08@codespeak.net> Author: ldr Date: Tue Jul 6 17:48:30 2010 New Revision: 75929 Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/ - copied from r75926, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/ Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/theme.html Log: Check that xml:lang is always set to value of lang Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl Tue Jul 6 17:48:30 2010 @@ -50,6 +50,10 @@
+ + + + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/content.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/content.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/content.html Tue Jul 6 17:48:30 2010 @@ -1 +1 @@ - + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/output.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/output.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/output.html Tue Jul 6 17:48:30 2010 @@ -1,9 +1,9 @@ - + - Check that xml:lang is not duplicated. + Check that xml:lang is always set to value of lang Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/rules.xml ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/rules.xml (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/rules.xml Tue Jul 6 17:48:30 2010 @@ -1,4 +1,4 @@ - + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/theme.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/theme.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/theme.html Tue Jul 6 17:48:30 2010 @@ -4,6 +4,6 @@ - Check that xml:lang is not duplicated. + Check that xml:lang is always set to value of lang From ldr at codespeak.net Tue Jul 6 19:00:58 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Tue, 6 Jul 2010 19:00:58 +0200 (CEST) Subject: [z3-checkins] r75933 - in z3/xdv/branches/multistage-compiler/lib/xdv: . tests/drop-content tests/esi tests/ssi Message-ID: <20100706170058.A37C5282C05@codespeak.net> Author: ldr Date: Tue Jul 6 19:00:57 2010 New Revision: 75933 Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/theme.html Modified: z3/xdv/branches/multistage-compiler/lib/xdv/cssrules.py z3/xdv/branches/multistage-compiler/lib/xdv/tests/esi/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/ssi/output.html Log: Change the css selector prefix so they are relative rather than absolute to the root (normally they are run relative to the root node anyway, so it makes no odds). + +
+
+ Drop this +
+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/output.html Tue Jul 6 19:00:57 2010 @@ -0,0 +1,8 @@ + + + +
+ +
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/rules.xml Tue Jul 6 19:00:57 2010 @@ -0,0 +1,7 @@ + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/theme.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/theme.html Tue Jul 6 19:00:57 2010 @@ -0,0 +1,3 @@ + + + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/esi/output.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/esi/output.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/esi/output.html Tue Jul 6 19:00:57 2010 @@ -2,7 +2,7 @@

theme

- + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/tests/ssi/output.html ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/tests/ssi/output.html (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/ssi/output.html Tue Jul 6 19:00:57 2010 @@ -2,7 +2,7 @@

theme

- + From ldr at codespeak.net Tue Jul 6 19:18:19 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Tue, 6 Jul 2010 19:18:19 +0200 (CEST) Subject: [z3-checkins] r75936 - in z3/xdv/branches/multistage-compiler/lib/xdv: . tests/multi-theme-1 tests/multi-theme-2 Message-ID: <20100706171819.DD5C8282C05@codespeak.net> Author: ldr Date: Tue Jul 6 19:18:18 2010 New Revision: 75936 Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/options.cfg z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme1.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme2.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/options.cfg z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme1.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme2.html Modified: z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py z3/xdv/branches/multistage-compiler/lib/xdv/run.py Log: test for multiple theme support Modified: z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py Tue Jul 6 19:18:18 2010 @@ -135,13 +135,13 @@ dest="extra", default=None) (options, args) = parser.parse_args() - if options.rules is None and options.theme is None: - if len(args) == 2: + if options.rules is None: + if len(args) == 2 and options.theme is None: options.rules, options.theme = args + elif len(args) == 1: + options.rules, = args else: parser.error("Wrong number of arguments.") - elif not(options.rules is not None and options.theme is not None): - parser.error("Both theme and rules must be supplied as options or as arguments.") if options.trace: logger.setLevel(logging.DEBUG) Modified: z3/xdv/branches/multistage-compiler/lib/xdv/run.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/run.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/run.py Tue Jul 6 19:18:18 2010 @@ -69,12 +69,12 @@ parser = etree.XMLParser() output_xslt = etree.parse(transform_path, parser=parser) elif len(args) == 1: - if options.theme and options.rules: + if options.rules: content, = args parser = etree.HTMLParser() output_xslt = compile_theme(rules=options.rules, theme=options.theme, extra=options.extra, parser=parser, access_control=access_control, absolute_prefix=options.absolute_prefix, includemode=options.includemode) else: - op.error("Theme and rules must be supplied.") + op.error("Rules must be supplied.") else: op.error("Wrong number of arguments.") Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/content.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/content.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/options.cfg Tue Jul 6 19:18:18 2010 @@ -0,0 +1,2 @@ +[xdvtest] +theme = Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/output.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,9 @@ + + + +

This is theme 1

+
+

content

+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/rules.xml Tue Jul 6 19:18:18 2010 @@ -0,0 +1,9 @@ + + + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme1.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme1.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,7 @@ + + +

This is theme 1

+
+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme2.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme2.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,7 @@ + + +

This is theme 2

+
+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/content.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/content.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/options.cfg Tue Jul 6 19:18:18 2010 @@ -0,0 +1,2 @@ +[xdvtest] +theme = Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/output.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,9 @@ + + + +

This is theme 2

+
+

content

+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/rules.xml Tue Jul 6 19:18:18 2010 @@ -0,0 +1,9 @@ + + + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme1.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme1.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,7 @@ + + +

This is theme 1

+
+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme2.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme2.html Tue Jul 6 19:18:18 2010 @@ -0,0 +1,7 @@ + + +

This is theme 2

+
+
+ + From ldr at codespeak.net Wed Jul 7 17:07:30 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 7 Jul 2010 17:07:30 +0200 (CEST) Subject: [z3-checkins] r75974 - in z3/xdv/branches/multistage-compiler/lib/xdv: . tests/nested-rules-merge-conditions-1 tests/nested-rules-merge-conditions-2 tests/nested-rules-merge-conditions-3 Message-ID: <20100707150730.EC50A282B9E@codespeak.net> Author: ldr Date: Wed Jul 7 17:07:29 2010 New Revision: 75974 Added: z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/theme.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/theme.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/content.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/output.html z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/rules.xml z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/theme.html Modified: z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Log: nested conditions Added: z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl Wed Jul 7 17:07:29 2010 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl Wed Jul 7 17:07:29 2010 @@ -83,13 +83,13 @@ - + - + - - + + ERROR: Multiple unconditional copy rules may not match a single theme node. @@ -224,26 +224,31 @@ Otherwise keep theme node. --> + - + + + + + @@ -273,10 +278,10 @@ - + - + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Wed Jul 7 17:07:29 2010 @@ -16,8 +16,8 @@ - - + + @@ -37,6 +37,7 @@ + / @@ -44,9 +45,10 @@ + - + . @@ -55,7 +57,9 @@
+
+ . @@ -69,6 +73,7 @@ + @@ -84,12 +89,16 @@ + - THEME + + THEME + + @@ -99,8 +108,10 @@ Do nothing, skip these nodes + + / @@ -110,14 +121,19 @@
+ + + + +
Added: z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl Wed Jul 7 17:07:29 2010 @@ -0,0 +1,27 @@ + + + + + + + + + + () and + + + + + + + + + + + + + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/rules.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/rules.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Wed Jul 7 17:07:29 2010 @@ -26,6 +26,8 @@ update_transform = pkg_xsl('update-namespace.xsl') normalize_rules = pkg_xsl('normalize-rules.xsl') +apply_conditions = pkg_xsl('apply-conditions.xsl') +merge_conditions = pkg_xsl('merge-conditions.xsl') annotate_themes = pkg_xsl('annotate-themes.xsl') annotate_rules = pkg_xsl('annotate-rules.xsl') apply_rules = pkg_xsl('apply-rules.xsl') @@ -122,7 +124,8 @@ includemode = 'document' includemode = "'%s'" % includemode rules_doc = normalize_rules(rules_doc, includemode=includemode) - #import pdb; pdb.set_trace() + rules_doc = apply_conditions(rules_doc) + rules_doc = merge_conditions(rules_doc) rules_doc = annotate_themes(rules_doc) rules_doc = annotate_rules(rules_doc) rules_doc = apply_rules(rules_doc) Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/content.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/content.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,5 @@ + + +

From the content

+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/output.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,8 @@ + + + +
+

From the content

+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/rules.xml Wed Jul 7 17:07:29 2010 @@ -0,0 +1,8 @@ + + + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/theme.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/theme.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,3 @@ +
+
Content
+
Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/content.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/content.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,5 @@ + + +

From the content

+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/output.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,8 @@ + + + +
+
Theme
+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/rules.xml Wed Jul 7 17:07:29 2010 @@ -0,0 +1,8 @@ + + + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/theme.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/theme.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,3 @@ +
+
Theme
+
Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/content.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/content.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,5 @@ + + +

From the content

+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/output.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/output.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,8 @@ + + + +
+
Theme
+
+ + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/rules.xml Wed Jul 7 17:07:29 2010 @@ -0,0 +1,8 @@ + + + + + + Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/theme.html ============================================================================== --- (empty file) +++ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/theme.html Wed Jul 7 17:07:29 2010 @@ -0,0 +1,3 @@ +
+
Theme
+
From ldr at codespeak.net Wed Jul 7 17:08:44 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 7 Jul 2010 17:08:44 +0200 (CEST) Subject: [z3-checkins] r75976 - in z3/xdv/branches/multistage-compiler/lib/xdv/tests: nested-conditions-1 nested-conditions-2 nested-conditions-3 nested-rules-merge-conditions-1 nested-rules-merge-conditions-2 nested-rules-merge-conditions-3 Message-ID: <20100707150844.D77C5282BF5@codespeak.net> Author: ldr Date: Wed Jul 7 17:08:43 2010 New Revision: 75976 Added: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-1/ - copied from r75974, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-2/ - copied from r75974, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-3/ - copied from r75974, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/ Removed: z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-1/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-2/ z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-rules-merge-conditions-3/ Log: rename test From ldr at codespeak.net Wed Jul 7 17:26:39 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 7 Jul 2010 17:26:39 +0200 (CEST) Subject: [z3-checkins] r75984 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100707152639.E4538282B9E@codespeak.net> Author: ldr Date: Wed Jul 7 17:26:38 2010 New Revision: 75984 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl Log: fix null-if-content problem from nested conditions Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl Wed Jul 7 17:26:38 2010 @@ -22,11 +22,6 @@
- - - - - Modified: z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl Wed Jul 7 17:26:38 2010 @@ -9,7 +9,14 @@ - + + + + + + + + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl Wed Jul 7 17:26:38 2010 @@ -11,7 +11,7 @@ - () and + () and From ldr at codespeak.net Wed Jul 7 18:48:44 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 7 Jul 2010 18:48:44 +0200 (CEST) Subject: [z3-checkins] r75996 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100707164844.12C8F282B9E@codespeak.net> Author: ldr Date: Wed Jul 7 18:48:42 2010 New Revision: 75996 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl Log: tidy up Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl Wed Jul 7 18:48:42 2010 @@ -19,11 +19,7 @@ - + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl Wed Jul 7 18:48:42 2010 @@ -20,7 +20,6 @@ - @@ -58,20 +57,7 @@ - + @@ -271,7 +257,6 @@
- @@ -343,5 +328,4 @@
- From ldr at codespeak.net Thu Jul 8 15:14:33 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 8 Jul 2010 15:14:33 +0200 (CEST) Subject: [z3-checkins] r76022 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100708131433.ED971282BFB@codespeak.net> Author: ldr Date: Thu Jul 8 15:14:29 2010 New Revision: 76022 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Log: tidy up generated stylesheet indentation Modified: z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Thu Jul 8 15:14:29 2010 @@ -37,7 +37,7 @@ - + / @@ -92,13 +92,17 @@ - - THEME + + THEME : + + (inline) + + - + @@ -111,7 +115,7 @@ - + / @@ -123,15 +127,17 @@ - - - - - + + + + + + + - + From ldr at codespeak.net Thu Jul 8 16:19:56 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 8 Jul 2010 16:19:56 +0200 (CEST) Subject: [z3-checkins] r76030 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100708141956.8BA52282BFA@codespeak.net> Author: ldr Date: Thu Jul 8 16:19:55 2010 New Revision: 76030 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Log: fix inline xsl Modified: z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Thu Jul 8 16:19:55 2010 @@ -127,7 +127,7 @@ - + @@ -136,7 +136,7 @@ - + From ldr at codespeak.net Thu Jul 8 16:20:20 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 8 Jul 2010 16:20:20 +0200 (CEST) Subject: [z3-checkins] r76031 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100708142020.53E59282BFA@codespeak.net> Author: ldr Date: Thu Jul 8 16:20:16 2010 New Revision: 76031 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Log: restore the trace support Modified: z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl Thu Jul 8 16:20:16 2010 @@ -24,11 +24,19 @@ Apply the rules --> + + + + + + + + + + - - @@ -314,18 +322,29 @@ TRACE: () - - RULE: < - =""/> - + + + + - THEME: THEME: /[@id=''][] + + + + + + : < + =""/> + + + + Modified: z3/xdv/branches/multistage-compiler/lib/xdv/rules.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/rules.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Thu Jul 8 16:20:16 2010 @@ -22,7 +22,17 @@ IMPORT_STYLESHEET = re.compile(r'''(@import\s+(?:url\(['"]?|['"]))(.+)(['"]?\)|['"])''', re.IGNORECASE) def pkg_xsl(name, parser=None): - return etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name), parser=parser)) + xslt = etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name), parser=parser)) + def wrapped(*args, **kw): + result = xslt(*args, **kw) + for msg in xslt.error_log: + if msg.type == etree.ErrorTypes.ERR_OK: + logger.debug(msg.message) + else: + logger.debug(msg) + return result + wrapped.xslt = xslt + return wrapped update_transform = pkg_xsl('update-namespace.xsl') normalize_rules = pkg_xsl('normalize-rules.xsl') @@ -106,6 +116,10 @@ return output_doc def process_rules(rules, theme=None, extra=None, trace=None, css=True, xinclude=True, absolute_prefix=None, includemode=None, update=True, parser=None, rules_parser=None, compiler_parser=None, access_control=None): + if trace: + trace = '1' + else: + trace = '0' if rules_parser is None: rules_parser = etree.XMLParser(recover=False) rules_doc = etree.parse(rules, parser=rules_parser) @@ -128,7 +142,7 @@ rules_doc = merge_conditions(rules_doc) rules_doc = annotate_themes(rules_doc) rules_doc = annotate_rules(rules_doc) - rules_doc = apply_rules(rules_doc) + rules_doc = apply_rules(rules_doc, trace=trace) compiled_doc = emit_stylesheet(rules_doc) compiled_doc = set_parser(etree.tostring(compiled_doc), parser, compiler_parser) return compiled_doc From ldr at codespeak.net Thu Jul 8 20:06:28 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 8 Jul 2010 20:06:28 +0200 (CEST) Subject: [z3-checkins] r76049 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100708180628.621EA282BFA@codespeak.net> Author: ldr Date: Thu Jul 8 20:06:26 2010 New Revision: 76049 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/rules.py z3/xdv/branches/multistage-compiler/lib/xdv/utils.py Log: logging wrapper Modified: z3/xdv/branches/multistage-compiler/lib/xdv/rules.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/rules.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Thu Jul 8 20:06:26 2010 @@ -2,7 +2,7 @@ """\ Usage: %prog RULES -Preprocess RULES, and xdv rules file +Preprocess RULES, an xdv rules file """ usage = __doc__ @@ -15,24 +15,12 @@ from urlparse import urljoin from xdv.cssrules import convert_css_selectors -from xdv.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, CustomResolver +from xdv.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, CustomResolver, pkg_xsl logger = logging.getLogger('xdv') IMPORT_STYLESHEET = re.compile(r'''(@import\s+(?:url\(['"]?|['"]))(.+)(['"]?\)|['"])''', re.IGNORECASE) -def pkg_xsl(name, parser=None): - xslt = etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name), parser=parser)) - def wrapped(*args, **kw): - result = xslt(*args, **kw) - for msg in xslt.error_log: - if msg.type == etree.ErrorTypes.ERR_OK: - logger.debug(msg.message) - else: - logger.debug(msg) - return result - wrapped.xslt = xslt - return wrapped update_transform = pkg_xsl('update-namespace.xsl') normalize_rules = pkg_xsl('normalize-rules.xsl') Modified: z3/xdv/branches/multistage-compiler/lib/xdv/utils.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/utils.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/utils.py Thu Jul 8 20:06:26 2010 @@ -1,4 +1,8 @@ from lxml import etree +import logging +import pkg_resources + +logger=logging.getLogger('xdv') namespaces = dict( xdv="http://namespaces.plone.org/xdv", @@ -24,3 +28,21 @@ output = self.data.get(url) if output is not None: return self.resolve_string(output, context) + + +class LoggingXSLTWrapper: + def __init__(self, xslt, logger): + self.xslt = xslt + self.logger = logger + def __call__(self, *args, **kw): + result = self.xslt(*args, **kw) + for msg in self.xslt.error_log: + if msg.type == etree.ErrorTypes.ERR_OK: + self.logger.debug(msg.message) + else: + self.logger.debug(msg) + return result + + +def pkg_xsl(name, parser=None): + return LoggingXSLTWrapper(etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name), parser=parser)), logger) From ldr at codespeak.net Thu Jul 8 20:24:58 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 8 Jul 2010 20:24:58 +0200 (CEST) Subject: [z3-checkins] r76052 - z3/xdv/branches/multistage-compiler/lib/xdv Message-ID: <20100708182458.1B6C0282BFA@codespeak.net> Author: ldr Date: Thu Jul 8 20:24:55 2010 New Revision: 76052 Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Log: document includes base tag evasion Modified: z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl Thu Jul 8 20:24:55 2010 @@ -97,7 +97,7 @@ - document('', .) + document('', $base) Modified: z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl Thu Jul 8 20:24:55 2010 @@ -12,6 +12,7 @@ exclude-result-prefixes="dv dyn exsl xml"> defaults.xsl + @@ -36,7 +37,35 @@ - + + + + + + + + base + / + + + + + + + + base-rtf + + + + + base + exsl:node-set($base-rtf) + + + + + + / From ldr at codespeak.net Fri Jul 9 17:24:31 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Fri, 9 Jul 2010 17:24:31 +0200 (CEST) Subject: [z3-checkins] r76079 - in z3/xdv/branches/multistage-compiler: . lib/xdv Message-ID: <20100709152431.DB4C3282C07@codespeak.net> Author: ldr Date: Fri Jul 9 17:24:30 2010 New Revision: 76079 Removed: z3/xdv/branches/multistage-compiler/lib/xdv/boilerplate.xsl z3/xdv/branches/multistage-compiler/lib/xdv/compiler.xsl Modified: z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py z3/xdv/branches/multistage-compiler/lib/xdv/rules.py z3/xdv/branches/multistage-compiler/lib/xdv/run.py z3/xdv/branches/multistage-compiler/lib/xdv/utils.py z3/xdv/branches/multistage-compiler/setup.py Log: tidy up Deleted: /z3/xdv/branches/multistage-compiler/lib/xdv/boilerplate.xsl ============================================================================== --- /z3/xdv/branches/multistage-compiler/lib/xdv/boilerplate.xsl Fri Jul 9 17:24:30 2010 +++ (empty file) @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/compiler.py Fri Jul 9 17:24:30 2010 @@ -12,19 +12,31 @@ usage = __doc__ import logging +import pkg_resources import sys from lxml import etree -from optparse import OptionParser -from urlparse import urljoin from xdv.rules import process_rules -from xdv.utils import namespaces, AC_READ_NET, AC_READ_FILE +from xdv.utils import namespaces, AC_READ_NET, AC_READ_FILE, pkg_xsl, _createOptionParser, CustomResolver logger = logging.getLogger('xdv') +emit_stylesheet = pkg_xsl('emit-stylesheet.xsl') -def compile_theme(rules, theme=None, extra=None, css=True, xinclude=True, absolute_prefix=None, update=True, trace=False, includemode=None, parser=None, compiler_parser=None, rules_parser=None, access_control=None): +def set_parser(stylesheet, parser, compiler_parser=None): + dummy_doc = etree.parse(pkg_resources.resource_filename('xdv', 'dummy.html'), parser=parser) + name = 'file:///__xdv__' + resolver = CustomResolver({name: stylesheet}) + if compiler_parser is None: + compiler_parser = etree.XMLParser() + compiler_parser.resolvers.add(resolver) + identity = pkg_xsl('identity.xsl', compiler_parser) + output_doc = identity(dummy_doc, docurl="'%s'"%name) + compiler_parser.resolvers.remove(resolver) + return output_doc + +def compile_theme(rules, theme=None, extra=None, css=True, xinclude=True, absolute_prefix=None, update=True, trace=False, includemode=None, parser=None, compiler_parser=None, rules_parser=None, access_control=None, read_network=False): """Invoke the xdv compiler. * ``rules`` is the rules file @@ -55,84 +67,31 @@ * ``rules_parser`` can be set to an lxml parser instance; the default is a XMLParser. """ - return process_rules(rules, theme=theme, extra=extra, css=css, xinclude=xinclude, absolute_prefix=absolute_prefix, update=update, trace=trace, includemode=includemode, parser=parser, compiler_parser=compiler_parser, rules_parser=rules_parser, access_control=access_control) - if rules_parser is None: - rules_parser = etree.XMLParser(recover=False) - rules_doc = etree.parse(rules, parser=rules_parser) - - if xinclude: - rules_doc.xinclude() - if update: - rules_doc = update_namespace(rules_doc) - if css: - convert_css_selectors(rules_doc) - - if parser is None: - parser = etree.HTMLParser() - if theme is None: - theme_doc = etree.parse(DUMMY_PATH, parser=parser) - else: - theme_doc = etree.parse(theme, parser=parser) - - if absolute_prefix: - apply_absolute_prefix(theme_doc, absolute_prefix) - - if compiler_parser is None: - compiler_parser = etree.XMLParser() - if access_control is None: - access_control = AC_READ_FILE - compiler_transform = etree.XSLT(etree.parse(COMPILER_PATH, parser=compiler_parser), access_control=access_control) - - params = dict(rulesuri="'file:///__xdv__rules'") - if extra: - params['extraurl'] = "'file:///__xdv__extra'" - resolver = CompileResolver(etree.tostring(rules_doc), etree.tostring(etree.parse(extra))) - else: - resolver = CompileResolver(etree.tostring(rules_doc)) - if trace: - params['trace'] = '1' - if includemode: - params['includemode'] = "'%s'" % includemode - - #compiled = compiler_transform(theme_doc, **params) - #for msg in compiler_transform.error_log: - # logger.info(msg) - return compiled + if access_control is not None: + read_network = access_control.options['read_network'] + rules_doc = process_rules( + rules=rules, + theme=theme, + extra=extra, + css=css, + xinclude=xinclude, + absolute_prefix=absolute_prefix, + update=update, + trace=trace, + includemode=includemode, + parser=parser, + rules_parser=rules_parser, + read_network=read_network, + ) + compiled_doc = emit_stylesheet(rules_doc) + compiled_doc = set_parser(etree.tostring(compiled_doc), parser, compiler_parser) + return compiled_doc + def main(): """Called from console script """ - parser = OptionParser(usage=usage) - parser.add_option("-o", "--output", metavar="output.xsl", - help="Output filename (instead of stdout)", - dest="output", default=sys.stdout) - parser.add_option("-p", "--pretty-print", action="store_true", - help="Pretty print output (may alter rendering in browser)", - dest="pretty_print", default=False) - parser.add_option("--trace", action="store_true", - help="Compiler trace logging", - dest="trace", default=False) - parser.add_option("--xinclude", action="store_true", - help="Run XInclude on rules.xml (depracated, xinclude is always run)", - dest="xinclude", default=True) - parser.add_option("-a", "--absolute-prefix", metavar="/", - help="relative urls in the theme file will be made into absolute links with this prefix.", - dest="absolute_prefix", default=None) - parser.add_option("-i", "--includemode", metavar="INC", - help="include mode (document, ssi or esi)", - dest="includemode", default=None) - parser.add_option("-n", "--network", action="store_true", - help="Allow reads to the network to fetch resources", - dest="read_network", default=False) - parser.add_option("-t", "--theme", metavar="theme.html", - help="Theme file", - dest="theme", default=None) - parser.add_option("-r", "--rules", metavar="rules.xml", - help="XDV rules file", - dest="rules", default=None) - parser.add_option("-e", "--extra", metavar="extra.xsl", - help="Extra XSL to be included in the transform (depracated, use inline xsl in the rules instead)", - dest="extra", default=None) + parser = _createOptionParser(usage=usage) (options, args) = parser.parse_args() if options.rules is None: @@ -142,16 +101,21 @@ options.rules, = args else: parser.error("Wrong number of arguments.") + elif args: + parser.error("Wrong number of arguments.") if options.trace: logger.setLevel(logging.DEBUG) - if options.read_network: - access_control = AC_READ_NET - else: - access_control = AC_READ_FILE - - output_xslt = compile_theme(rules=options.rules, theme=options.theme, extra=options.extra, trace=options.trace, xinclude=options.xinclude, absolute_prefix=options.absolute_prefix, includemode=options.includemode, access_control=access_control) + output_xslt = compile_theme( + rules=options.rules, + theme=options.theme, + extra=options.extra, + trace=options.trace, + absolute_prefix=options.absolute_prefix, + includemode=options.includemode, + read_network=options.read_network, + ) output_xslt.write(options.output, encoding='utf-8', pretty_print=options.pretty_print) if __name__ == '__main__': Deleted: /z3/xdv/branches/multistage-compiler/lib/xdv/compiler.xsl ============================================================================== --- /z3/xdv/branches/multistage-compiler/lib/xdv/compiler.xsl Fri Jul 9 17:24:30 2010 +++ (empty file) @@ -1,613 +0,0 @@ - - - - - rules.xml - boilerplate.xsl - - - document - - - ;filter_xpath= - - - ;filter_xpath= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - initial-stage - Do nothing, skip these nodes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - esi - - - - - - - - - - - - r - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - xmlns - - - - - - - - - - - - - - - - - - - - - before - - - - - - - - after - - - - - - - - - - - - - - - - - - - - tag_text - - - - $tag_text - yes - - - - - - - - drop - - - - - - - - - - - - - - () - - or - - - - - - - - - - - - - - - - - - - - - - - - - - replace - - - - - - - - - ERROR: Multiple unconditional replace rules may not match a single theme node. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - prepend-copy-append - - - - - - - - - - - - - - - - - - - ERROR: Multiple unconditional copy rules may not match a single theme node. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: @content attribute and inline content not allowed in same rule - - - - - ERROR: @href attribute and inline content not allowed in same rule - - - - - - - - - - - - - - document('', .) - - - - - # include virtual=" - - - - " wait="yes" - - - - - - - - - - - - ERROR: Unknown includemode or @method attribute - - - - - - - - - - - - - tag_text - - - - $tag_text - yes - - - - - - - - - - - - - - - - TRACE: () - - RULE: < - =""/> - - - - - - - THEME: /[@id=''][] - - - - - Modified: z3/xdv/branches/multistage-compiler/lib/xdv/rules.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/rules.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/rules.py Fri Jul 9 17:24:30 2010 @@ -1,13 +1,12 @@ #!/usr/bin/env python """\ -Usage: %prog RULES +Usage: %prog [-r] RULES Preprocess RULES, an xdv rules file """ usage = __doc__ import logging -import pkg_resources import re from optparse import OptionParser @@ -15,7 +14,7 @@ from urlparse import urljoin from xdv.cssrules import convert_css_selectors -from xdv.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, CustomResolver, pkg_xsl +from xdv.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, pkg_xsl, _createOptionParser logger = logging.getLogger('xdv') @@ -29,7 +28,6 @@ annotate_themes = pkg_xsl('annotate-themes.xsl') annotate_rules = pkg_xsl('annotate-rules.xsl') apply_rules = pkg_xsl('apply-rules.xsl') -emit_stylesheet = pkg_xsl('emit-stylesheet.xsl') def update_namespace(rules_doc): """Convert old namespace to new namespace in place @@ -40,7 +38,7 @@ else: return rules_doc -def expand_themes(rules_doc, parser=None, absolute_prefix=None): +def expand_themes(rules_doc, parser=None, absolute_prefix=None, read_network=False): """Expand nodes with the theme html. """ if absolute_prefix is None: @@ -50,6 +48,9 @@ parser = etree.HTMLParser() for element in rules_doc.xpath('xdv:theme[@href]', namespaces=namespaces): url = urljoin(base, element.get('href')) + if '://' in url: + if not theme.startswith('file://'): + raise ValueError("Supplied theme '%s', but network access denied." % url) theme_doc = etree.parse(url, parser=parser) prefix = urljoin(absolute_prefix, element.get('prefix', '')) apply_absolute_prefix(theme_doc, prefix) @@ -69,7 +70,9 @@ node.set('href', url) for node in theme_doc.xpath('//comment() | //style'): if node.tag == 'style' or node.tag == etree.Comment and node.text.startswith("[if IE"): - node.text = IMPORT_STYLESHEET.sub(lambda match: match.group(1) + urljoin(absolute_prefix, match.group(2)) + match.group(3), node.text) + node.text = IMPORT_STYLESHEET.sub( + lambda match: match.group(1) + urljoin(absolute_prefix, match.group(2)) + match.group(3), + node.text) def add_extra(rules_doc, extra): root = rules_doc.getroot() @@ -77,7 +80,10 @@ root.extend(extra_elements) return rules_doc -def add_theme(rules_doc, theme, parser=None, absolute_prefix=None): +def add_theme(rules_doc, theme, parser=None, absolute_prefix=None, read_network=False): + if isinstance(theme, basestring) and '://' in theme: + if not theme.startswith('file://'): + raise ValueError("Supplied theme '%s', but network access denied." % theme) if absolute_prefix is None: absolute_prefix = '' if parser is None: @@ -91,19 +97,8 @@ root.append(element) return rules_doc -def set_parser(stylesheet, parser, compiler_parser=None): - dummy_doc = etree.parse(pkg_resources.resource_filename('xdv', 'dummy.html'), parser=parser) - name = 'file:///__xdv__' - resolver = CustomResolver({name: stylesheet}) - if compiler_parser is None: - compiler_parser = etree.XMLParser() - compiler_parser.resolvers.add(resolver) - identity = pkg_xsl('identity.xsl', compiler_parser) - output_doc = identity(dummy_doc, docurl="'%s'"%name) - compiler_parser.resolvers.remove(resolver) - return output_doc - -def process_rules(rules, theme=None, extra=None, trace=None, css=True, xinclude=True, absolute_prefix=None, includemode=None, update=True, parser=None, rules_parser=None, compiler_parser=None, access_control=None): +def process_rules(rules, theme=None, extra=None, trace=None, css=True, xinclude=True, absolute_prefix=None, + includemode=None, update=True, parser=None, rules_parser=None, read_network=False, stop=None): if trace: trace = '1' else: @@ -111,57 +106,72 @@ if rules_parser is None: rules_parser = etree.XMLParser(recover=False) rules_doc = etree.parse(rules, parser=rules_parser) + if stop == 0: return rules_doc if parser is None: parser = etree.HTMLParser() if xinclude: - rules_doc.xinclude() + rules_doc.xinclude() # XXX read_network limitation not yet supported for xinclude + if stop == 1: return rules_doc if update: rules_doc = update_namespace(rules_doc) + if stop == 2: return rules_doc if css: rules_doc = convert_css_selectors(rules_doc) - rules_doc = expand_themes(rules_doc, parser, absolute_prefix) + if stop == 3: return rules_doc + rules_doc = expand_themes(rules_doc, parser, absolute_prefix, read_network) if theme is not None: - rules_doc = add_theme(rules_doc, theme, parser, absolute_prefix) + rules_doc = add_theme(rules_doc, theme, parser, absolute_prefix, read_network) + if stop == 4: return rules_doc if includemode is None: includemode = 'document' includemode = "'%s'" % includemode rules_doc = normalize_rules(rules_doc, includemode=includemode) + if stop == 5: return rules_doc rules_doc = apply_conditions(rules_doc) + if stop == 6: return rules_doc rules_doc = merge_conditions(rules_doc) + if stop == 7: return rules_doc rules_doc = annotate_themes(rules_doc) + if stop == 8: return rules_doc rules_doc = annotate_rules(rules_doc) + if stop == 9: return rules_doc rules_doc = apply_rules(rules_doc, trace=trace) - compiled_doc = emit_stylesheet(rules_doc) - compiled_doc = set_parser(etree.tostring(compiled_doc), parser, compiler_parser) - return compiled_doc - + assert stop < 10, "There are only 10 steps" + return rules_doc def main(): """Called from console script """ - parser = OptionParser(usage=usage) - parser.add_option("-o", "--output", metavar="output.html", - help="Output filename (instead of stdout)", - dest="output", default=sys.stdout) - parser.add_option("-p", "--pretty-print", action="store_true", - help="Pretty print output", - dest="pretty_print", default=False) - parser.add_option("-a", "--absolute-prefix", metavar="/", - help="relative urls in the theme file will be made into absolute links with this prefix.", - dest="absolute_prefix", default=None) - parser.add_option("-i", "--includemode", metavar="INC", - help="include mode (document, ssi or esi)", - dest="includemode", default=None) - parser.add_option("-t", "--theme", metavar="theme.html", - help="Theme file", - dest="theme", default=None) + parser = _createOptionParser(usage=usage) + parser.add_option("-s", "--stop", metavar="n", type="int", + help="Stop preprocessing at stage n", + dest="stop", default=None) (options, args) = parser.parse_args() - if len(args) != 1: - parser.error("Invalid number of arguments") - rules = args[0] - rules_doc = process_rules(rules, theme=options.theme, absolute_prefix=options.absolute_prefix, includemode=options.includemode) + if options.rules is None: + if len(args) == 2 and options.theme is None: + options.rules, options.theme = args + elif len(args) == 1: + options.rules, = args + else: + parser.error("Wrong number of arguments.") + elif args: + parser.error("Wrong number of arguments.") + + if options.trace: + logger.setLevel(logging.DEBUG) + + rules_doc = process_rules( + options.rules, + theme=options.theme, + extra=options.extra, + trace=options.trace, + absolute_prefix=options.absolute_prefix, + includemode=options.includemode, + read_network=options.read_network, + stop=options.stop, + ) rules_doc.write(options.output, pretty_print=options.pretty_print) if __name__ == '__main__': Modified: z3/xdv/branches/multistage-compiler/lib/xdv/run.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/run.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/run.py Fri Jul 9 17:24:30 2010 @@ -1,20 +1,24 @@ #!/usr/bin/env python """\ -Usage: %prog TRANSFORM CONTENT +Usage: %prog -x TRANSFORM CONTENT TRANSFORM is the compiled theme transform CONTENT is an html file. -Usage: %prog -t THEME -r RULES [options] CONTENT +Usage: %prog -r RULES [options] CONTENT """ usage = __doc__ +import logging import sys import os.path + from lxml import etree -from optparse import OptionParser -from compiler import compile_theme -from utils import AC_READ_NET, AC_READ_FILE + +from xdv.compiler import compile_theme +from xdv.utils import AC_READ_NET, AC_READ_FILE, _createOptionParser + +logger = logging.getLogger('xdv') class RunResolver(etree.Resolver): def __init__(self, directory): @@ -29,65 +33,61 @@ def main(): """Called from console script """ - op = OptionParser(usage=usage) - op.add_option("-t", "--theme", metavar="theme.html", - help="Theme file", - dest="theme", default=None) - op.add_option("-r", "--rules", metavar="rules.xml", - help="XDV rules file", - dest="rules", default=None) - op.add_option("-e", "--extra", metavar="extra.xsl", - help="XDV extraurl XSLT file (depracated, use inline xsl in the rules instead)", - dest="extra", default=None) - op.add_option("-o", "--output", metavar="output.html", - help="Output filename (instead of stdout)", - dest="output", default=sys.stdout) - op.add_option("-p", "--pretty-print", action="store_true", - help="Pretty print output (can alter rendering on the browser)", - dest="pretty_print", default=False) - op.add_option("--xinclude", action="store_true", - help="Run XInclude on rules.xml (depracated, xinclude is always run)", - dest="xinclude", default=True) - op.add_option("-n", "--network", action="store_true", - help="Allow reads to the network to fetch resources", - dest="read_network", default=False) - op.add_option("-a", "--absolute-prefix", metavar="/", - help="relative urls in the theme file will be made into absolute links with this prefix.", - dest="absolute_prefix", default=None) - op.add_option("-i", "--includemode", metavar="INC", - help="include mode (document, ssi or esi)", - dest="includemode", default=None) + op = _createOptionParser(usage=usage) + op.add_option("-x", "--xsl", metavar="transform.xsl", + help="XSL transform", + dest="xsl", default=None) (options, args) = op.parse_args() - if options.read_network: - access_control = AC_READ_NET - else: - access_control = AC_READ_FILE - - if len(args) == 2: - transform_path, content = args - parser = etree.XMLParser() - output_xslt = etree.parse(transform_path, parser=parser) - elif len(args) == 1: - if options.rules: - content, = args - parser = etree.HTMLParser() - output_xslt = compile_theme(rules=options.rules, theme=options.theme, extra=options.extra, parser=parser, access_control=access_control, absolute_prefix=options.absolute_prefix, includemode=options.includemode) + if len(args) > 2: + op.error("Wrong number of arguments.") + elif len(args) == 2: + if options.xsl or options.rules: + op.error("Wrong number of arguments.") + path, content = args + if path.lower().endswith('.xsl'): + options.xsl = path else: - op.error("Rules must be supplied.") + options.rules = path + elif len(args) == 1: + content, = args else: op.error("Wrong number of arguments.") + if options.rules is None and options.xsl is None: + op.error("Must supply either options or rules") + + if options.trace: + logger.setLevel(logging.DEBUG) + + if options.xsl is not None: + output_xslt = etree.parse(options.xsl) + else: + parser = etree.HTMLParser() + output_xslt = compile_theme( + rules=options.rules, + theme=options.theme, + extra=options.extra, + parser=parser, + read_network=options.read_network, + absolute_prefix=options.absolute_prefix, + includemode=options.includemode, + ) if content == '-': content = sys.stdin + if options.read_network: + access_control = AC_READ_NET + else: + access_control = AC_READ_FILE + parser.resolvers.add(RunResolver(os.path.dirname(content))) transform = etree.XSLT(output_xslt, access_control=access_control) content_doc = etree.parse(content, parser=etree.HTMLParser()) output_html = transform(content_doc) output_html.write(options.output, encoding='UTF-8', pretty_print=options.pretty_print) for msg in transform.error_log: - print msg + logger.warn(msg) if __name__ == '__main__': main() Modified: z3/xdv/branches/multistage-compiler/lib/xdv/utils.py ============================================================================== --- z3/xdv/branches/multistage-compiler/lib/xdv/utils.py (original) +++ z3/xdv/branches/multistage-compiler/lib/xdv/utils.py Fri Jul 9 17:24:30 2010 @@ -1,6 +1,9 @@ -from lxml import etree import logging import pkg_resources +import sys + +from lxml import etree +from optparse import OptionParser logger=logging.getLogger('xdv') @@ -46,3 +49,35 @@ def pkg_xsl(name, parser=None): return LoggingXSLTWrapper(etree.XSLT(etree.parse(pkg_resources.resource_filename('xdv', name), parser=parser)), logger) + + +def _createOptionParser(usage): + parser = OptionParser(usage=usage) + parser.add_option("-o", "--output", metavar="output.xsl", + help="Output filename (instead of stdout)", + dest="output", default=sys.stdout) + parser.add_option("-p", "--pretty-print", action="store_true", + help="Pretty print output (may alter rendering in browser)", + dest="pretty_print", default=False) + parser.add_option("--trace", action="store_true", + help="Compiler trace logging", + dest="trace", default=False) + parser.add_option("-a", "--absolute-prefix", metavar="/", + help="relative urls in the theme file will be made into absolute links with this prefix.", + dest="absolute_prefix", default=None) + parser.add_option("-i", "--includemode", metavar="INC", + help="include mode (document, ssi or esi)", + dest="includemode", default=None) + parser.add_option("-n", "--network", action="store_true", + help="Allow reads to the network to fetch resources", + dest="read_network", default=False) + parser.add_option("-t", "--theme", metavar="theme.html", + help="Theme file", + dest="theme", default=None) + parser.add_option("-r", "--rules", metavar="rules.xml", + help="XDV rules file", + dest="rules", default=None) + parser.add_option("-e", "--extra", metavar="extra.xsl", + help="Extra XSL to be included in the transform (depracated, use inline xsl in the rules instead)", + dest="extra", default=None) + return parser Modified: z3/xdv/branches/multistage-compiler/setup.py ============================================================================== --- z3/xdv/branches/multistage-compiler/setup.py (original) +++ z3/xdv/branches/multistage-compiler/setup.py Fri Jul 9 17:24:30 2010 @@ -26,5 +26,6 @@ [console_scripts] xdvcompiler = xdv.compiler:main xdvrun = xdv.run:main + xdvpreprocessor = xdv.rules:main """, ) From ldr at codespeak.net Fri Jul 9 17:28:14 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Fri, 9 Jul 2010 17:28:14 +0200 (CEST) Subject: [z3-checkins] r76080 - in z3/xdv/trunk: . docs lib/xdv lib/xdv/tests lib/xdv/tests/absolute-prefix lib/xdv/tests/absolute-prefix-disabled lib/xdv/tests/drop-content lib/xdv/tests/esi lib/xdv/tests/html-xml-lang lib/xdv/tests/html-xml-lang-2 lib/xdv/tests/modify-theme lib/xdv/tests/multi-theme-1 lib/xdv/tests/multi-theme-2 lib/xdv/tests/nested-conditions-1 lib/xdv/tests/nested-conditions-2 lib/xdv/tests/nested-conditions-3 lib/xdv/tests/ssi Message-ID: <20100709152814.126D2282C07@codespeak.net> Author: ldr Date: Fri Jul 9 17:28:12 2010 New Revision: 76080 Added: z3/xdv/trunk/lib/xdv/annotate-rules.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/annotate-rules.xsl z3/xdv/trunk/lib/xdv/annotate-themes.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/annotate-themes.xsl z3/xdv/trunk/lib/xdv/apply-conditions.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/apply-conditions.xsl z3/xdv/trunk/lib/xdv/apply-rules.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/apply-rules.xsl z3/xdv/trunk/lib/xdv/defaults.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/defaults.xsl z3/xdv/trunk/lib/xdv/dummy.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/dummy.html z3/xdv/trunk/lib/xdv/emit-stylesheet.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/emit-stylesheet.xsl z3/xdv/trunk/lib/xdv/identity.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/identity.xsl z3/xdv/trunk/lib/xdv/merge-conditions.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/merge-conditions.xsl z3/xdv/trunk/lib/xdv/normalize-rules.xsl - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/normalize-rules.xsl z3/xdv/trunk/lib/xdv/rules.py - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/rules.py z3/xdv/trunk/lib/xdv/tests/absolute-prefix/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/ z3/xdv/trunk/lib/xdv/tests/absolute-prefix-disabled/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/ z3/xdv/trunk/lib/xdv/tests/absolute-prefix-disabled/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/content.html z3/xdv/trunk/lib/xdv/tests/absolute-prefix-disabled/options.cfg - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/options.cfg z3/xdv/trunk/lib/xdv/tests/absolute-prefix-disabled/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/output.html z3/xdv/trunk/lib/xdv/tests/absolute-prefix-disabled/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/rules.xml z3/xdv/trunk/lib/xdv/tests/absolute-prefix-disabled/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix-disabled/theme.html z3/xdv/trunk/lib/xdv/tests/absolute-prefix/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/content.html z3/xdv/trunk/lib/xdv/tests/absolute-prefix/options.cfg - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/options.cfg z3/xdv/trunk/lib/xdv/tests/absolute-prefix/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/output.html z3/xdv/trunk/lib/xdv/tests/absolute-prefix/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/rules.xml z3/xdv/trunk/lib/xdv/tests/absolute-prefix/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/absolute-prefix/theme.html z3/xdv/trunk/lib/xdv/tests/default-options.cfg - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/default-options.cfg z3/xdv/trunk/lib/xdv/tests/drop-content/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/ z3/xdv/trunk/lib/xdv/tests/drop-content/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/content.html z3/xdv/trunk/lib/xdv/tests/drop-content/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/output.html z3/xdv/trunk/lib/xdv/tests/drop-content/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/rules.xml z3/xdv/trunk/lib/xdv/tests/drop-content/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/drop-content/theme.html z3/xdv/trunk/lib/xdv/tests/html-xml-lang/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/ z3/xdv/trunk/lib/xdv/tests/html-xml-lang-2/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/ z3/xdv/trunk/lib/xdv/tests/html-xml-lang-2/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/content.html z3/xdv/trunk/lib/xdv/tests/html-xml-lang-2/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/output.html z3/xdv/trunk/lib/xdv/tests/html-xml-lang-2/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/rules.xml z3/xdv/trunk/lib/xdv/tests/html-xml-lang-2/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang-2/theme.html z3/xdv/trunk/lib/xdv/tests/html-xml-lang/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/content.html z3/xdv/trunk/lib/xdv/tests/html-xml-lang/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/output.html z3/xdv/trunk/lib/xdv/tests/html-xml-lang/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/rules.xml z3/xdv/trunk/lib/xdv/tests/html-xml-lang/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/html-xml-lang/theme.html z3/xdv/trunk/lib/xdv/tests/multi-theme-1/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/ z3/xdv/trunk/lib/xdv/tests/multi-theme-1/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/content.html z3/xdv/trunk/lib/xdv/tests/multi-theme-1/options.cfg - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/options.cfg z3/xdv/trunk/lib/xdv/tests/multi-theme-1/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/output.html z3/xdv/trunk/lib/xdv/tests/multi-theme-1/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/rules.xml z3/xdv/trunk/lib/xdv/tests/multi-theme-1/theme1.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme1.html z3/xdv/trunk/lib/xdv/tests/multi-theme-1/theme2.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-1/theme2.html z3/xdv/trunk/lib/xdv/tests/multi-theme-2/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/ z3/xdv/trunk/lib/xdv/tests/multi-theme-2/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/content.html z3/xdv/trunk/lib/xdv/tests/multi-theme-2/options.cfg - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/options.cfg z3/xdv/trunk/lib/xdv/tests/multi-theme-2/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/output.html z3/xdv/trunk/lib/xdv/tests/multi-theme-2/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/rules.xml z3/xdv/trunk/lib/xdv/tests/multi-theme-2/theme1.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme1.html z3/xdv/trunk/lib/xdv/tests/multi-theme-2/theme2.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/multi-theme-2/theme2.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-1/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-1/ z3/xdv/trunk/lib/xdv/tests/nested-conditions-1/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-1/content.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-1/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-1/output.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-1/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-1/rules.xml z3/xdv/trunk/lib/xdv/tests/nested-conditions-1/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-1/theme.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-2/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-2/ z3/xdv/trunk/lib/xdv/tests/nested-conditions-2/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-2/content.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-2/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-2/output.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-2/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-2/rules.xml z3/xdv/trunk/lib/xdv/tests/nested-conditions-2/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-2/theme.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-3/ - copied from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-3/ z3/xdv/trunk/lib/xdv/tests/nested-conditions-3/content.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-3/content.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-3/output.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-3/output.html z3/xdv/trunk/lib/xdv/tests/nested-conditions-3/rules.xml - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-3/rules.xml z3/xdv/trunk/lib/xdv/tests/nested-conditions-3/theme.html - copied unchanged from r76079, z3/xdv/branches/multistage-compiler/lib/xdv/tests/nested-conditions-3/theme.html Removed: z3/xdv/trunk/lib/xdv/boilerplate.xsl z3/xdv/trunk/lib/xdv/compiler.xsl z3/xdv/trunk/lib/xdv/tests/absolute_rules.xml z3/xdv/trunk/lib/xdv/tests/absolute_theme.html Modified: z3/xdv/trunk/ (props changed) z3/xdv/trunk/buildout.cfg z3/xdv/trunk/docs/TODO.txt z3/xdv/trunk/lib/xdv/compiler.py z3/xdv/trunk/lib/xdv/cssrules.py z3/xdv/trunk/lib/xdv/run.py z3/xdv/trunk/lib/xdv/tests/esi/output.html z3/xdv/trunk/lib/xdv/tests/modify-theme/rules.xml z3/xdv/trunk/lib/xdv/tests/ssi/output.html z3/xdv/trunk/lib/xdv/tests/tests.py z3/xdv/trunk/lib/xdv/utils.py z3/xdv/trunk/setup.py Log: merge the multistage-compiler branch back to trunk Modified: z3/xdv/trunk/buildout.cfg ============================================================================== --- z3/xdv/trunk/buildout.cfg (original) +++ z3/xdv/trunk/buildout.cfg Fri Jul 9 17:28:12 2010 @@ -12,3 +12,4 @@ [test] recipe = zc.recipe.testrunner eggs = xdv +defaults = ['--auto-color'] Modified: z3/xdv/trunk/docs/TODO.txt ============================================================================== --- z3/xdv/trunk/docs/TODO.txt (original) +++ z3/xdv/trunk/docs/TODO.txt Fri Jul 9 17:28:12 2010 @@ -39,6 +39,16 @@ 0.4 release =========== +Refactor compiler +----------------- + +Move to a pipeline. Running compiler.xsl in Apache did not work out in +practise. + +# css -> xpath +# rules.xml + themes merged together +# annotate +# compile theme Group directive --------------- Deleted: /z3/xdv/trunk/lib/xdv/boilerplate.xsl ============================================================================== --- /z3/xdv/trunk/lib/xdv/boilerplate.xsl Fri Jul 9 17:28:12 2010 +++ (empty file) @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: z3/xdv/trunk/lib/xdv/compiler.py ============================================================================== --- z3/xdv/trunk/lib/xdv/compiler.py (original) +++ z3/xdv/trunk/lib/xdv/compiler.py Fri Jul 9 17:28:12 2010 @@ -11,79 +11,32 @@ """ usage = __doc__ -import re -import os.path -import sys import logging +import pkg_resources +import sys + from lxml import etree -from optparse import OptionParser -from utils import namespaces, AC_READ_NET, AC_READ_FILE -from cssrules import convert_css_selectors +from xdv.rules import process_rules +from xdv.utils import namespaces, AC_READ_NET, AC_READ_FILE, pkg_xsl, _createOptionParser, CustomResolver logger = logging.getLogger('xdv') -HERE = os.path.dirname(__file__) - -IMPORT_STYLESHEET = re.compile(r'''(@import\s+(?:url\(['"]?|['"]))(.+)(['"]?\)|['"])''', re.IGNORECASE) - -COMPILER_PATH = os.path.join(HERE, 'compiler.xsl') - -UPDATE_PATH = os.path.join(HERE, 'update-namespace.xsl') -update_transform = etree.XSLT(etree.parse(UPDATE_PATH)) +emit_stylesheet = pkg_xsl('emit-stylesheet.xsl') -def update_namespace(rules): - """Convert old namespace to new namespace in place - """ - if rules.xpath("//*[namespace-uri()='%s']" % namespaces['old']): - logger.warning('The %s namespace is deprecated, use %s instead.' % (namespaces['old'], namespaces['xdv'])) - return update_transform(rules) - else: - return rules - -class CompileResolver(etree.Resolver): - def __init__(self, rules, extra=None): - self.rules = rules - self.extra = extra - - def resolve(self, url, pubid, context): - if url == 'file:///__xdv__rules': - return self.resolve_string(self.rules, context) - if url == 'file:///__xdv__extra' and self.extra is not None: - return self.resolve_string(self.extra, context) - -def to_absolute(path, prefix): - """Make a url/path into an absolute URL by applying the given prefix - """ - # Absolute path or full url - if path.startswith('/') or '://' in path: - return path - - absolute = "%s/%s" % (prefix, path) - if '://' in absolute: - return absolute - - normalized = os.path.normpath(absolute) - if os.path.sep != '/': - normalized = normalized.replace(os.path.sep, '/') - return normalized - -def apply_absolute_prefix(theme_doc, absolute_prefix): - if absolute_prefix.endswith('/'): - absolute_prefix = absolute_prefix[:-1] - for node in theme_doc.xpath('*//style | *//script | *//img | *//link | *//input | *//comment() '): - if node.tag in ('img', 'script', 'input',): - src = node.get('src') - if src: - node.set('src', to_absolute(src, absolute_prefix)) - elif node.tag == 'link': - href = node.get('href') - if href: - node.set('href', to_absolute(href, absolute_prefix)) - elif node.tag == 'style' or node.tag == etree.Comment and node.text.startswith("[if IE"): - node.text = IMPORT_STYLESHEET.sub(lambda match: match.group(1) + to_absolute(match.group(2), absolute_prefix) + match.group(3), node.text) +def set_parser(stylesheet, parser, compiler_parser=None): + dummy_doc = etree.parse(pkg_resources.resource_filename('xdv', 'dummy.html'), parser=parser) + name = 'file:///__xdv__' + resolver = CustomResolver({name: stylesheet}) + if compiler_parser is None: + compiler_parser = etree.XMLParser() + compiler_parser.resolvers.add(resolver) + identity = pkg_xsl('identity.xsl', compiler_parser) + output_doc = identity(dummy_doc, docurl="'%s'"%name) + compiler_parser.resolvers.remove(resolver) + return output_doc -def compile_theme(rules, theme, extra=None, css=True, xinclude=True, absolute_prefix=None, update=True, trace=False, includemode=None, parser=None, compiler_parser=None, rules_parser=None, access_control=None): +def compile_theme(rules, theme=None, extra=None, css=True, xinclude=True, absolute_prefix=None, update=True, trace=False, includemode=None, parser=None, compiler_parser=None, rules_parser=None, access_control=None, read_network=False): """Invoke the xdv compiler. * ``rules`` is the rules file @@ -112,103 +65,57 @@ * ``compiler_parser``` can be set to an lxml parser instance; the default is a XMLParser * ``rules_parser`` can be set to an lxml parser instance; the default is a - XMLParse. + XMLParser. """ - - if rules_parser is None: - rules_parser = etree.XMLParser(recover=False) - rules_doc = etree.parse(rules, parser=rules_parser) - - if xinclude: - rules_doc.xinclude() - if update: - rules_doc = update_namespace(rules_doc) - if css: - convert_css_selectors(rules_doc) - - if parser is None: - parser = etree.HTMLParser() - theme_doc = etree.parse(theme, parser=parser) - - if absolute_prefix: - apply_absolute_prefix(theme_doc, absolute_prefix) - - if compiler_parser is None: - compiler_parser = etree.XMLParser() - if access_control is None: - access_control = AC_READ_FILE - compiler_transform = etree.XSLT(etree.parse(COMPILER_PATH, parser=compiler_parser), access_control=access_control) - - params = dict(rulesuri="'file:///__xdv__rules'") - if extra: - params['extraurl'] = "'file:///__xdv__extra'" - resolver = CompileResolver(etree.tostring(rules_doc), etree.tostring(etree.parse(extra))) - else: - resolver = CompileResolver(etree.tostring(rules_doc)) - if trace: - params['trace'] = '1' - if includemode: - params['includemode'] = "'%s'" % includemode + if access_control is not None: + read_network = access_control.options['read_network'] + rules_doc = process_rules( + rules=rules, + theme=theme, + extra=extra, + css=css, + xinclude=xinclude, + absolute_prefix=absolute_prefix, + update=update, + trace=trace, + includemode=includemode, + parser=parser, + rules_parser=rules_parser, + read_network=read_network, + ) + compiled_doc = emit_stylesheet(rules_doc) + compiled_doc = set_parser(etree.tostring(compiled_doc), parser, compiler_parser) + return compiled_doc - compiler_parser.resolvers.add(resolver) - compiled = compiler_transform(theme_doc, **params) - for msg in compiler_transform.error_log: - logger.info(msg) - return compiled def main(): """Called from console script """ - parser = OptionParser(usage=usage) - parser.add_option("-o", "--output", metavar="output.xsl", - help="Output filename (instead of stdout)", - dest="output", default=sys.stdout) - parser.add_option("-p", "--pretty-print", action="store_true", - help="Pretty print output (may alter rendering in browser)", - dest="pretty_print", default=False) - parser.add_option("--trace", action="store_true", - help="Compiler trace logging", - dest="trace", default=False) - parser.add_option("--xinclude", action="store_true", - help="Run XInclude on rules.xml (depracated, xinclude is always run)", - dest="xinclude", default=True) - parser.add_option("-a", "--absolute-prefix", metavar="/", - help="relative urls in the theme file will be made into absolute links with this prefix.", - dest="absolute_prefix", default=None) - parser.add_option("-i", "--includemode", metavar="INC", - help="include mode (document, ssi or esi)", - dest="includemode", default=None) - parser.add_option("-n", "--network", action="store_true", - help="Allow reads to the network to fetch resources", - dest="read_network", default=False) - parser.add_option("-t", "--theme", metavar="theme.html", - help="Theme file", - dest="theme", default=None) - parser.add_option("-r", "--rules", metavar="rules.xml", - help="XDV rules file", - dest="rules", default=None) - parser.add_option("-e", "--extra", metavar="extra.xsl", - help="Extra XSL to be included in the transform (depracated, use inline xsl in the rules instead)", - dest="extra", default=None) + parser = _createOptionParser(usage=usage) (options, args) = parser.parse_args() - if options.rules is None and options.theme is None: - if len(args) == 2: + if options.rules is None: + if len(args) == 2 and options.theme is None: options.rules, options.theme = args + elif len(args) == 1: + options.rules, = args else: parser.error("Wrong number of arguments.") - elif not(options.rules is not None and options.theme is not None): - parser.error("Both theme and rules must be supplied as options or as arguments.") + elif args: + parser.error("Wrong number of arguments.") if options.trace: logger.setLevel(logging.DEBUG) - if options.read_network: - access_control = AC_READ_NET - else: - access_control = AC_READ_FILE - - output_xslt = compile_theme(rules=options.rules, theme=options.theme, extra=options.extra, trace=options.trace, xinclude=options.xinclude, absolute_prefix=options.absolute_prefix, includemode=options.includemode, access_control=access_control) + output_xslt = compile_theme( + rules=options.rules, + theme=options.theme, + extra=options.extra, + trace=options.trace, + absolute_prefix=options.absolute_prefix, + includemode=options.includemode, + read_network=options.read_network, + ) output_xslt.write(options.output, encoding='utf-8', pretty_print=options.pretty_print) if __name__ == '__main__': Deleted: /z3/xdv/trunk/lib/xdv/compiler.xsl ============================================================================== --- /z3/xdv/trunk/lib/xdv/compiler.xsl Fri Jul 9 17:28:12 2010 +++ (empty file) @@ -1,613 +0,0 @@ - - - - - rules.xml - boilerplate.xsl - - - document - - - ;filter_xpath= - - - ;filter_xpath= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - initial-stage - Do nothing, skip these nodes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - esi - - - - - - - - - - - - r - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - xmlns - - - - - - - - - - - - - - - - - - - - - before - - - - - - - - after - - - - - - - - - - - - - - - - - - - - tag_text - - - - $tag_text - yes - - - - - - - - drop - - - - - - - - - - - - - - () - - or - - - - - - - - - - - - - - - - - - - - - - - - - - replace - - - - - - - - - ERROR: Multiple unconditional replace rules may not match a single theme node. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - prepend-copy-append - - - - - - - - - - - - - - - - - - - ERROR: Multiple unconditional copy rules may not match a single theme node. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: @content attribute and inline content not allowed in same rule - - - - - ERROR: @href attribute and inline content not allowed in same rule - - - - - - - - - - - - - - document('', .) - - - - - # include virtual=" - - - - " wait="yes" - - - - - - - - - - - - ERROR: Unknown includemode or @method attribute - - - - - - - - - - - - - tag_text - - - - $tag_text - yes - - - - - - - - - - - - - - - - TRACE: () - - RULE: < - =""/> - - - - - - - THEME: /[@id=''][] - - - - - Modified: z3/xdv/trunk/lib/xdv/cssrules.py ============================================================================== --- z3/xdv/trunk/lib/xdv/cssrules.py (original) +++ z3/xdv/trunk/lib/xdv/cssrules.py Fri Jul 9 17:28:12 2010 @@ -20,7 +20,7 @@ import logging logger = logging.getLogger('xdv') -def convert_css_selectors(rules, prefix='//'): +def convert_css_selectors(rules): """Convert css rules to xpath rules element tree in place """ #XXX: There is a :root pseudo-class - http://www.w3.org/TR/css3-selectors/#root-pseudo @@ -28,10 +28,17 @@ for element in rules.xpath("//@*[namespace-uri()='%s']/.." % utils.namespaces['css']): for name, value in element.attrib.items(): if name.startswith('{%s}' % utils.namespaces['css']): - if value: - element.attrib[utils.localname(name)] = css_to_xpath(value, prefix=prefix) + localname = utils.localname(name) + if not value: + element.attrib[localname] = "" + continue + if localname == 'content' and element.tag == '{%s}drop' % utils.namespaces['xdv']: + prefix = '//' else: - element.attrib[utils.fullname(element.nsmap[element.prefix], utils.localname(name))] = "" + prefix = 'descendant-or-self::' + element.attrib[localname] = css_to_xpath(value, prefix=prefix) + + return rules def main(): """Called from console script Modified: z3/xdv/trunk/lib/xdv/run.py ============================================================================== --- z3/xdv/trunk/lib/xdv/run.py (original) +++ z3/xdv/trunk/lib/xdv/run.py Fri Jul 9 17:28:12 2010 @@ -1,20 +1,24 @@ #!/usr/bin/env python """\ -Usage: %prog TRANSFORM CONTENT +Usage: %prog -x TRANSFORM CONTENT TRANSFORM is the compiled theme transform CONTENT is an html file. -Usage: %prog -t THEME -r RULES [options] CONTENT +Usage: %prog -r RULES [options] CONTENT """ usage = __doc__ +import logging import sys import os.path + from lxml import etree -from optparse import OptionParser -from compiler import compile_theme -from utils import AC_READ_NET, AC_READ_FILE + +from xdv.compiler import compile_theme +from xdv.utils import AC_READ_NET, AC_READ_FILE, _createOptionParser + +logger = logging.getLogger('xdv') class RunResolver(etree.Resolver): def __init__(self, directory): @@ -29,59 +33,61 @@ def main(): """Called from console script """ - op = OptionParser(usage=usage) - op.add_option("-t", "--theme", metavar="theme.html", - help="Theme file", - dest="theme", default=None) - op.add_option("-r", "--rules", metavar="rules.xml", - help="XDV rules file", - dest="rules", default=None) - op.add_option("-e", "--extra", metavar="extra.xsl", - help="XDV extraurl XSLT file (depracated, use inline xsl in the rules instead)", - dest="extra", default=None) - op.add_option("-o", "--output", metavar="output.html", - help="Output filename (instead of stdout)", - dest="output", default=sys.stdout) - op.add_option("-p", "--pretty-print", action="store_true", - help="Pretty print output (can alter rendering on the browser)", - dest="pretty_print", default=False) - op.add_option("--xinclude", action="store_true", - help="Run XInclude on rules.xml (depracated, xinclude is always run)", - dest="xinclude", default=True) - op.add_option("-n", "--network", action="store_true", - help="Allow reads to the network to fetch resources", - dest="read_network", default=False) + op = _createOptionParser(usage=usage) + op.add_option("-x", "--xsl", metavar="transform.xsl", + help="XSL transform", + dest="xsl", default=None) (options, args) = op.parse_args() - if options.read_network: - access_control = AC_READ_NET - else: - access_control = AC_READ_FILE - - if len(args) == 2: - transform_path, content = args - parser = etree.XMLParser() - output_xslt = etree.parse(transform_path, parser=parser) - elif len(args) == 1: - if options.theme and options.rules: - content, = args - parser = etree.HTMLParser() - output_xslt = compile_theme(rules=options.rules, theme=options.theme, extra=options.extra, parser=parser, access_control=access_control) + if len(args) > 2: + op.error("Wrong number of arguments.") + elif len(args) == 2: + if options.xsl or options.rules: + op.error("Wrong number of arguments.") + path, content = args + if path.lower().endswith('.xsl'): + options.xsl = path else: - op.error("Theme and rules must be supplied.") + options.rules = path + elif len(args) == 1: + content, = args else: op.error("Wrong number of arguments.") + if options.rules is None and options.xsl is None: + op.error("Must supply either options or rules") + + if options.trace: + logger.setLevel(logging.DEBUG) + + if options.xsl is not None: + output_xslt = etree.parse(options.xsl) + else: + parser = etree.HTMLParser() + output_xslt = compile_theme( + rules=options.rules, + theme=options.theme, + extra=options.extra, + parser=parser, + read_network=options.read_network, + absolute_prefix=options.absolute_prefix, + includemode=options.includemode, + ) if content == '-': content = sys.stdin + if options.read_network: + access_control = AC_READ_NET + else: + access_control = AC_READ_FILE + parser.resolvers.add(RunResolver(os.path.dirname(content))) transform = etree.XSLT(output_xslt, access_control=access_control) content_doc = etree.parse(content, parser=etree.HTMLParser()) output_html = transform(content_doc) output_html.write(options.output, encoding='UTF-8', pretty_print=options.pretty_print) for msg in transform.error_log: - print msg + logger.warn(msg) if __name__ == '__main__': main() Deleted: /z3/xdv/trunk/lib/xdv/tests/absolute_rules.xml ============================================================================== --- /z3/xdv/trunk/lib/xdv/tests/absolute_rules.xml Fri Jul 9 17:28:12 2010 +++ (empty file) @@ -1,4 +0,0 @@ - - - - Deleted: /z3/xdv/trunk/lib/xdv/tests/absolute_theme.html ============================================================================== --- /z3/xdv/trunk/lib/xdv/tests/absolute_theme.html Fri Jul 9 17:28:12 2010 +++ (empty file) @@ -1,44 +0,0 @@ - - - - Absolute prefix - - - - - - - - - - + + + Added: z3/xdv/trunk/lib/xdv/tests/style-script-quoting-2/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/style-script-quoting-2/output.html Wed Sep 8 15:04:54 2010 @@ -0,0 +1,30 @@ + + + + + Theme Title + + + + + + +

Title

+ + Added: z3/xdv/trunk/lib/xdv/tests/style-script-quoting-2/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/style-script-quoting-2/rules.xml Wed Sep 8 15:04:54 2010 @@ -0,0 +1,5 @@ + + + + + Added: z3/xdv/trunk/lib/xdv/tests/style-script-quoting-2/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/style-script-quoting-2/theme.html Wed Sep 8 15:04:54 2010 @@ -0,0 +1,19 @@ + + + + Theme Title + + + + +

Title

+ + From ldr at codespeak.net Wed Sep 8 17:08:36 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 8 Sep 2010 17:08:36 +0200 (CEST) Subject: [z3-checkins] r76948 - in z3/xdv/trunk: docs lib/xdv lib/xdv/tests Message-ID: <20100908150836.7A244282BD6@codespeak.net> Author: ldr Date: Wed Sep 8 17:08:35 2010 New Revision: 76948 Modified: z3/xdv/trunk/docs/CHANGES.txt z3/xdv/trunk/lib/xdv/compiler.py z3/xdv/trunk/lib/xdv/emit-stylesheet.xsl z3/xdv/trunk/lib/xdv/run.py z3/xdv/trunk/lib/xdv/tests/tests.py Log: Serialize using XSLT method from xdvrun. Modified: z3/xdv/trunk/docs/CHANGES.txt ============================================================================== --- z3/xdv/trunk/docs/CHANGES.txt (original) +++ z3/xdv/trunk/docs/CHANGES.txt Wed Sep 8 17:08:35 2010 @@ -4,6 +4,8 @@ 0.4b3 - unreleased ------------------ +* Serialize using XSLT method from xdvrun. + * Fix for default theme. * Fix for themes in nested rules tags. Modified: z3/xdv/trunk/lib/xdv/compiler.py ============================================================================== --- z3/xdv/trunk/lib/xdv/compiler.py (original) +++ z3/xdv/trunk/lib/xdv/compiler.py Wed Sep 8 17:08:35 2010 @@ -36,7 +36,7 @@ compiler_parser.resolvers.remove(resolver) return output_doc -def compile_theme(rules, theme=None, extra=None, css=True, xinclude=True, absolute_prefix=None, update=True, trace=False, includemode=None, parser=None, compiler_parser=None, rules_parser=None, access_control=None, read_network=False): +def compile_theme(rules, theme=None, extra=None, css=True, xinclude=True, absolute_prefix=None, update=True, trace=False, includemode=None, parser=None, compiler_parser=None, rules_parser=None, access_control=None, read_network=False, indent=None): """Invoke the xdv compiler. * ``rules`` is the rules file @@ -83,7 +83,10 @@ rules_parser=rules_parser, read_network=read_network, ) - compiled_doc = emit_stylesheet(rules_doc) + params = {} + if indent is not None: + params['indent'] = indent and "'yes'" or "'no'" + compiled_doc = emit_stylesheet(rules_doc, **params) compiled_doc = set_parser(etree.tostring(compiled_doc), parser, compiler_parser) return compiled_doc Modified: z3/xdv/trunk/lib/xdv/emit-stylesheet.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/emit-stylesheet.xsl (original) +++ z3/xdv/trunk/lib/xdv/emit-stylesheet.xsl Wed Sep 8 17:08:35 2010 @@ -13,6 +13,7 @@ defaults.xsl + @@ -31,6 +32,17 @@
+ + + + + + + + + + + Modified: z3/xdv/trunk/lib/xdv/run.py ============================================================================== --- z3/xdv/trunk/lib/xdv/run.py (original) +++ z3/xdv/trunk/lib/xdv/run.py Wed Sep 8 17:08:35 2010 @@ -76,6 +76,7 @@ read_network=options.read_network, absolute_prefix=options.absolute_prefix, includemode=options.includemode, + indent=options.pretty_print, ) if content == '-': @@ -89,7 +90,11 @@ transform = etree.XSLT(output_xslt, access_control=access_control) content_doc = etree.parse(content, parser=parser) output_html = transform(content_doc) - output_html.write(options.output, encoding='UTF-8', pretty_print=options.pretty_print) + if isinstance(options.output, basestring): + out = open(options.output, 'wt') + else: + out = options.output + out.write(str(output_html)) for msg in transform.error_log: logger.warn(msg) Modified: z3/xdv/trunk/lib/xdv/tests/tests.py ============================================================================== --- z3/xdv/trunk/lib/xdv/tests/tests.py (original) +++ z3/xdv/trunk/lib/xdv/tests/tests.py Wed Sep 8 17:08:35 2010 @@ -53,7 +53,7 @@ theme=themefn, parser=theme_parser, absolute_prefix=config.get('xdvtest', 'absolute-prefix'), - includemode=config.get('xdvtest', 'includemode'), + indent=config.getboolean('xdvtest', 'pretty-print') ) # Serialize / parse the theme - this can catch problems with escaping. @@ -84,7 +84,7 @@ # Read the whole thing to strip off xhtml namespace. # If we had xslt 2.0 then we could use xpath-default-namespace. - self.themed_string = etree.tostring(result, encoding="UTF-8", pretty_print=config.getboolean('xdvtest', 'pretty-print')) + self.themed_string = str(result) self.themed_content = etree.ElementTree(file=StringIO(self.themed_string), parser=etree.HTMLParser()) From ldr at codespeak.net Wed Sep 8 17:55:42 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 8 Sep 2010 17:55:42 +0200 (CEST) Subject: [z3-checkins] r76949 - in z3/xdv/trunk: docs lib/xdv lib/xdv/tests lib/xdv/tests/path-param-1 lib/xdv/tests/path-param-2 Message-ID: <20100908155542.E5193282BD6@codespeak.net> Author: ldr Date: Wed Sep 8 17:55:40 2010 New Revision: 76949 Added: z3/xdv/trunk/lib/xdv/tests/path-param-1/ z3/xdv/trunk/lib/xdv/tests/path-param-1/content.html z3/xdv/trunk/lib/xdv/tests/path-param-1/options.cfg z3/xdv/trunk/lib/xdv/tests/path-param-1/output.html z3/xdv/trunk/lib/xdv/tests/path-param-1/rules.xml z3/xdv/trunk/lib/xdv/tests/path-param-1/theme.html z3/xdv/trunk/lib/xdv/tests/path-param-2/ z3/xdv/trunk/lib/xdv/tests/path-param-2/content.html z3/xdv/trunk/lib/xdv/tests/path-param-2/options.cfg z3/xdv/trunk/lib/xdv/tests/path-param-2/output.html z3/xdv/trunk/lib/xdv/tests/path-param-2/rules.xml z3/xdv/trunk/lib/xdv/tests/path-param-2/theme.html Modified: z3/xdv/trunk/docs/CHANGES.txt z3/xdv/trunk/lib/xdv/defaults.xsl z3/xdv/trunk/lib/xdv/run.py z3/xdv/trunk/lib/xdv/tests/default-options.cfg z3/xdv/trunk/lib/xdv/tests/tests.py Log: path parameter Modified: z3/xdv/trunk/docs/CHANGES.txt ============================================================================== --- z3/xdv/trunk/docs/CHANGES.txt (original) +++ z3/xdv/trunk/docs/CHANGES.txt Wed Sep 8 17:55:40 2010 @@ -4,6 +4,8 @@ 0.4b3 - unreleased ------------------ +* $path parameter. + * Serialize using XSLT method from xdvrun. * Fix for default theme. Modified: z3/xdv/trunk/lib/xdv/defaults.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/defaults.xsl (original) +++ z3/xdv/trunk/lib/xdv/defaults.xsl Wed Sep 8 17:55:40 2010 @@ -10,6 +10,8 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl str css dv dyn xhtml"> + + 2: @@ -89,7 +92,10 @@ transform = etree.XSLT(output_xslt, access_control=access_control) content_doc = etree.parse(content, parser=parser) - output_html = transform(content_doc) + params = {} + if options.path is not None: + params['path'] = "'%s'" % options.path + output_html = transform(content_doc, **params) if isinstance(options.output, basestring): out = open(options.output, 'wt') else: Modified: z3/xdv/trunk/lib/xdv/tests/default-options.cfg ============================================================================== --- z3/xdv/trunk/lib/xdv/tests/default-options.cfg (original) +++ z3/xdv/trunk/lib/xdv/tests/default-options.cfg Wed Sep 8 17:55:40 2010 @@ -3,3 +3,4 @@ absolute-prefix = includemode = document theme = theme.html +path = Added: z3/xdv/trunk/lib/xdv/tests/path-param-1/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-1/content.html Wed Sep 8 17:55:40 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/path-param-1/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-1/options.cfg Wed Sep 8 17:55:40 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /somewhere Added: z3/xdv/trunk/lib/xdv/tests/path-param-1/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-1/output.html Wed Sep 8 17:55:40 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/path-param-1/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-1/rules.xml Wed Sep 8 17:55:40 2010 @@ -0,0 +1,10 @@ + + + Added: z3/xdv/trunk/lib/xdv/tests/path-param-1/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-1/theme.html Wed Sep 8 17:55:40 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/path-param-2/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-2/content.html Wed Sep 8 17:55:40 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/path-param-2/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-2/options.cfg Wed Sep 8 17:55:40 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /elsewhere Added: z3/xdv/trunk/lib/xdv/tests/path-param-2/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-2/output.html Wed Sep 8 17:55:40 2010 @@ -0,0 +1,7 @@ + + + +

Title

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/path-param-2/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-2/rules.xml Wed Sep 8 17:55:40 2010 @@ -0,0 +1,10 @@ + + + Added: z3/xdv/trunk/lib/xdv/tests/path-param-2/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/path-param-2/theme.html Wed Sep 8 17:55:40 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + Modified: z3/xdv/trunk/lib/xdv/tests/tests.py ============================================================================== --- z3/xdv/trunk/lib/xdv/tests/tests.py (original) +++ z3/xdv/trunk/lib/xdv/tests/tests.py Wed Sep 8 17:55:40 2010 @@ -80,7 +80,9 @@ # Apply the compiled version, then test against desired output theme_parser.resolvers.add(xdv.run.RunResolver(self.testdir)) processor = etree.XSLT(ct) - result = processor(contentdoc) + params = {} + params['path'] = "'%s'" % config.get('xdvtest', 'path') + result = processor(contentdoc, **params) # Read the whole thing to strip off xhtml namespace. # If we had xslt 2.0 then we could use xpath-default-namespace. From ldr at codespeak.net Wed Sep 8 18:39:32 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Wed, 8 Sep 2010 18:39:32 +0200 (CEST) Subject: [z3-checkins] r76950 - in z3/xdv/trunk: docs lib/xdv lib/xdv/tests/if-path-1 Message-ID: <20100908163932.AD570282BD6@codespeak.net> Author: ldr Date: Wed Sep 8 18:39:31 2010 New Revision: 76950 Added: z3/xdv/trunk/lib/xdv/tests/if-path-1/ z3/xdv/trunk/lib/xdv/tests/if-path-1/content.html z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-1/output.html z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-1/theme.html Modified: z3/xdv/trunk/docs/CHANGES.txt z3/xdv/trunk/lib/xdv/apply-conditions.xsl z3/xdv/trunk/lib/xdv/defaults.xsl z3/xdv/trunk/lib/xdv/merge-conditions.xsl Log: if-path support Modified: z3/xdv/trunk/docs/CHANGES.txt ============================================================================== --- z3/xdv/trunk/docs/CHANGES.txt (original) +++ z3/xdv/trunk/docs/CHANGES.txt Wed Sep 8 18:39:31 2010 @@ -4,6 +4,8 @@ 0.4b3 - unreleased ------------------ +* if-path support. + * $path parameter. * Serialize using XSLT method from xdvrun. Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/apply-conditions.xsl (original) +++ z3/xdv/trunk/lib/xdv/apply-conditions.xsl Wed Sep 8 18:39:31 2010 @@ -5,17 +5,21 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > - + - - + + () + + and + + + @if-path ending with '/' not yet supported - - - + starts-with($normalized_path, '/') + contains($normalized_path, '//') Modified: z3/xdv/trunk/lib/xdv/defaults.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/defaults.xsl (original) +++ z3/xdv/trunk/lib/xdv/defaults.xsl Wed Sep 8 18:39:31 2010 @@ -11,6 +11,7 @@ exclude-result-prefixes="exsl str css dv dyn xhtml"> + - () and + and Added: z3/xdv/trunk/lib/xdv/tests/if-path-1/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/content.html Wed Sep 8 18:39:31 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg Wed Sep 8 18:39:31 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /somewhere Added: z3/xdv/trunk/lib/xdv/tests/if-path-1/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/output.html Wed Sep 8 18:39:31 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml Wed Sep 8 18:39:31 2010 @@ -0,0 +1,10 @@ + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-1/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/theme.html Wed Sep 8 18:39:31 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 18:22:08 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 18:22:08 +0200 (CEST) Subject: [z3-checkins] r76977 - in z3/xdv/trunk/lib/xdv: . tests/if-path-1 tests/if-path-2 Message-ID: <20100909162208.73F3536C225@codespeak.net> Author: ldr Date: Thu Sep 9 18:22:06 2010 New Revision: 76977 Added: z3/xdv/trunk/lib/xdv/tests/if-path-2/ z3/xdv/trunk/lib/xdv/tests/if-path-2/content.html z3/xdv/trunk/lib/xdv/tests/if-path-2/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-2/output.html z3/xdv/trunk/lib/xdv/tests/if-path-2/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-2/theme.html Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml Log: exact path match Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/apply-conditions.xsl (original) +++ z3/xdv/trunk/lib/xdv/apply-conditions.xsl Thu Sep 9 18:22:06 2010 @@ -15,7 +15,8 @@ and - + $normalized_path = '' + @if-path ending with '/' not yet supported starts-with($normalized_path, '/') Modified: z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml ============================================================================== --- z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml (original) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/rules.xml Thu Sep 9 18:22:06 2010 @@ -2,6 +2,7 @@ xmlns="http://namespaces.plone.org/xdv" xmlns:css="http://namespaces.plone.org/xdv+css" > + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-2/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-2/options.cfg Thu Sep 9 18:22:06 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /somewhere Added: z3/xdv/trunk/lib/xdv/tests/if-path-2/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-2/output.html Thu Sep 9 18:22:06 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-2/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-2/rules.xml Thu Sep 9 18:22:06 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-2/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-2/theme.html Thu Sep 9 18:22:06 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 18:31:18 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 18:31:18 +0200 (CEST) Subject: [z3-checkins] r76979 - in z3/xdv/trunk/lib/xdv: . tests/if-path-1 tests/if-path-3 Message-ID: <20100909163118.363C9282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 18:31:16 2010 New Revision: 76979 Added: z3/xdv/trunk/lib/xdv/tests/if-path-3/ z3/xdv/trunk/lib/xdv/tests/if-path-3/content.html z3/xdv/trunk/lib/xdv/tests/if-path-3/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-3/output.html z3/xdv/trunk/lib/xdv/tests/if-path-3/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-3/theme.html Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg Log: path ends with Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/apply-conditions.xsl (original) +++ z3/xdv/trunk/lib/xdv/apply-conditions.xsl Thu Sep 9 18:31:16 2010 @@ -15,12 +15,14 @@
and - $normalized_path = '' - - @if-path ending with '/' not yet supported - - starts-with($normalized_path, '/') - contains($normalized_path, '//') + $normalized_path = '' + substring($normalized_path, string-length($normalized_path) - ) = '/' + starts-with($normalized_path, '/') + contains($normalized_path, '//') Modified: z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg ============================================================================== --- z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg (original) +++ z3/xdv/trunk/lib/xdv/tests/if-path-1/options.cfg Thu Sep 9 18:31:16 2010 @@ -1,2 +1,2 @@ [xdvtest] -path = /somewhere +path = /somewhere/another Added: z3/xdv/trunk/lib/xdv/tests/if-path-3/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-3/content.html Thu Sep 9 18:31:16 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-3/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-3/options.cfg Thu Sep 9 18:31:16 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /somewhere/another Added: z3/xdv/trunk/lib/xdv/tests/if-path-3/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-3/output.html Thu Sep 9 18:31:16 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-3/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-3/rules.xml Thu Sep 9 18:31:16 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-3/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-3/theme.html Thu Sep 9 18:31:16 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 18:33:34 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 18:33:34 +0200 (CEST) Subject: [z3-checkins] r76980 - z3/xdv/trunk/lib/xdv/tests/if-path-4 Message-ID: <20100909163334.94BB936C227@codespeak.net> Author: ldr Date: Thu Sep 9 18:33:33 2010 New Revision: 76980 Added: z3/xdv/trunk/lib/xdv/tests/if-path-4/ z3/xdv/trunk/lib/xdv/tests/if-path-4/content.html z3/xdv/trunk/lib/xdv/tests/if-path-4/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-4/output.html z3/xdv/trunk/lib/xdv/tests/if-path-4/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-4/theme.html Log: path contains Added: z3/xdv/trunk/lib/xdv/tests/if-path-4/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-4/content.html Thu Sep 9 18:33:33 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-4/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-4/options.cfg Thu Sep 9 18:33:33 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /start/somewhere/another Added: z3/xdv/trunk/lib/xdv/tests/if-path-4/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-4/output.html Thu Sep 9 18:33:33 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-4/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-4/rules.xml Thu Sep 9 18:33:33 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-4/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-4/theme.html Thu Sep 9 18:33:33 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 19:01:45 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 19:01:45 +0200 (CEST) Subject: [z3-checkins] r76981 - in z3/xdv/trunk/lib/xdv: . tests/if-path-5 Message-ID: <20100909170145.1FB6A36C22E@codespeak.net> Author: ldr Date: Thu Sep 9 19:01:43 2010 New Revision: 76981 Added: z3/xdv/trunk/lib/xdv/tests/if-path-5/ z3/xdv/trunk/lib/xdv/tests/if-path-5/content.html z3/xdv/trunk/lib/xdv/tests/if-path-5/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-5/output.html z3/xdv/trunk/lib/xdv/tests/if-path-5/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-5/theme.html Modified: z3/xdv/trunk/lib/xdv/defaults.xsl Log: path normalization for trailing / Modified: z3/xdv/trunk/lib/xdv/defaults.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/defaults.xsl (original) +++ z3/xdv/trunk/lib/xdv/defaults.xsl Thu Sep 9 19:01:43 2010 @@ -11,7 +11,7 @@ exclude-result-prefixes="exsl str css dv dyn xhtml"> - + / + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-5/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-5/options.cfg Thu Sep 9 19:01:43 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /somewhere/ Added: z3/xdv/trunk/lib/xdv/tests/if-path-5/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-5/output.html Thu Sep 9 19:01:43 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-5/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-5/rules.xml Thu Sep 9 19:01:43 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-5/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-5/theme.html Thu Sep 9 19:01:43 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 19:21:10 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 19:21:10 +0200 (CEST) Subject: [z3-checkins] r76982 - in z3/xdv/trunk/lib/xdv: . tests/if-path-6 Message-ID: <20100909172110.6C804282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 19:21:08 2010 New Revision: 76982 Added: z3/xdv/trunk/lib/xdv/tests/if-path-6/ z3/xdv/trunk/lib/xdv/tests/if-path-6/content.html z3/xdv/trunk/lib/xdv/tests/if-path-6/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-6/output.html z3/xdv/trunk/lib/xdv/tests/if-path-6/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-6/theme.html Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl Log: multiple path conditions Modified: z3/xdv/trunk/lib/xdv/apply-conditions.xsl ============================================================================== --- z3/xdv/trunk/lib/xdv/apply-conditions.xsl (original) +++ z3/xdv/trunk/lib/xdv/apply-conditions.xsl Thu Sep 9 19:21:08 2010 @@ -1,5 +1,6 @@ () and - - $normalized_path = '' - substring($normalized_path, string-length($normalized_path) - ) = '/' - starts-with($normalized_path, '/') - contains($normalized_path, '//') - + + + ( + + + + $normalized_path = '' + substring($normalized_path, string-length($normalized_path) - ) = '/' + starts-with($normalized_path, '/') + contains($normalized_path, '//') + + or + + ) +
Added: z3/xdv/trunk/lib/xdv/tests/if-path-6/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-6/content.html Thu Sep 9 19:21:08 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-6/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-6/options.cfg Thu Sep 9 19:21:08 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /another Added: z3/xdv/trunk/lib/xdv/tests/if-path-6/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-6/output.html Thu Sep 9 19:21:08 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-6/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-6/rules.xml Thu Sep 9 19:21:08 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-6/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-6/theme.html Thu Sep 9 19:21:08 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 19:39:01 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 19:39:01 +0200 (CEST) Subject: [z3-checkins] r76985 - z3/xdv/trunk Message-ID: <20100909173901.DAF02282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 19:39:00 2010 New Revision: 76985 Modified: z3/xdv/trunk/README.txt Log: Note on Apache configuration docs Modified: z3/xdv/trunk/README.txt ============================================================================== --- z3/xdv/trunk/README.txt (original) +++ z3/xdv/trunk/README.txt Thu Sep 9 19:39:00 2010 @@ -916,12 +916,12 @@ Apache ------ -XDV currently requires a version of mod_transform with html parsing support. -The latest patched versions may be downloaded from the html-xslt_ project +XDV requires a version of mod_transform with html parsing support. +The latest compatible version may be downloaded from the html-xslt_ project page. As well as the libxml2 and libxslt development packages, you will require the -appropriate Apache development pacakge:: +appropriate Apache development package:: $ sudo apt-get install libxslt1-dev apache2-threaded-dev @@ -942,17 +942,19 @@ FilterDeclare THEME FilterProvider THEME XSLT resp=Content-Type $text/html - TransformOptions ApacheFS HTML HideParseErrors + TransformOptions +ApacheFS +HTML +HideParseErrors TransformSet /theme.xsl TransformCache /theme.xsl /etc/apache2/theme.xsl FilterChain THEME - + -The ``ApacheFS`` directive enables XSLT ``document()`` inclusion. +The ``ApacheFS`` directive enables XSLT ``document()`` inclusion, though +beware that the includes documents are currently parsed using the XML rather +than HTML parser. Unfortunately it is not possible to theme error responses (such as a 404 Not Found page) with Apache as these do not pass through the filter chain. From ldr at codespeak.net Thu Sep 9 19:52:37 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 19:52:37 +0200 (CEST) Subject: [z3-checkins] r76987 - z3/xdv/trunk/lib/xdv/tests/if-path-7 Message-ID: <20100909175237.5B569282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 19:52:35 2010 New Revision: 76987 Added: z3/xdv/trunk/lib/xdv/tests/if-path-7/ z3/xdv/trunk/lib/xdv/tests/if-path-7/content.html z3/xdv/trunk/lib/xdv/tests/if-path-7/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-7/output.html z3/xdv/trunk/lib/xdv/tests/if-path-7/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-7/theme.html Log: a test for an exact path match to / Added: z3/xdv/trunk/lib/xdv/tests/if-path-7/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-7/content.html Thu Sep 9 19:52:35 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-7/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-7/options.cfg Thu Sep 9 19:52:35 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = / Added: z3/xdv/trunk/lib/xdv/tests/if-path-7/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-7/output.html Thu Sep 9 19:52:35 2010 @@ -0,0 +1,9 @@ + + + +

Title

+
+

content

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-7/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-7/rules.xml Thu Sep 9 19:52:35 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-7/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-7/theme.html Thu Sep 9 19:52:35 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 19:57:46 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 19:57:46 +0200 (CEST) Subject: [z3-checkins] r76988 - z3/xdv/trunk/lib/xdv/tests/if-path-8 Message-ID: <20100909175746.49134282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 19:57:44 2010 New Revision: 76988 Added: z3/xdv/trunk/lib/xdv/tests/if-path-8/ z3/xdv/trunk/lib/xdv/tests/if-path-8/content.html z3/xdv/trunk/lib/xdv/tests/if-path-8/options.cfg z3/xdv/trunk/lib/xdv/tests/if-path-8/output.html z3/xdv/trunk/lib/xdv/tests/if-path-8/rules.xml z3/xdv/trunk/lib/xdv/tests/if-path-8/theme.html Log: test to show only complete path segments are matched Added: z3/xdv/trunk/lib/xdv/tests/if-path-8/content.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-8/content.html Thu Sep 9 19:57:44 2010 @@ -0,0 +1,5 @@ + + +

content

+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-8/options.cfg ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-8/options.cfg Thu Sep 9 19:57:44 2010 @@ -0,0 +1,2 @@ +[xdvtest] +path = /somewherelse Added: z3/xdv/trunk/lib/xdv/tests/if-path-8/output.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-8/output.html Thu Sep 9 19:57:44 2010 @@ -0,0 +1,7 @@ + + + +

Title

+
+ + Added: z3/xdv/trunk/lib/xdv/tests/if-path-8/rules.xml ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-8/rules.xml Thu Sep 9 19:57:44 2010 @@ -0,0 +1,11 @@ + + + + Added: z3/xdv/trunk/lib/xdv/tests/if-path-8/theme.html ============================================================================== --- (empty file) +++ z3/xdv/trunk/lib/xdv/tests/if-path-8/theme.html Thu Sep 9 19:57:44 2010 @@ -0,0 +1,6 @@ + + +

Title

+
+ + From ldr at codespeak.net Thu Sep 9 20:43:58 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 20:43:58 +0200 (CEST) Subject: [z3-checkins] r76989 - in z3/xdv/trunk: . docs templates Message-ID: <20100909184358.BBC92282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 20:43:55 2010 New Revision: 76989 Modified: z3/xdv/trunk/README.txt z3/xdv/trunk/docs/CHANGES.txt z3/xdv/trunk/docs/TODO.txt z3/xdv/trunk/templates/nginx.conf.in Log: Document path conditions. Modified: z3/xdv/trunk/README.txt ============================================================================== --- z3/xdv/trunk/README.txt (original) +++ z3/xdv/trunk/README.txt Thu Sep 9 20:43:55 2010 @@ -286,7 +286,7 @@ does not appear in the markup. The ``if-content`` attribute can be used with any rule to make it conditional. -``if-content`` should be set an XPath expression. You can also use +``if-content`` should be set to an XPath expression. You can also use ``css:if-content`` with a CSS3 expression. If the expression matches a node in the content, the rule will be applied:: @@ -306,10 +306,9 @@ content into the element with id ``header`` in the theme, so long as an element with id ``personal-bar`` also appears somewhere in the content. -Above, we also saw the special case of an empty ``if-content`` (which also -works with an empty ``css:if-content``). This is a shortcut that means "use -the expression in the ``content`` or ``css:content``` attribute as the -condition". Hence the following two rules are equivalent:: +An empty ``if-content`` (or ``css:if-content``) is a shortcut meaning "use the +expression in the ``content`` or ``css:content``` attribute as the condition". +Hence the following two rules are equivalent:: @@ -385,6 +384,48 @@ +Path conditions +~~~~~~~~~~~~~~~ + +A path condition may be applied to a rule, theme or group with the ``if-path`` +attribute. + +A leading ``/`` indicates that a path should be matched at the start of the +url:: + + + +matches pages with urls ``/news``, ``/news/`` and ``/news/page1.html`` but +not ``/newspapers`` - only complete path segments are matched. + +A trailing ``/`` indicates that a path should be matched at the end of the +url:: + + + +matches ``/mysite/news`` and ``/mysite/news/``. + +To match an exact url, use both leading and trailing ``/``:: + + + +matches ``/news`` and ``/news/``. + +Without a leading or trailing ``/`` the path segment(s) may match anywhere in +the url:: + + + +matches ``/mysite/news/space/page1.html``. + +Multiple alternative path conditions may be included in the ``if-path`` +attribute as whitespace separated list:: + + + +matches ``/`` and ``/index.html``. ``if-path="/"`` is considered an exact +match condition + Including external content ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -800,7 +841,9 @@ configuration as follows:: location / { - xslt_stylesheet /path/to/compiled-theme.xsl; + xslt_stylesheet /path/to/compiled-theme.xsl + path='$uri' + ; xslt_html_parser on; xslt_types text/html; } @@ -808,7 +851,9 @@ Nginx may also be configured as a transforming proxy server:: location / { - xslt_stylesheet /path/to/compiled-theme.xsl; + xslt_stylesheet /path/to/compiled-theme.xsl + path='$uri' + ; xslt_html_parser on; xslt_types text/html; rewrite ^(.*)$ /VirtualHostBase/http/localhost/Plone/VirtualHostRoot$1 break; @@ -828,8 +873,8 @@ In this example an X-XDV header was set so the backend server may choose to serve different different CSS resources. -Including external content -~~~~~~~~~~~~~~~~~~~~~~~~~~ +Including external content with SSI +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As an event based server, it is not practical to add ``document()`` support to the Nginx XSLT module for in-transform inclusion. Instead, external content is @@ -886,7 +931,9 @@ } location / { - xslt_stylesheet theme.xsl; + xslt_stylesheet theme.xsl + path='$uri' + ; xslt_html_parser on; xslt_types text/html; ssi on; # Not required in ESI mode @@ -959,6 +1006,8 @@ Unfortunately it is not possible to theme error responses (such as a 404 Not Found page) with Apache as these do not pass through the filter chain. +As parameters are not currently supported, path expression are unavailable. + .. _Deliverance: http://deliveranceproject.org/ .. _collective.xdv: http://pypi.python.org/pypi/collective.xdv .. _dv.xdvserver: http://pypi.python.org/pypi/dv.xdvserver Modified: z3/xdv/trunk/docs/CHANGES.txt ============================================================================== --- z3/xdv/trunk/docs/CHANGES.txt (original) +++ z3/xdv/trunk/docs/CHANGES.txt Thu Sep 9 20:43:55 2010 @@ -4,11 +4,9 @@ 0.4b3 - unreleased ------------------ -* if-path support. +* Path conditions with @if-path. -* $path parameter. - -* Serialize using XSLT method from xdvrun. +* Serialize using XSLT method in xdvrun to respect * Fix for default theme. Modified: z3/xdv/trunk/docs/TODO.txt ============================================================================== --- z3/xdv/trunk/docs/TODO.txt (original) +++ z3/xdv/trunk/docs/TODO.txt Thu Sep 9 20:43:55 2010 @@ -32,7 +32,7 @@ * Maybe this should be called ``rules`` instead. -Path conditions +Path conditions (implemented as a single if-path attribute) --------------- So far, XDV has taken the view that path configuration belongs in your Modified: z3/xdv/trunk/templates/nginx.conf.in ============================================================================== --- z3/xdv/trunk/templates/nginx.conf.in (original) +++ z3/xdv/trunk/templates/nginx.conf.in Thu Sep 9 20:43:55 2010 @@ -56,7 +56,9 @@ # Our styled location. location /styled { alias ${root}; - xslt_stylesheet ${example.xsl}; + xslt_stylesheet ${example.xsl} + path='$uri' + ; xslt_html_parser on; xslt_types text/html; # Switch on ssi here to enable external includes. @@ -66,7 +68,9 @@ # Another styled location. location /styled/ploneorg { alias ${root}/ploneorg; - xslt_stylesheet ${ploneorg.xsl}; + xslt_stylesheet ${ploneorg.xsl} + path='$uri' + ; xslt_html_parser on; xslt_types text/html; } From ldr at codespeak.net Thu Sep 9 20:46:18 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 20:46:18 +0200 (CEST) Subject: [z3-checkins] r76990 - z3/xdv/trunk/docs Message-ID: <20100909184618.559A6282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 20:46:16 2010 New Revision: 76990 Modified: z3/xdv/trunk/docs/CHANGES.txt Log: prepare 0.4b3 release Modified: z3/xdv/trunk/docs/CHANGES.txt ============================================================================== --- z3/xdv/trunk/docs/CHANGES.txt (original) +++ z3/xdv/trunk/docs/CHANGES.txt Thu Sep 9 20:46:16 2010 @@ -1,7 +1,7 @@ Changelog ========= -0.4b3 - unreleased +0.4b3 - 2010-09-09 ------------------ * Path conditions with @if-path. From ldr at codespeak.net Thu Sep 9 20:47:50 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 20:47:50 +0200 (CEST) Subject: [z3-checkins] r76991 - z3/xdv/tags/0.4b3 Message-ID: <20100909184750.27A7E282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 20:47:48 2010 New Revision: 76991 Added: z3/xdv/tags/0.4b3/ (props changed) - copied from r76990, z3/xdv/trunk/ Log: tag 0.4b3 From ldr at codespeak.net Thu Sep 9 20:48:47 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Thu, 9 Sep 2010 20:48:47 +0200 (CEST) Subject: [z3-checkins] r76992 - in z3/xdv/trunk: . docs Message-ID: <20100909184847.A7058282B9C@codespeak.net> Author: ldr Date: Thu Sep 9 20:48:46 2010 New Revision: 76992 Modified: z3/xdv/trunk/docs/CHANGES.txt z3/xdv/trunk/setup.py Log: bump version Modified: z3/xdv/trunk/docs/CHANGES.txt ============================================================================== --- z3/xdv/trunk/docs/CHANGES.txt (original) +++ z3/xdv/trunk/docs/CHANGES.txt Thu Sep 9 20:48:46 2010 @@ -1,6 +1,11 @@ Changelog ========= +0.4b4 - unreleased +------------------ + + + 0.4b3 - 2010-09-09 ------------------ Modified: z3/xdv/trunk/setup.py ============================================================================== --- z3/xdv/trunk/setup.py (original) +++ z3/xdv/trunk/setup.py Thu Sep 9 20:48:46 2010 @@ -3,7 +3,7 @@ setup( name='xdv', - version='0.4b3', + version='0.4b4', description='''\ XDV implements a subset of Deliverance using a pure XSLT engine. With XDV, you "compile" your theme and ruleset in one step, then use a superfast/simple From ldr at codespeak.net Mon Sep 13 18:09:59 2010 From: ldr at codespeak.net (ldr at codespeak.net) Date: Mon, 13 Sep 2010 18:09:59 +0200 (CEST) Subject: [z3-checkins] r77045 - in z3/dv.xdvserver/trunk: . dv/xdvserver Message-ID: <20100913160959.8825F282C01@codespeak.net> Author: ldr Date: Mon Sep 13 18:09:53 2010 New Revision: 77045 Added: z3/dv.xdvserver/trunk/bootstrap.py (contents, props changed) z3/dv.xdvserver/trunk/buildout.cfg z3/dv.xdvserver/trunk/dv/xdvserver/tests.py Log: basic testing infrastructure Added: z3/dv.xdvserver/trunk/bootstrap.py ============================================================================== --- (empty file) +++ z3/dv.xdvserver/trunk/bootstrap.py Mon Sep 13 18:09:53 2010 @@ -0,0 +1,260 @@ +############################################################################## +# +# Copyright (c) 2006 Zope Foundation and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +"""Bootstrap a buildout-based project + +Simply run this script in a directory containing a buildout.cfg. +The script accepts buildout command-line options, so you can +use the -c option to specify an alternate configuration file. +""" + +import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess +from optparse import OptionParser + +if sys.platform == 'win32': + def quote(c): + if ' ' in c: + return '"%s"' % c # work around spawn lamosity on windows + else: + return c +else: + quote = str + +# See zc.buildout.easy_install._has_broken_dash_S for motivation and comments. +stdout, stderr = subprocess.Popen( + [sys.executable, '-Sc', + 'try:\n' + ' import ConfigParser\n' + 'except ImportError:\n' + ' print 1\n' + 'else:\n' + ' print 0\n'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() +has_broken_dash_S = bool(int(stdout.strip())) + +# In order to be more robust in the face of system Pythons, we want to +# run without site-packages loaded. This is somewhat tricky, in +# particular because Python 2.6's distutils imports site, so starting +# with the -S flag is not sufficient. However, we'll start with that: +if not has_broken_dash_S and 'site' in sys.modules: + # We will restart with python -S. + args = sys.argv[:] + args[0:0] = [sys.executable, '-S'] + args = map(quote, args) + os.execv(sys.executable, args) +# Now we are running with -S. We'll get the clean sys.path, import site +# because distutils will do it later, and then reset the path and clean +# out any namespace packages from site-packages that might have been +# loaded by .pth files. +clean_path = sys.path[:] +import site +sys.path[:] = clean_path +for k, v in sys.modules.items(): + if k in ('setuptools', 'pkg_resources') or ( + hasattr(v, '__path__') and + len(v.__path__)==1 and + not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))): + # This is a namespace package. Remove it. + sys.modules.pop(k) + +is_jython = sys.platform.startswith('java') + +setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py' +distribute_source = 'http://python-distribute.org/distribute_setup.py' + +# parsing arguments +def normalize_to_url(option, opt_str, value, parser): + if value: + if '://' not in value: # It doesn't smell like a URL. + value = 'file://%s' % ( + urllib.pathname2url( + os.path.abspath(os.path.expanduser(value))),) + if opt_str == '--download-base' and not value.endswith('/'): + # Download base needs a trailing slash to make the world happy. + value += '/' + else: + value = None + name = opt_str[2:].replace('-', '_') + setattr(parser.values, name, value) + +usage = '''\ +[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] + +Bootstraps a buildout-based project. + +Simply run this script in a directory containing a buildout.cfg, using the +Python that you want bin/buildout to use. + +Note that by using --setup-source and --download-base to point to +local resources, you can keep this script from going over the network. +''' + +parser = OptionParser(usage=usage) +parser.add_option("-v", "--version", dest="version", + help="use a specific zc.buildout version") +parser.add_option("-d", "--distribute", + action="store_true", dest="use_distribute", default=False, + help="Use Distribute rather than Setuptools.") +parser.add_option("--setup-source", action="callback", dest="setup_source", + callback=normalize_to_url, nargs=1, type="string", + help=("Specify a URL or file location for the setup file. " + "If you use Setuptools, this will default to " + + setuptools_source + "; if you use Distribute, this " + "will default to " + distribute_source +".")) +parser.add_option("--download-base", action="callback", dest="download_base", + callback=normalize_to_url, nargs=1, type="string", + help=("Specify a URL or directory for downloading " + "zc.buildout and either Setuptools or Distribute. " + "Defaults to PyPI.")) +parser.add_option("--eggs", + help=("Specify a directory for storing eggs. Defaults to " + "a temporary directory that is deleted when the " + "bootstrap script completes.")) +parser.add_option("-t", "--accept-buildout-test-releases", + dest='accept_buildout_test_releases', + action="store_true", default=False, + help=("Normally, if you do not specify a --version, the " + "bootstrap script and buildout gets the newest " + "*final* versions of zc.buildout and its recipes and " + "extensions for you. If you use this flag, " + "bootstrap and buildout will get the newest releases " + "even if they are alphas or betas.")) +parser.add_option("-c", None, action="store", dest="config_file", + help=("Specify the path to the buildout configuration " + "file to be used.")) + +options, args = parser.parse_args() + +# if -c was provided, we push it back into args for buildout's main function +if options.config_file is not None: + args += ['-c', options.config_file] + +if options.eggs: + eggs_dir = os.path.abspath(os.path.expanduser(options.eggs)) +else: + eggs_dir = tempfile.mkdtemp() + +if options.setup_source is None: + if options.use_distribute: + options.setup_source = distribute_source + else: + options.setup_source = setuptools_source + +if options.accept_buildout_test_releases: + args.append('buildout:accept-buildout-test-releases=true') +args.append('bootstrap') + +try: + import pkg_resources + import setuptools # A flag. Sometimes pkg_resources is installed alone. + if not hasattr(pkg_resources, '_distribute'): + raise ImportError +except ImportError: + ez_code = urllib2.urlopen( + options.setup_source).read().replace('\r\n', '\n') + ez = {} + exec ez_code in ez + setup_args = dict(to_dir=eggs_dir, download_delay=0) + if options.download_base: + setup_args['download_base'] = options.download_base + if options.use_distribute: + setup_args['no_fake'] = True + ez['use_setuptools'](**setup_args) + if 'pkg_resources' in sys.modules: + reload(sys.modules['pkg_resources']) + import pkg_resources + # This does not (always?) update the default working set. We will + # do it. + for path in sys.path: + if path not in pkg_resources.working_set.entries: + pkg_resources.working_set.add_entry(path) + +cmd = [quote(sys.executable), + '-c', + quote('from setuptools.command.easy_install import main; main()'), + '-mqNxd', + quote(eggs_dir)] + +if not has_broken_dash_S: + cmd.insert(1, '-S') + +find_links = options.download_base +if not find_links: + find_links = os.environ.get('bootstrap-testing-find-links') +if find_links: + cmd.extend(['-f', quote(find_links)]) + +if options.use_distribute: + setup_requirement = 'distribute' +else: + setup_requirement = 'setuptools' +ws = pkg_resources.working_set +setup_requirement_path = ws.find( + pkg_resources.Requirement.parse(setup_requirement)).location +env = dict( + os.environ, + PYTHONPATH=setup_requirement_path) + +requirement = 'zc.buildout' +version = options.version +if version is None and not options.accept_buildout_test_releases: + # Figure out the most recent final version of zc.buildout. + import setuptools.package_index + _final_parts = '*final-', '*final' + def _final_version(parsed_version): + for part in parsed_version: + if (part[:1] == '*') and (part not in _final_parts): + return False + return True + index = setuptools.package_index.PackageIndex( + search_path=[setup_requirement_path]) + if find_links: + index.add_find_links((find_links,)) + req = pkg_resources.Requirement.parse(requirement) + if index.obtain(req) is not None: + best = [] + bestv = None + for dist in index[req.project_name]: + distv = dist.parsed_version + if _final_version(distv): + if bestv is None or distv > bestv: + best = [dist] + bestv = distv + elif distv == bestv: + best.append(dist) + if best: + best.sort() + version = best[-1].version +if version: + requirement = '=='.join((requirement, version)) +cmd.append(requirement) + +if is_jython: + import subprocess + exitcode = subprocess.Popen(cmd, env=env).wait() +else: # Windows prefers this, apparently; otherwise we would prefer subprocess + exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env])) +if exitcode != 0: + sys.stdout.flush() + sys.stderr.flush() + print ("An error occurred when trying to install zc.buildout. " + "Look above this message for any errors that " + "were output by easy_install.") + sys.exit(exitcode) + +ws.add_entry(eggs_dir) +ws.require(requirement) +import zc.buildout.buildout +zc.buildout.buildout.main(args) +if not options.eggs: # clean up temporary egg directory + shutil.rmtree(eggs_dir) Added: z3/dv.xdvserver/trunk/buildout.cfg ============================================================================== --- (empty file) +++ z3/dv.xdvserver/trunk/buildout.cfg Mon Sep 13 18:09:53 2010 @@ -0,0 +1,19 @@ +[buildout] +versions = versions +parts = test py +develop = . + +[test] +recipe = zc.recipe.testrunner +eggs = dv.xdvserver +defaults = ['--auto-color'] + +[py] +recipe = zc.recipe.egg +eggs = + dv.xdvserver + collective.checkdocs +interpreter = py + +[versions] +lxml = 2.2.8 Added: z3/dv.xdvserver/trunk/dv/xdvserver/tests.py ============================================================================== --- (empty file) +++ z3/dv.xdvserver/trunk/dv/xdvserver/tests.py Mon Sep 13 18:09:53 2010 @@ -0,0 +1,36 @@ +import unittest +from dv.xdvserver.filter import XSLTMiddleware +from paste.fixture import TestApp + +def application(environ, start_response): + """Simplest possible application object""" + status = '200 OK' + response_headers = [('Content-Type', 'text/html')] + start_response(status, response_headers) + return ['Hello world!
\n'] + +XHTML_IDENTITY = ''' + + + + + + + + +''' + +class TestXSLTMiddleware(unittest.TestCase): + + def broken_test_xhtml(self): + app = TestApp(XSLTMiddleware(app=application, global_conf=None, xslt_source=XHTML_IDENTITY)) + response = app.get('/') + response.mustcontain('
') + + +def test_suite(): + return unittest.defaultTestLoader.loadTestsFromName(__name__) From z3-checkins at codespeak.net Tue Sep 21 17:58:57 2010 From: z3-checkins at codespeak.net (z3-checkins at codespeak.net) Date: Tue, 21 Sep 2010 17:58:57 +0200 (CEST) Subject: [z3-checkins] MensHealth Discount ID65771 Message-ID: <20100921195216.2666.qmail@186-58-25-195.speedy.com.ar> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/z3-checkins/attachments/20100921/53f7657f/attachment-0001.htm From ejucovy at codespeak.net Thu Sep 23 18:26:16 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 18:26:16 +0200 (CEST) Subject: [z3-checkins] r77307 - z3/deliverance/trunk Message-ID: <20100923162616.DB4AF282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 18:26:15 2010 New Revision: 77307 Modified: z3/deliverance/trunk/setup.py Log: remove broken devauth dependency_link. i'll tag and release devauth. Modified: z3/deliverance/trunk/setup.py ============================================================================== --- z3/deliverance/trunk/setup.py (original) +++ z3/deliverance/trunk/setup.py Thu Sep 23 18:26:15 2010 @@ -45,9 +45,6 @@ "chardet", "simplejson", ], - dependency_links=[ - "https://svn.openplans.org/svn/DevAuth/trunk#egg=DevAuth-dev", - ], entry_points=""" [console_scripts] deliverance-proxy = deliverance.proxycommand:main From ejucovy at codespeak.net Thu Sep 23 19:04:14 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:04:14 +0200 (CEST) Subject: [z3-checkins] r77308 - z3/deliverance/trunk/deliverance Message-ID: <20100923170414.A69F2282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:04:12 2010 New Revision: 77308 Modified: z3/deliverance/trunk/deliverance/ruleset.py Log: fix import for webob 1.0 Modified: z3/deliverance/trunk/deliverance/ruleset.py ============================================================================== --- z3/deliverance/trunk/deliverance/ruleset.py (original) +++ z3/deliverance/trunk/deliverance/ruleset.py Thu Sep 23 19:04:12 2010 @@ -3,7 +3,12 @@ import re from lxml.html import tostring, document_fromstring from lxml.etree import XML, Comment -from webob.headerdict import HeaderDict + +try: # webob 1.0 + from webob.headers import ResponseHeaders +except ImportError: # webob 0.9.8 + from webob.headerdict import HeaderDict as ResponseHeaders + from deliverance.exceptions import AbortTheme, DeliveranceSyntaxError from deliverance.pagematch import run_matches, Match, ClientsideMatch from deliverance.rules import Rule, remove_content_attribs @@ -35,7 +40,7 @@ """ extra_headers = parse_meta_headers(resp.body) if extra_headers: - response_headers = HeaderDict(resp.headerlist + extra_headers) + response_headers = ResponseHeaders(resp.headerlist + extra_headers) else: response_headers = resp.headers try: @@ -239,7 +244,7 @@ def clientside_actions(self, req, resp, log): extra_headers = parse_meta_headers(resp.body) if extra_headers: - response_headers = HeaderDict(resp.headerlist + extra_headers) + response_headers = ResponseHeaders(resp.headerlist + extra_headers) else: response_headers = resp.headers try: From ejucovy at codespeak.net Thu Sep 23 19:08:38 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:08:38 +0200 (CEST) Subject: [z3-checkins] r77309 - z3/deliverance/branches/0.3 Message-ID: <20100923170838.D264C282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:08:37 2010 New Revision: 77309 Added: z3/deliverance/branches/0.3/ - copied from r77308, z3/deliverance/tags/0.3.0/ Log: branch 0.3.0 tag to backport fix from trunk for webob 1.0 From ejucovy at codespeak.net Thu Sep 23 19:09:36 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:09:36 +0200 (CEST) Subject: [z3-checkins] r77310 - z3/deliverance/branches/0.3 Message-ID: <20100923170936.6DD91282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:09:34 2010 New Revision: 77310 Modified: z3/deliverance/branches/0.3/setup.py Log: bump version Modified: z3/deliverance/branches/0.3/setup.py ============================================================================== --- z3/deliverance/branches/0.3/setup.py (original) +++ z3/deliverance/branches/0.3/setup.py Thu Sep 23 19:09:34 2010 @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.3.0' +version = '0.3.1' setup(name='Deliverance', version=version, From ejucovy at codespeak.net Thu Sep 23 19:10:03 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:10:03 +0200 (CEST) Subject: [z3-checkins] r77311 - z3/deliverance/branches/0.3 Message-ID: <20100923171003.2EE15282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:10:01 2010 New Revision: 77311 Modified: z3/deliverance/branches/0.3/setup.py Log: devauth trunk link is broken (devauth has moved); anyway, we should depend on a release Modified: z3/deliverance/branches/0.3/setup.py ============================================================================== --- z3/deliverance/branches/0.3/setup.py (original) +++ z3/deliverance/branches/0.3/setup.py Thu Sep 23 19:10:01 2010 @@ -45,9 +45,6 @@ "chardet", "simplejson", ], - dependency_links=[ - "https://svn.openplans.org/svn/DevAuth/trunk#egg=DevAuth-dev", - ], entry_points=""" [console_scripts] deliverance-proxy = deliverance.proxycommand:main From ejucovy at codespeak.net Thu Sep 23 19:11:59 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:11:59 +0200 (CEST) Subject: [z3-checkins] r77312 - in z3/deliverance/branches/0.3: . deliverance Message-ID: <20100923171159.B3688282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:11:58 2010 New Revision: 77312 Modified: z3/deliverance/branches/0.3/ (props changed) z3/deliverance/branches/0.3/deliverance/ruleset.py Log: merge r77308 from trunk: webob 1.0 compatibility (with fallback import from webob 0.9.8 location) Modified: z3/deliverance/branches/0.3/deliverance/ruleset.py ============================================================================== --- z3/deliverance/branches/0.3/deliverance/ruleset.py (original) +++ z3/deliverance/branches/0.3/deliverance/ruleset.py Thu Sep 23 19:11:58 2010 @@ -3,7 +3,12 @@ import re from lxml.html import tostring, document_fromstring from lxml.etree import XML, Comment -from webob.headerdict import HeaderDict + +try: # webob 1.0 + from webob.headers import ResponseHeaders +except ImportError: # webob 0.9.8 + from webob.headerdict import HeaderDict as ResponseHeaders + from deliverance.exceptions import AbortTheme, DeliveranceSyntaxError from deliverance.pagematch import run_matches, Match, ClientsideMatch from deliverance.rules import Rule, remove_content_attribs @@ -35,7 +40,7 @@ """ extra_headers = parse_meta_headers(resp.body) if extra_headers: - response_headers = HeaderDict(resp.headerlist + extra_headers) + response_headers = ResponseHeaders(resp.headerlist + extra_headers) else: response_headers = resp.headers try: @@ -239,7 +244,7 @@ def clientside_actions(self, req, resp, log): extra_headers = parse_meta_headers(resp.body) if extra_headers: - response_headers = HeaderDict(resp.headerlist + extra_headers) + response_headers = ResponseHeaders(resp.headerlist + extra_headers) else: response_headers = resp.headers try: From ejucovy at codespeak.net Thu Sep 23 19:14:04 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:14:04 +0200 (CEST) Subject: [z3-checkins] r77313 - in z3/deliverance/branches/0.3: . deliverance/docs Message-ID: <20100923171404.4AAEB282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:14:02 2010 New Revision: 77313 Modified: z3/deliverance/branches/0.3/changes_on_trunk.txt z3/deliverance/branches/0.3/deliverance/docs/news.txt Log: update news Modified: z3/deliverance/branches/0.3/changes_on_trunk.txt ============================================================================== --- z3/deliverance/branches/0.3/changes_on_trunk.txt (original) +++ z3/deliverance/branches/0.3/changes_on_trunk.txt Thu Sep 23 19:14:02 2010 @@ -1,3 +1 @@ -* Pass open file objects to lxml instead of filenames. Apparently lxml can segfault in some circumstances - if you pass a filename for it to open multiple times. (kiorky) Modified: z3/deliverance/branches/0.3/deliverance/docs/news.txt ============================================================================== --- z3/deliverance/branches/0.3/deliverance/docs/news.txt (original) +++ z3/deliverance/branches/0.3/deliverance/docs/news.txt Thu Sep 23 19:14:02 2010 @@ -1,6 +1,20 @@ News ==== +0.3.1 +----- + + * Compatible with WebOb 1.0 (or 0.9.8) + + * Remove dependency_link for unpinned trunk of DevAuth + +0.3 +--- + + * Pass open file objects to lxml instead of filenames. Apparently + lxml can segfault in some circumstances if you pass a filename + for it to open multiple times. (kiorky) + 0.3c4 ----- From ejucovy at codespeak.net Thu Sep 23 19:15:27 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:15:27 +0200 (CEST) Subject: [z3-checkins] r77314 - z3/deliverance/branches/0.3 Message-ID: <20100923171527.E8288282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:15:26 2010 New Revision: 77314 Modified: z3/deliverance/branches/0.3/changes_on_trunk.txt Log: keep 0.3.1 changes in changes_on_trunk file which setup.py uses to generate long_description for a release Modified: z3/deliverance/branches/0.3/changes_on_trunk.txt ============================================================================== --- z3/deliverance/branches/0.3/changes_on_trunk.txt (original) +++ z3/deliverance/branches/0.3/changes_on_trunk.txt Thu Sep 23 19:15:26 2010 @@ -1 +1,2 @@ - + * Compatible with WebOb 1.0 (or 0.9.8) + * Remove dependency_link for unpinned trunk of DevAuth From ejucovy at codespeak.net Thu Sep 23 19:16:31 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:16:31 +0200 (CEST) Subject: [z3-checkins] r77315 - z3/deliverance/branches/0.3/deliverance/docs Message-ID: <20100923171631.0DDAC282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:16:29 2010 New Revision: 77315 Modified: z3/deliverance/branches/0.3/deliverance/docs/news.txt Log: copy news.txt entry for 0.3.0 from trunk instead Modified: z3/deliverance/branches/0.3/deliverance/docs/news.txt ============================================================================== --- z3/deliverance/branches/0.3/deliverance/docs/news.txt (original) +++ z3/deliverance/branches/0.3/deliverance/docs/news.txt Thu Sep 23 19:16:29 2010 @@ -8,13 +8,18 @@ * Remove dependency_link for unpinned trunk of DevAuth -0.3 ---- +0.3.0 +----- - * Pass open file objects to lxml instead of filenames. Apparently + * Pass open file objects to lxml instead of filenames. Apparently lxml can segfault in some circumstances if you pass a filename for it to open multiple times. (kiorky) + * Reorganized pyref documentation into a single document for easier + reference. + + * Added a document on configuring Deliverance with Paste Deploy. + 0.3c4 ----- From ejucovy at codespeak.net Thu Sep 23 19:19:08 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:19:08 +0200 (CEST) Subject: [z3-checkins] r77316 - z3/deliverance/tags/0.3.1 Message-ID: <20100923171908.3CFC6282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:19:06 2010 New Revision: 77316 Added: z3/deliverance/tags/0.3.1/ (props changed) - copied from r77315, z3/deliverance/branches/0.3/ Log: tag 0.3.1 From ejucovy at codespeak.net Thu Sep 23 19:23:14 2010 From: ejucovy at codespeak.net (ejucovy at codespeak.net) Date: Thu, 23 Sep 2010 19:23:14 +0200 (CEST) Subject: [z3-checkins] r77317 - z3/deliverance/trunk/deliverance/docs Message-ID: <20100923172314.30996282B9D@codespeak.net> Author: ejucovy Date: Thu Sep 23 19:23:12 2010 New Revision: 77317 Modified: z3/deliverance/trunk/deliverance/docs/news.txt Log: add 0.3.1 news entries Modified: z3/deliverance/trunk/deliverance/docs/news.txt ============================================================================== --- z3/deliverance/trunk/deliverance/docs/news.txt (original) +++ z3/deliverance/trunk/deliverance/docs/news.txt Thu Sep 23 19:23:12 2010 @@ -1,6 +1,13 @@ News ==== +0.3.1 +----- + + * Compatible with WebOb 1.0 (or 0.9.8) + + * Remove dependency_link for unpinned trunk of DevAuth + 0.3.0 -----