[Formed-commits] r370 - in trunk: . formed/formed formed/formed/io formed/formed/model formed/formed/plugins/export formed/formed/plugins/web

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jul 21 16:54:11 CEST 2010


Author: torsten
Date: 2010-07-21 16:54:10 +0200 (Wed, 21 Jul 2010)
New Revision: 370

Modified:
   trunk/ChangeLog
   trunk/formed/formed/config.py
   trunk/formed/formed/io/document.py
   trunk/formed/formed/model/data.py
   trunk/formed/formed/plugins/export/new_sql.py
   trunk/formed/formed/plugins/web/view_renderer.py
Log:
Issue851


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-07-21 14:51:51 UTC (rev 369)
+++ trunk/ChangeLog	2010-07-21 14:54:10 UTC (rev 370)
@@ -6,6 +6,14 @@
 	all headers to the referenced fields. Only list labels of the error
 	fields, which should be distinct enough.
 
+	Issue851
+
+	* formed/formed/model/data.py
+	  formed/formed/plugins/export/new_sql.py
+	  formed/formed/plugins/web/view_renderer.py
+	  formed/formed/io/document.py
+	  formed/formed/config.py: Added Float-Field to Formed
+
 2010-06-11  Bernhard Herzog  <bh at intevation.de>
 
 	* formed/formed/plugins/export/rg_sql.py

Modified: trunk/formed/formed/config.py
===================================================================
--- trunk/formed/formed/config.py	2010-07-21 14:51:51 UTC (rev 369)
+++ trunk/formed/formed/config.py	2010-07-21 14:54:10 UTC (rev 370)
@@ -19,6 +19,7 @@
 from formed.plugins.export.latex   import ExportAsLaTeXFilter
 from formed.plugins.export.html    import ExportAsHTMLFilter
 from formed.plugins.export.html2   import ExportAsHTMLFilter2
+from formed.plugins.export.html3   import ExportAsHTMLFilter3
 from formed.plugins.export.typemap import ExportAsTypeDict
 from formed.plugins.export.diff    import ExportDiffAsHTMLFilter
 from formed.plugins.export.mode    import ModeExportFilter
@@ -56,6 +57,7 @@
             ExportAsLaTeXFilter(),
             ExportAsHTMLFilter(),
             ExportAsHTMLFilter2(),
+            ExportAsHTMLFilter3(),
             ExportDiffAsHTMLFilter(),
             ExportAsTypeDict(),
             ExportAsSQLFilter(),

Modified: trunk/formed/formed/io/document.py
===================================================================
--- trunk/formed/formed/io/document.py	2010-07-21 14:51:51 UTC (rev 369)
+++ trunk/formed/formed/io/document.py	2010-07-21 14:54:10 UTC (rev 370)
@@ -29,6 +29,7 @@
 RADIO_TAG           = u"radio"
 BOOL_TAG            = u"bool"
 INT_TAG             = u"int"
+FLOAT_TAG           = u"float"
 INFO_TAG            = u"info"
 TEXT_TAG            = u"text"
 CHOICE_TAG          = u"choice"
@@ -51,6 +52,7 @@
     CHOICE_TAG:          ChoiceNode,
     EXT_CHOICE_LIST_TAG: ExternalChoiceListLeaf,
     INT_TAG:             IntLeaf,
+    FLOAT_TAG:           FloatLeaf,
     INFO_TAG:            InfoLeaf,
     TEXT_TAG:            TextLeaf,
     TEXT_AREA_TAG:       TextAreaLeaf,
@@ -74,6 +76,7 @@
     EXT_CHOICE_LIST_TAG: SimpleCreator(NodeComponentFactory, ExternalChoiceListLeaf),
     BOOL_TAG:            SimpleCreator(NodeComponentFactory, BoolLeaf),
     INT_TAG:             SimpleCreator(NodeComponentFactory, IntLeaf),
+    FLOAT_TAG:           SimpleCreator(NodeComponentFactory, FloatLeaf),
     INFO_TAG:            SimpleCreator(NodeComponentFactory, InfoLeaf),
     TEXT_AREA_TAG:       SimpleCreator(NodeComponentFactory, TextAreaLeaf),
     TEXT_TAG:            SimpleCreator(NodeComponentFactory, TextLeaf),

