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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 6 14:39:57 CET 2009


Author: teichmann
Date: 2009-02-06 14:39:56 +0100 (Fri, 06 Feb 2009)
New Revision: 306

Modified:
   trunk/formed/formed/io/parser.py
   trunk/formed/formed/main.py
   trunk/formed/formed/model/nodecomponents.py
   trunk/formed/formed/plugins/export/xls.py
   trunk/formed/formed/plugins/web/help.py
   trunk/formed/formed/ui/controls.py
Log:
Make FormEd startable again.


Modified: trunk/formed/formed/io/parser.py
===================================================================
--- trunk/formed/formed/io/parser.py	2009-01-22 15:57:51 UTC (rev 305)
+++ trunk/formed/formed/io/parser.py	2009-02-06 13:39:56 UTC (rev 306)
@@ -10,8 +10,9 @@
 # Sascha L. Teichmann <teichmann at intevation.de>
 #
 
-from xml.sax.saxutils import DefaultHandler
+from xml.sax.handler import ContentHandler
 
+
 class Creator:
 
     def createFactory(tag, attrs, context):
@@ -36,7 +37,7 @@
     def reduce(self, context):
         return self.array
 
-class SAXBuilder(DefaultHandler):
+class SAXBuilder(ContentHandler):
 
     def __init__(self, context=None):
         self.context  = context

Modified: trunk/formed/formed/main.py
===================================================================
--- trunk/formed/formed/main.py	2009-01-22 15:57:51 UTC (rev 305)
+++ trunk/formed/formed/main.py	2009-02-06 13:39:56 UTC (rev 306)
@@ -569,7 +569,10 @@
     locName = str(wxLoc.GetName())
     lang = gettext.translation("formed", localedir, languages=[locName])
     lang.install()
-    locale.setlocale(locale.LC_ALL, locName)
+    try:
+        locale.setlocale(locale.LC_ALL, locName)
+    except locale.Error:
+        print >> sys.stderr, "unable to set locale '%s'" % locName
     buildGUI(argv).MainLoop()
 
 if __name__ == "__main__":

Modified: trunk/formed/formed/model/nodecomponents.py
===================================================================
--- trunk/formed/formed/model/nodecomponents.py	2009-01-22 15:57:51 UTC (rev 305)
+++ trunk/formed/formed/model/nodecomponents.py	2009-02-06 13:39:56 UTC (rev 306)
@@ -365,15 +365,23 @@
     def __init__(self, root=None):
         Publisher.__init__(self)
         if root is None: 
-            self.root = RootNode()
-            self.case = self.root.addChild(CaseNode())
-            self.logbook = self.root.addChild(LogbookNode())
+            self.root = RootNode(self)
+            self.case = CaseNode() 
+            self.root.addChild(self.case)
+            self.logbook = LogbookNode()
+            self.root.addChild(self.logbook)
         else:
             self.root = root
             self.case = self.findByClassAndName(CaseNode)
             self.logbook = self.findByClassAndName(LogbookNode)
             self.root.document = self
 
+    def getCase(self):
+        if not self.case:
+            self.case = CaseNode()
+            self.root.addChild(self.case)
+        return self.case
+
     def importDocument(self, ndocument):
         root, nroot = self.root, ndocument.root
         if not root or not nroot: return

Modified: trunk/formed/formed/plugins/export/xls.py
===================================================================
--- trunk/formed/formed/plugins/export/xls.py	2009-01-22 15:57:51 UTC (rev 305)
+++ trunk/formed/formed/plugins/export/xls.py	2009-02-06 13:39:56 UTC (rev 306)
@@ -23,8 +23,6 @@
 from cgi import escape
 from time import gmtime, strftime
 
-from pyExcelerator import Workbook
-
 XLS_HEADER = \
 '''%s
 '''
@@ -305,6 +303,7 @@
 class Book:
     
     def __init__(self):
+        from pyExcelerator import Workbook
         self.workbook = Workbook()
 
     def addSheet(self, title):

Modified: trunk/formed/formed/plugins/web/help.py
===================================================================
--- trunk/formed/formed/plugins/web/help.py	2009-01-22 15:57:51 UTC (rev 305)
+++ trunk/formed/formed/plugins/web/help.py	2009-02-06 13:39:56 UTC (rev 306)
@@ -12,10 +12,13 @@
 
 from xml.dom.minidom import parseString
 
-from xml.dom.ext     import Print
+#from xml.dom.ext     import Print
 
 from cStringIO       import StringIO
 
+def Print(div, out, encoding):
+    print >> sys.stderr, "help.py(Print): not implemented yet"
+
 class HelpProvider:
 
     def __init__(self, xhtml):

Modified: trunk/formed/formed/ui/controls.py
===================================================================
--- trunk/formed/formed/ui/controls.py	2009-01-22 15:57:51 UTC (rev 305)
+++ trunk/formed/formed/ui/controls.py	2009-02-06 13:39:56 UTC (rev 306)
@@ -151,6 +151,7 @@
         print "OnTreeItemActivated"
 
     def _label(self, nc):
+        if not nc: return ""
         n = nc.getName()
         if n is None: prefix = ""
         else:         prefix = n + " - "
@@ -181,7 +182,7 @@
 
     def _buildTree(self):
         #root = self.document.root
-        root = self.document.case
+        root = self.document.getCase()
         rootId = self.AddRoot(self._label(root))
         self.SetItemPyData(rootId, root)
         self.SetItemHasChildren(rootId, True)
@@ -269,12 +270,12 @@
         selectedId = self.GetSelection()
         if not selectedId or not selectedId.IsOk():
             document = self.document
-            if document: document.case.addChild(child)
+            if document: document.getCase().addChild(child)
             return
         selected = self.GetItemPyData(selectedId)
         if not selected:
             document = self.document
-            if document: document.case.addChild(child)
+            if document: document.getCase().addChild(child)
             return
         if isinstance(selected, CaseNode):
             selected.addChild(child)
@@ -282,12 +283,12 @@
         parent = selected.parent
         if not parent:
             document = self.document
-            if document: document.case.addChild(child)
+            if document: document.getCase().addChild(child)
             return
         idx = parent.indexOfChild(selected)
         if idx < 0:
             document = self.document
-            if document: document.case.addChild(child)
+            if document: document.getCase().addChild(child)
             return
         parent.addChild(child, idx+1)
 



More information about the Formed-commits mailing list