commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue common/src/GParser.py forms/src/GFForm.py ...


From: James Thompson
Subject: gnue common/src/GParser.py forms/src/GFForm.py ...
Date: Mon, 04 Nov 2002 15:14:55 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     James Thompson <address@hidden> 02/11/04 15:14:55

Modified files:
        common/src     : GParser.py 
        forms/src      : GFForm.py GFParser.py 
        forms/src/uidrivers/wx: UIdriver.py 
        reports/src    : GRParser.py 

Log message:
        Added support for common based <import> tag based upon the tags marked 
as Importable
        Fixed bad function name in form's wx UI driver

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GParser.py.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.196&tr2=1.197&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFParser.py.diff?tr1=1.76&tr2=1.77&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/wx/UIdriver.py.diff?tr1=1.204&tr2=1.205&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRParser.py.diff?tr1=1.27&tr2=1.28&r1=text&r2=text

Patches:
Index: gnue/common/src/GParser.py
diff -c gnue/common/src/GParser.py:1.45 gnue/common/src/GParser.py:1.46
*** gnue/common/src/GParser.py:1.45     Mon Nov  4 09:55:51 2002
--- gnue/common/src/GParser.py  Mon Nov  4 15:14:54 2002
***************
*** 319,327 ****
    def _buildObject(self):
      if hasattr(self,'_xmltag'):
        self._type = 'GC%s' % self._xmltag
-       print self._type
      if not hasattr(self,'_importclass'):
-       print "Adding import class dude"
        self._importclass = self._xmlParser\
           .getXMLelements()[string.lower(self._type[9:])]['BaseClass']
      return GObj._buildObject(self)
--- 319,325 ----
***************
*** 375,382 ****
         return None
                                                     
  
  
! def buildImportableTags(elements):
      #
      # Scans xml elements and looks for Importable = 1
      # Items with this set can be imported
--- 373,408 ----
         return None
                                                     
  
+ class GImport(GObj):
+   def __init__(self, parent=None):
+     GObj.__init__(self, parent, type="GCImport")
+     self.library = ""
+     self._form = None
+     self._inits = [self.primaryInit]
+     self._xmlParser = self.findParentOfType(None)._xmlParser
+                   
+   def primaryInit(self):
+     handle = openResource(self.library)
+     form = self._xmlParser.loadFile(handle, self.findParentOfType(None)._app, 
initialize=0)
+     handle.close()
+ 
+     for attribute in self._loadedxmlattrs.keys():
+       if attribute != 'library':
+         importAll =  self._loadedxmlattrs[attribute] == "*"
+         importNames = 
string.split(string.replace(self._loadedxmlattrs[attribute],' ',''),',')
+ 
+         instanceType = 
self._xmlParser.getXMLelements()[string.lower(attribute)]['BaseClass']
+               
+         if importAll or len(importNames):
+           for child in form._children:
+             if isinstance(child,instanceType) and \
+                (importAll or child.name in importNames):
+               child._parent = self
+               child._IMPORTED = 1
+               self._children.append(child)
+               child._buildObject()
  
! def buildImportableTags(rootTag, elements):
      #
      # Scans xml elements and looks for Importable = 1
      # Items with this set can be imported
***************
*** 386,391 ****
--- 412,425 ----
      # (otherwise we don't know how to reference
      # it in the imported file).
      #
+     importElement = {'BaseClass': GImport,
+                      'Attributes': {'library': {
+                                       'Required': 1,
+                                       'Typecast': GTypecast.name },
+                                    },
+                      'ParentTags': rootTag,
+                      }
+     
      for key in elements.keys():
       if elements[key].has_key('Importable') and elements[key]['Importable']:
         name = "import-%s" % key
***************
*** 401,404 ****
--- 435,445 ----
         p['MixedContent'] = 0
         p['Required'] = 0
         elements[name] = p
