# HG changeset patch
# User cmlenz
# Date 1213608141 0
# Node ID 9f28d17b1f723cb61c9d17b26ad6e41c1157568d
# Parent 70a172ab5705950e7d1940fe944bb90d5406b809
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.
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,15 @@
* Support for Python 2.3 has been dropped.
+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
@@ -687,6 +687,27 @@
finally:
shutil.rmtree(dirname)
+ def test_nested_matches_without_buffering(self):
+ xml = ("""
+