[Formed-commits] r445 - in trunk: . formed/formed/io formed/formed/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue May 3 15:28:43 CEST 2011
Author: bricks
Date: 2011-05-03 15:28:39 +0200 (Tue, 03 May 2011)
New Revision: 445
Modified:
trunk/ChangeLog
trunk/formed/formed/io/document.py
trunk/formed/formed/model/data.py
Log:
Add ReferenceNode to be able to create and save references
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-15 08:05:37 UTC (rev 444)
+++ trunk/ChangeLog 2011-05-03 13:28:39 UTC (rev 445)
@@ -1,3 +1,13 @@
+2011-04-29 Björn Ricks <bjoern.ricks at intevation.de>
+
+ Add ReferenceNode to be able to create references
+
+ * formed/formed/model/data.py: Add ReferenceNode class derived
+ from NodeComponent
+ * formed/formed/io/document.py: Add creator for parsing ReferenceNodes
+ (_toXml): Handle ReferenceNodes like Leafs for saving to an xml
+ structure
+
2011-03-15 Roland Geider <roland.geider at intevation.de>
* formed/formed/plugins/export/xls.py: Generate correct XLS if there
Modified: trunk/formed/formed/io/document.py
===================================================================
--- trunk/formed/formed/io/document.py 2011-03-15 08:05:37 UTC (rev 444)
+++ trunk/formed/formed/io/document.py 2011-05-03 13:28:39 UTC (rev 445)
@@ -39,6 +39,7 @@
RULE_TAG = u"rule"
REPEAT_TAG = u"repeat"
CONDITIONAL_TAG = u"conditional"
+REFERENCE_TAG = u"reference"
namesToClasses = {
DOCUMENT_TAG: RootNode,
@@ -59,7 +60,8 @@
RULE_TAG: RuleLeaf,
REPEAT_TAG: RepeatNode,
DATE_TAG: DateLeaf,
- CONDITIONAL_TAG: ConditionalNode
+ CONDITIONAL_TAG: ConditionalNode,
+ REFERENCE_TAG: ReferenceNode
}
factoryCreators = {
@@ -81,7 +83,8 @@
TEXT_AREA_TAG: SimpleCreator(NodeComponentFactory, TextAreaLeaf),
TEXT_TAG: SimpleCreator(NodeComponentFactory, TextLeaf),
RULE_TAG: SimpleCreator(NodeComponentFactory, RuleLeaf),
- DATE_TAG: SimpleCreator(NodeComponentFactory, DateLeaf)}
+ DATE_TAG: SimpleCreator(NodeComponentFactory, DateLeaf),
+ REFERENCE_TAG: SimpleCreator(NodeComponentFactory, ReferenceNode)}
classesToTagNames = dict([(v, k) for k, v in namesToClasses.iteritems()])
@@ -118,7 +121,7 @@
out.append(_toXML(child, next_depth))
out.append(u"%s</%s>" % (indent, tagName))
return "\n".join(out)
- if isinstance(nc, Leaf):
+ if isinstance(nc, (Leaf, ReferenceNode)):
tagName = classesToTagNames.get(nc.__class__, "leaf")
return u"%s<%s%s/>" % (indent, tagName, _attributesToXML(nc))
if isinstance(nc, Document):
Modified: trunk/formed/formed/model/data.py
===================================================================
--- trunk/formed/formed/model/data.py 2011-03-15 08:05:37 UTC (rev 444)
+++ trunk/formed/formed/model/data.py 2011-05-03 13:28:39 UTC (rev 445)
@@ -326,5 +326,16 @@
def getTag(self):
return self.getAttribute("tag")
+class ReferenceNode(NodeComponent):
+ def __init__(self):
+ NodeComponent.__init__(self)
+ self.attributes["ref"] = ""
+
+ def setReference(self, ref):
+ self.setAttribute("ref", ref)
+
+ def getReference(self):
+ return self.getAttribute("ref")
+
# vim:set ts=4 sw=4 si et sta sts=4:
More information about the Formed-commits
mailing list