+ 
+        importElement['Attributes'][key] =  {
+          'Typecast': GTypecast.name,
+          'Default': ""  }
+ 
+     if len(importElement['Attributes'].keys()):
+       elements['import'] = importElement
      return elements
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.196 gnue/forms/src/GFForm.py:1.197
*** gnue/forms/src/GFForm.py:1.196      Mon Nov  4 09:55:51 2002
--- gnue/forms/src/GFForm.py    Mon Nov  4 15:14:55 2002
***************
*** 158,168 ****
      # Initialize our events system
      events.EventAware.__init__(self, self._app.eventController)
  
- 
-     # TODO: Look at moving this into GParser
-     # Import all needed objects
-     self.walk(self.initImportedObjects)
- 
      self.initTriggerSystem()
      self._triggerns.update(self._triggerNamespaceTree._globalNamespace)
      # TODO: Is this right
--- 158,163 ----
***************
*** 323,405 ****
        GDebug.printMesg(1, "Trigger Error!")
        message = _("Trigger Exception :\n") + t.msg
      return message
- 
- 
-   def initImportedObjects(self, object):
-     if isinstance(object, GFLibrary.GFImport):
-       importAllDataSources = object.datasources == "*"
-       importAllPages = object.pages == "*"
-       importAllTriggers = object.triggers == "*"
-       importDataSources = string.split(string.replace(object.datasources,' 
',''),',')
-       importPages = string.split(string.replace(object.pages,' ',''),',')
-       importTriggers = string.split(string.replace(object.triggers,' 
',''),',')
- 
-       handle = openResource(object.library)
-       form = GFParser.loadFile(handle, self._app, initialize=0)
-       handle.close()
- 
-       if importAllDataSources or len(importDataSources):
-         for child in form._children:
-           if isinstance(child, GFDataSource) and \
-              (importAllDataSources or child.name in importDataSources):
-             child._parent = object
-             child._IMPORTED = 1
-             object._children.append(child)
-             child._buildObject()
- 
-       if importAllPages or len(importPages):
-         for child in form._children:
-           if isinstance(child, GFPage) and \
-              (importAllPages or child.name in importPages):
-             child._parent = object
-             child._IMPORTED = 1
-             object._children.append(child)
-             child._buildObject()
- 
-       if importAllTriggers or len(importTriggers):
-         for child in form._children:
-           if isinstance(child, GTrigger.GTrigger) and \
-              (importAllTriggers or child.name in importTriggers):
-             child._parent = object
-             child._IMPORTED = 1
-             object._children.append(child)
-             child._buildObject()
- 
- 
-     elif isinstance(object, GImportItem):
-       pass
- ##       handle = openResource(object.library)
- ##       form = GFParser.loadFile(handle, self._app, initialize=0)
- ##       handle.close()
- ##       id = 'id'
- ##       if hasattr(object,'name'):
- ##         id = 'name'
- 
- ##       rv = self.__findImportItem(object, form, id)
- ##       if rv != None:
- ##         rv._parent = object
- ##         rv._IMPORTED = 1
- ##         object._children.append(rv)
- ##         for key in object._loadedxmlattrs.keys():
- ##           if key[0] != '_':
- ##             rv.__dict__[key] = object._loadedxmlattrs[key]
- ##             GDebug.printMesg (5, ">>> Moving %s" % key)
- ##         rv._buildObject()
- 
- ##   def __findImportItem(self, find, object, id):
- ##     if isinstance(object, find._importclass) and \
- ##        hasattr(object, id) and \
- ##        object.__dict__[id] == find.__dict__[id]:
- ##       return object
- ##     elif hasattr(object,'_children'):
- ##       rv = None
- ##       for child in object._children:
- ##         rv = self.__findImportItem(find, child, id)
- ##         if rv:
- ##           break
- ##       return rv
- ##     else:
- ##       return None
  
    #
    # end of routines made for walking
--- 318,323 ----
Index: gnue/forms/src/GFParser.py
diff -c gnue/forms/src/GFParser.py:1.76 gnue/forms/src/GFParser.py:1.77
*** gnue/forms/src/GFParser.py:1.76     Mon Nov  4 09:55:51 2002
--- gnue/forms/src/GFParser.py  Mon Nov  4 15:14:55 2002
***************
*** 100,122 ****
                 'Default': 12 } },
           'ParentTags': None },
  
-       'import': {
-          'BaseClass': GFLibrary.GFImport,
-          'Attributes': {
-             'library': {
-                'Required': 1,
-                'Typecast': GTypecast.name },
-             'datasources': {
-                'Typecast': GTypecast.name,
-                'Default': "" },
-             'pages': {
-                'Typecast': GTypecast.name,
-                'Default': ""  },
-             'triggers': {
-                'Typecast': GTypecast.name,
-                'Default': "" } },
-          'ParentTags': ('form',) },
- 
        'database': {
           'BaseClass': GFObjects.GFDatabase,
           'Attributes': {
--- 100,105 ----
***************
*** 592,624 ****
                     'ParentTags': ('form',) },
                   }))
  
