/[papo]/gnue/designer/src/schema/Incubator.py
ViewVC logotype

Diff of /gnue/designer/src/schema/Incubator.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by styxman, Fri Nov 8 16:46:03 2002 UTC revision 1.4.4.1 by anthonyl, Tue Mar 4 22:11:41 2003 UTC
# Line 16  Line 16 
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19  # Copyright 2001-2002 Free Software Foundation  # Copyright 2001-2003 Free Software Foundation
20  #  #
21  # FILE:  # FILE:
22  # schema/Incubator.py  # schema/Incubator.py
# Line 29  Line 29 
29    
30  from gnue.common import GDebug  from gnue.common import GDebug
31  from gnue.common.schema import GSParser, Objects  from gnue.common.schema import GSParser, Objects
32  from gnue.designer.Incubator import *  from gnue.designer.base.Incubator import BaseIncubator
33    
34  def createObject(instance, schema, tag, type=None, parent=None,  class Incubator(BaseIncubator):
          parentHint=None, attributes={}):  
35    
36      elements = GSParser.getXMLelements()
37    
38    GDebug.printMesg(3,'Creating a "%s" object' % tag)    
   GDebug.printMesg(6,"Object's parent is %s" % parentHint)  
   
   try:  
     name = attributes['name']  
   except KeyError:  
     name = instance.getNextGenericName(tag)  
   
   try:  
     objclass = elements[tag]['BaseClass']  
     if elements[tag].has_key('Attributes'):  
       attrs = elements[tag]['Attributes']  
     else:  
       attrs = {}  
   except KeyError:  
     GDebug.printMesg(1, "Attempted to create a '%s', "  
                         "but I don't know what to do!" % tag)  
     return  
   
   
   parent = None  
   if tag in ('tables',):  
     parent = schema  
   
   o = objclass(parent or parentHint)  
   
   # Pull default values for any attributes not supplied  
   for attr in attrs.keys():  
     if not attributes.has_key(attr):  
       if attrs[attr].has_key('Default'):  
         attributes[attr] = attrs[attr]['Typecast'](attrs[attr]['Default'])  
   
   for attr in attributes.keys():  
     if attrs.has_key(attr):  
       o.__dict__[attr] = attributes[attr]  
   o.name = name  
   instance.nameMappings[o.name] = o  
   o._buildObject()  
   instance.onCreateObject(o, __name__)  
   instance.onSetCurrentObject(o, __name__)  
   return o  
   
   
 def reparentObject(instance, schema, object, newParent):  
   if object._parent == newParent:  
     return  
   
   # TODO  
   pass  
   
   
 def deleteObject(instance, schema, object, newCurrentObject=None, firstRun=1):  
   
   if firstRun:  
     newCurrentObject = object._parent  
     parent = object._parent  
   
   for child in object._children:  
     deleteObject(instance, schema, child, firstRun=0)  
   
   instance.onDeleteObject(object, __name__)  
   
   if firstRun:  
     o = parent  
     while not isinstance(o, Objects.GSSchema):  
       o._buildObject()  
       o = o._parent  
   
     if newCurrentObject:  
       instance.onSetCurrentObject(newCurrentObject, __name__)  
   
   
   
 #  
 # Figure out tag dependencies  
 #  
 elements = GSParser.getXMLelements()  
 elementMapping = {}  
 calcDependencies(elements, elementMapping)  
   

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.4.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26