Modified: trunk/formed/formed/model/data.py
===================================================================
--- trunk/formed/formed/model/data.py	2010-07-21 14:51:51 UTC (rev 369)
+++ trunk/formed/formed/model/data.py	2010-07-21 14:54:10 UTC (rev 370)
@@ -269,6 +269,9 @@
     def setMaxValue(self, maxValue):
         self.setAttribute("maxvalue", maxValue)
 
+class FloatLeaf(IntLeaf):
+    pass
+
 class DateLeaf(Leaf):
     def __init__(self):
         Leaf.__init__(self)

Modified: trunk/formed/formed/plugins/export/new_sql.py
===================================================================
--- trunk/formed/formed/plugins/export/new_sql.py	2010-07-21 14:51:51 UTC (rev 369)
+++ trunk/formed/formed/plugins/export/new_sql.py	2010-07-21 14:54:10 UTC (rev 370)
@@ -391,6 +391,14 @@
         table.appendColumn(Column(name, "INTEGER", func=integer.getFunction()))
 
     @modeCheck
+    def _createFloat(self, float):
+        name = float.getName()
+        if not name: return
+        name = sqlName(name)
+        table = self.tableStack[-1]
+        table.appendColumn(Column(name, "NUMERIC", func=float.getFunction()))
+
+    @modeCheck
     def _createChoice(self, choice):
         name = choice.getName()
         if not name: return
@@ -556,7 +564,9 @@
     @modeCheck
     def _createChild(self, child):
         if isinstance(child, Leaf):
-            if isinstance(child, data.IntLeaf):
+            if isinstance(child, data.FloatLeaf):
+                self._createFloat(child)
+            elif isinstance(child, data.IntLeaf):
                 self._createInteger(child)
             elif isinstance(child, data.DateLeaf):
                 self._createDate(child)

Modified: trunk/formed/formed/plugins/web/view_renderer.py
===================================================================
--- trunk/formed/formed/plugins/web/view_renderer.py	2010-07-21 14:51:51 UTC (rev 369)
+++ trunk/formed/formed/plugins/web/view_renderer.py	2010-07-21 14:54:10 UTC (rev 370)
@@ -79,7 +79,7 @@
 
     def render(self):
         if self.items:
-            out = ['<div class="w100">']
+            out = ['<div class="container">']
             f = 1.0/reduce(lambda x, y: x + y[1], self.items, 0)
             ws = [f*w[1] for w in self.items]
             target = self.target
@@ -181,7 +181,7 @@
         name        = node.getName()
 
         help        = self.formdata.getHelp(name)
-        data        = self.formdata.getData(name)
+        data2        = self.formdata.getData(name)
         error       = self.formdata.getError(name)
         legend      = []
 
@@ -214,19 +214,24 @@
                     out.append("<th>%s</th>" % header )
                 out.append("</tr>")
                 # write table body 
-                for row in node.children:
-                    out.append("<tr>")
-                    out.append('<td class="formed-radiomatrix-label">%s</td>' % row.getDescription())
-                    self.stateStack.append(self.formdata.getData(row.getName()))
-                    for col in row.children:
-                        out.append("<td>%s</td>" % self._renderRadioMatrixBool(col))
-                    self.stateStack.pop()
-                    out.append("</tr>")
-                # write legend
-                if legend:
-                    out.append('<tr><td colspan=%s><div class="formed-radiomatrix-legend">%s</div></td></tr>' % (len(node.children[0].children)+1, ", ".join(legend)))
+                try:
+                    for row in node.children:
+                        if not isinstance(row, data.RuleLeaf):
+                            out.append("<tr>")
+                            out.append('<td class="formed-radiomatrix-label">%s</td>' % row.getDescription())
+                            self.stateStack.append(self.formdata.getData(row.getName()))
+                            for col in row.children:
+                                out.append("<td>%s</td>" % self._renderRadioMatrixBool(col))
+                            self.stateStack.pop()
+                            out.append("</tr>")
+                    # write legend
+                    if legend:
+                        out.append('<tr><td colspan=%s><div class="formed-radiomatrix-legend">%s</div></td></tr>' % (len(node.children[0].children)+1, ", ".join(legend)))
+                except StandardError, err:
+                    print err
+                    pass
                 out.append("</table>")
-            except:
+            except StandardError, err:
                 pass
         self.toTarget(Item("".join(out)), node.getTarget())
         #self.toTarget(Text('<br class="newline">\n'), node.getTarget())



More information about the Formed-commits mailing list