/[papo]/gnue/designer/src/TemplateBase.py
ViewVC logotype

Diff of /gnue/designer/src/TemplateBase.py

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

revision 1.5 by charlie, Tue Aug 27 18:15:52 2002 UTC revision 1.6 by styxman, Fri Nov 8 16:46:03 2002 UTC
# Line 1  Line 1 
1  #  #
 # Copyright 2001 Free Software Foundation  
 #  
2  # This file is part of GNU Enterprise.  # This file is part of GNU Enterprise.
3  #  #
4  # GNU Enterprise is free software; you can redistribute it  # GNU Enterprise is free software; you can redistribute it
# Line 18  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
20    #
21  # FILE:  # FILE:
22  # TemplateBase.py  # TemplateBase.py
23  #  #
# Line 46  Line 46 
46  #   been trademarked. (No, I'm not kidding :)  #   been trademarked. (No, I'm not kidding :)
47    
48  from gnue.common import GTypecast  from gnue.common import GTypecast
49  from gnue.forms import GFParser  from gnue.common.GParserHelpers import GContent
 import Incubator  
50    
51  #  #
52  # These Identify the types of templates. A template  # These Identify the types of templates. A template
# Line 77  WIZARD=1        # This is a template tha Line 76  WIZARD=1        # This is a template tha
76  class TemplateBase:  class TemplateBase:
77    
78    ##########################################    ##########################################
79    #    #
80    #  The following few methods should be    #  The following few methods should be
81    #  subclassed by the template developer.    #  subclassed by the template developer.
82    
83    # The first step in our wizard    # The first step in our wizard
# Line 114  class TemplateBase: Line 113  class TemplateBase:
113    #  The following methods are convenience    #  The following methods are convenience
114    #  methods.    #  methods.
115    
116    def AddElement(self, tag, parent, attributes={}):    def AddElement(self, tag, parent, attributes={}, content=""):
117      o = self.parser.elements[tag]['BaseClass'](parent)      o = self.parser.elements[tag]['BaseClass'](parent)
118      for attr in attributes.keys():      o.__dict__.update(attributes)
119        o.__dict__[attr] = attributes[attr]      if content:
120          self.SetContent(o, content)
121        o._buildObject()
122        self.parser.instance.onCreateObject(o, __name__)
123      return o      return o
124    
125    
126      def SetContent(self, element, content):
127        i = 0
128        while i < len(element._children):
129          if element._children[i]._type == '_content_':
130            element._children.pop(i)
131          else:
132            i += 1
133        content = GContent(element,content)
134    
135    
136      def ModifyElement(self, element, **modifications):
137        element.__dict__.update(modifications)
138        mods = []
139        for attr in modifications.keys():
140          mods.append((attr, modifications[attr]))
141        self.parser.instance.onModifyObject(element, __name__, mods)
142    
143    
144    def GetAvailableConnections(self):    def GetAvailableConnections(self):
145      rv = []      rv = []
146      p = self._connections.getAllConnectionParameters()      p = self._connections.getAllConnectionParameters()
# Line 132  class TemplateBase: Line 152  class TemplateBase:
152      return rv      return rv
153    
154    
155    def GetTemporaryConnection(self, connection_name):    def GetTemporaryConnection(self, connection_name):
156    
157      if not self.__cachedConnections.has_key(connection_name):      if not self.__cachedConnections.has_key(connection_name):
158        self.__cachedConnections[connection_name] = \        self.__cachedConnections[connection_name] = \
159           self._connections.getDataObject(connection_name, 'object')           self._connections.getDataObject(connection_name, 'object')
160        self.__cachedConnections[connection_name].database = connection_name        self.__cachedConnections[connection_name].database = connection_name
# Line 189  class TemplateBase: Line 209  class TemplateBase:
209    
210  ###########################################################  ###########################################################
211  #  #
 # Base class for a form template  
 #  
 ###########################################################  
 class FormTemplate(TemplateBase):  
   
   # Initialize user code  
   def Start(self, form):  
     pass  
   
   
 ###########################################################  
 #  
 # Base class for a report template  
 #  
 ###########################################################  
 class ReportTemplate(TemplateBase):  
   
   # Initialize user code  
   def Start(self, report):  
     pass  
   
   
 ###########################################################  
 #  
212  # Wizard elements  # Wizard elements
213  #  #
214  ###########################################################  ###########################################################
215  class WizardPage:  class WizardPage:
216    
217    _ELEMENTS = GFParser.getXMLelements()  ##  _ELEMENTS = GFParser.getXMLelements()
218    
219    def __init__(self, variables):    def __init__(self, variables):
220      self.variables = variables      self.variables = variables
# Line 254  class WizardInput (WizardItem): Line 250  class WizardInput (WizardItem):
250      self.lowerbound = lowerbound      self.lowerbound = lowerbound
251      self.upperbound = upperbound      self.upperbound = upperbound
252      self.forceupper = forceupper      self.forceupper = forceupper
253        self.required = required
254      self.forcelower = forcelower      self.forcelower = forcelower
255      self.lines = lines      self.lines = lines
     required = required  
256    
257      # The following only have an effect is set != None      # The following only have an effect is set != None
258      self.maxSelections = maxSelections      self.maxSelections = maxSelections
259      self.orderable = orderable      self.orderable = orderable
260    
261    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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