# HG changeset patch
# User cmlenz
# Date 1213608732 0
# Node ID 1678915c08e18218c87485e5d5de2700a1a7d4b4
# Parent 4c163212522028aee3e7c22d9addb565b1b40434
Ported [884] back to 0.5.x branch.
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Version 0.5.1
+http://svn.edgewall.org/repos/genshi/tags/0.5.1/
+(???, from branches/stable/0.5.x)
+
+ * Fix problem with nested match templates not being applied when buffering
+ on the outer `py:match` is disabled. Thanks to Erik Bray for reporting the
+ problem and providing a test case!
+
+
Version 0.5
http://svn.edgewall.org/repos/genshi/tags/0.5.0/
(Jun 9 2008, from branches/stable/0.5.x)
diff --git a/genshi/template/markup.py b/genshi/template/markup.py
--- a/genshi/template/markup.py
+++ b/genshi/template/markup.py
@@ -221,7 +221,7 @@
assert len(streams) == 1
return streams[0]
- def _match(self, stream, ctxt, match_templates=None, **vars):
+ def _match(self, stream, ctxt, match_templates=None, offset=0, **vars):
"""Internal stream filter that applies any defined match templates
to the stream.
"""
@@ -254,6 +254,8 @@
for idx, (test, path, template, hints, namespaces, directives) \
in enumerate(match_templates):
+ if idx < offset:
+ continue
if test(event, namespaces, ctxt) is True:
if 'match_once' in hints:
@@ -296,7 +298,7 @@
self._flatten(template, ctxt, **vars),
ctxt, **vars),
ctxt, **vars),
- ctxt, match_templates[idx + 1:], **vars):
+ ctxt, match_templates, offset=idx + 1, **vars):
yield event
break
diff --git a/genshi/template/tests/markup.py b/genshi/template/tests/markup.py
--- a/genshi/template/tests/markup.py
+++ b/genshi/template/tests/markup.py
@@ -691,6 +691,27 @@
finally:
shutil.rmtree(dirname)
+ def test_nested_matches_without_buffering(self):
+ xml = ("""
+