!     #
!     # Add importable elements
!     # If an object needs to be importable,
!     # simply add its tag name to the tuple below
!     # and make sure it has a "name" attribute
!     # (otherwise we don't know how to reference
!     # it in the imported file).
!     #
! #    if 0:
! #     for key in ('datasource','page','block','trigger','button','entry'):
! #      name = "import-%s" % key
! #      copy._deepcopy_dispatch[types.FunctionType] = copy._deepcopy_atomic
! #      copy._deepcopy_dispatch[types.ClassType] = copy._deepcopy_atomic
! #      copy._deepcopy_dispatch[type(int)] = copy._deepcopy_atomic
! #
! #      p = copy.deepcopy(xmlElements[key])
! #      p['BaseClass'] = GFLibrary.GFImportItem
! #      p['Attributes']['library'] = {
! #         'Required': 1,
! #         'Typecast': GTypecast.name }
! #      p['MixedContent'] = 0
! #      p['Required'] = 0
! #
! #      xmlElements[name] = p
! #      #print xmlElements.keys()
! #  # print GParser.buildImportableTags(xmlElements).keys()
!   return GParser.buildImportableTags(xmlElements)
  
  #
  # Different Types of Entries
--- 575,581 ----
                     'ParentTags': ('form',) },
                   }))
  
!   return GParser.buildImportableTags('form',xmlElements)
  
  #
  # Different Types of Entries
Index: gnue/forms/src/uidrivers/wx/UIdriver.py
diff -c gnue/forms/src/uidrivers/wx/UIdriver.py:1.204 
gnue/forms/src/uidrivers/wx/UIdriver.py:1.205
*** gnue/forms/src/uidrivers/wx/UIdriver.py:1.204       Mon Nov  4 14:22:39 2002
--- gnue/forms/src/uidrivers/wx/UIdriver.py     Mon Nov  4 15:14:55 2002
***************
*** 367,373 ****
      self.mainWindow.CenterOnScreen()
      self.mainWindow.Show(true)
      # Keep splash on top
!     if hasattrib(self,'splash'):
        self.splash.Raise()
  
  
--- 367,373 ----
      self.mainWindow.CenterOnScreen()
      self.mainWindow.Show(true)
      # Keep splash on top
!     if hasattr(self,'splash'):
        self.splash.Raise()
  
  
Index: gnue/reports/src/GRParser.py
diff -c gnue/reports/src/GRParser.py:1.27 gnue/reports/src/GRParser.py:1.28
*** gnue/reports/src/GRParser.py:1.27   Mon Nov  4 09:55:51 2002
--- gnue/reports/src/GRParser.py        Mon Nov  4 15:14:55 2002
***************
*** 269,275 ****
  
  
  
!   return GParser.buildImportableTags(xmlElements)
  
  
  #######################################################
--- 269,275 ----
  
  
  
!   return GParser.buildImportableTags('report',xmlElements)
  
  
  #######################################################




reply via email to

[Prev in Thread] Current Thread [Next in Thread]