[Formed-commits] r316 - in trunk: . formed/formed/io formed/formed/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Mar 16 14:21:38 CET 2009
Author: teichmann
Date: 2009-03-16 14:21:37 +0100 (Mon, 16 Mar 2009)
New Revision: 316
Modified:
trunk/ChangeLog
trunk/formed/formed/io/document.py
trunk/formed/formed/model/data.py
Log:
Added ConditionalNode.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-03-13 18:18:16 UTC (rev 315)
+++ trunk/ChangeLog 2009-03-16 13:21:37 UTC (rev 316)
@@ -1,3 +1,9 @@
+2009-03-16 Sascha L. Teichmann <teichmann at intevation.de>
+
+ * formed/formed/model/data.py: Added ConditionalNode
+
+ * formed/formed/io/document.py: Make ConditionalNode loadable.
+
2009-03-13 Sascha L. Teichmann <teichmann at intevation.de>
* formed/formed/plugins/modify/rules.py: Make the error descriptions
Modified: trunk/formed/formed/io/document.py
===================================================================
--- trunk/formed/formed/io/document.py 2009-03-13 18:18:16 UTC (rev 315)
+++ trunk/formed/formed/io/document.py 2009-03-16 13:21:37 UTC (rev 316)
@@ -37,6 +37,7 @@
TEXT_AREA_TAG = u"textarea"
RULE_TAG = u"rule"
REPEAT_TAG = u"repeat"
+CONDITIONAL_TAG = u"conditional"
namesToClasses = {
DOCUMENT_TAG: RootNode,
@@ -55,7 +56,9 @@
TEXT_AREA_TAG: TextAreaLeaf,
RULE_TAG: RuleLeaf,
REPEAT_TAG: RepeatNode,
- DATE_TAG: DateLeaf}
+ DATE_TAG: DateLeaf,
+ CONDITIONAL_TAG: ConditionalNode
+ }
factoryCreators = {
DOCUMENT_TAG: SimpleCreator(DocumentFactory, RootNode),
@@ -67,6 +70,7 @@
RADIO_TAG: SimpleCreator(NodeFactory, RadioNode),
CHOICE_TAG: SimpleCreator(NodeFactory, ChoiceNode),
REPEAT_TAG: SimpleCreator(NodeFactory, RepeatNode),
+ CONDITIONAL_TAG: SimpleCreator(NodeFactory, ConditionalNode),
EXT_CHOICE_LIST_TAG: SimpleCreator(NodeComponentFactory, ExternalChoiceListLeaf),
BOOL_TAG: SimpleCreator(NodeComponentFactory, BoolLeaf),
INT_TAG: SimpleCreator(NodeComponentFactory, IntLeaf),
@@ -76,24 +80,7 @@
RULE_TAG: SimpleCreator(NodeComponentFactory, RuleLeaf),
DATE_TAG: SimpleCreator(NodeComponentFactory, DateLeaf)}
-classesToTagNames = {
- RootNode: DOCUMENT_TAG,
- CaseNode: CASE_TAG,
- LogbookNode: LOGBOOK_TAG,
- PageNode: PAGE_TAG,
- GroupNode: GROUP_TAG,
- MatrixNode: MATRIX_TAG,
- RadioNode: RADIO_TAG,
- ChoiceNode: CHOICE_TAG,
- RepeatNode: REPEAT_TAG,
- IntLeaf: INT_TAG,
- InfoLeaf: INFO_TAG,
- TextLeaf: TEXT_TAG,
- TextAreaLeaf: TEXT_AREA_TAG,
- DateLeaf: DATE_TAG,
- ExternalChoiceListLeaf: EXT_CHOICE_LIST_TAG,
- RuleLeaf: RULE_TAG,
- BoolLeaf: BOOL_TAG }
+classesToTagNames = dict((v, k) for k, v in namesToClasses.iteritems())
def openDocument(path):
builder = SAXBuilder(path)
Modified: trunk/formed/formed/model/data.py
===================================================================
--- trunk/formed/formed/model/data.py 2009-03-13 18:18:16 UTC (rev 315)
+++ trunk/formed/formed/model/data.py 2009-03-16 13:21:37 UTC (rev 316)
@@ -83,6 +83,27 @@
self.visit(collector.visitor, mode, allModes)
return collector.widgets
+class ConditionalNode(GroupNode):
+
+ def __init__(self):
+ GroupNode.__init__(self)
+ self.attributes["expr"] = ""
+ self.expr = None
+
+ def setAttribute(self, attrib, value, broadcast=True):
+ if attrib == "expr":
+ newExpr = Expr(value)
+ newExpr.compile()
+ self.expr = newExpr
+ GroupNode.setAttribute(self, attrib, value, broadcast)
+
+ def setExpr(self, expr):
+ self.setAttribute('expr', expr)
+
+ def getExpr(self):
+ return self.expr
+
+
class RepeatNode(GroupNode):
def __init__(self):
Node.__init__(self)
More information about the Formed-commits
mailing list