[z3-checkins] r33788 - in z3/deliverance/branches/packaged/deliverance: . test-data
cabraham at codespeak.net
cabraham at codespeak.net
Thu Oct 26 23:32:59 CEST 2006
Author: cabraham
Date: Thu Oct 26 23:32:56 2006
New Revision: 33788
Modified:
z3/deliverance/branches/packaged/deliverance/interpreter.py
z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml
Log:
errors for drop rules and debugging output
Modified: z3/deliverance/branches/packaged/deliverance/interpreter.py
==============================================================================
--- z3/deliverance/branches/packaged/deliverance/interpreter.py (original)
+++ z3/deliverance/branches/packaged/deliverance/interpreter.py Thu Oct 26 23:32:56 2006
@@ -342,12 +342,25 @@
def apply_drop(self, rule, theme, content):
+
if 'theme' in rule.attrib:
+ removed = False
for el in theme.xpath(rule.attrib['theme']):
el.getparent().remove(el)
+ removed = True
+ if not removed and rule.attrib.get(self.NOCONTENT_KEY) != 'ignore':
+ self.add_to_body_start(
+ theme, self.format_error("no element found in theme", rule))
+
if 'content' in rule.attrib:
+ removed = False
for el in content.xpath(rule.attrib['content']):
el.getparent().remove(el)
+ if not removed and rule.attrib.get(self.NOCONTENT_KEY) != 'ignore':
+ self.add_to_body_start(
+ theme, self.format_error("no element found in content", rule))
+
+
def elements_in(self, els):
"""
Modified: z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml
==============================================================================
--- z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml (original)
+++ z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml Thu Oct 26 23:32:56 2006
@@ -119,8 +119,7 @@
</deliverance-test>
<!-- dropping missing tag generates an error -->
-<!-- XXX currently does not generate error, should it? -->
-<!--deliverance-test>
+<deliverance-test>
<rules xmlns="http://www.plone.org/deliverance">
<drop theme="//div[@id='foo']"/>
</rules>
@@ -137,12 +136,38 @@
<html>
<body>
Dummy Content
- <div class="deliverance-error">Deliverance error: no element found in theme<br/>rule: <drop theme=".//div[@id='foo']"/>
+ <div class="deliverance-error">Deliverance error: no element found in theme<br/>rule: <drop theme="//div[@id='foo']"/>
</div>
</body>
</html>
</output>
-</deliverance-test-->
+</deliverance-test>
+
+<!-- dropping missing tag in the content generates an error -->
+<deliverance-test>
+ <rules xmlns="http://www.plone.org/deliverance">
+ <drop content="//div[@id='foo']"/>
+ </rules>
+
+ <theme base="http://example.com">
+ <html><body>Dummy Content</body></html>
+ </theme>
+
+ <content>
+ <html><body>Real Content</body></html>
+ </content>
+
+ <output>
+ <html>
+ <body>
+ Dummy Content
+ <div class="deliverance-error">Deliverance error: no element found in content<br/>rule: <drop content="//div[@id='foo']"/>
+ </div>
+ </body>
+ </html>
+ </output>
+</deliverance-test>
+
<!-- dropping a tag that doesn't exist and ignoring errors
should squash error messages -->
More information about the z3-checkins
mailing list