commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/GDataSource.py common/src/dbdri...


From: Jason Cater
Subject: gnue common/src/GDataSource.py common/src/dbdri...
Date: Thu, 25 Jul 2002 01:36:09 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/07/25 01:36:08

Modified files:
        common/src     : GDataSource.py 
        common/src/dbdrivers/_static: DBdriver.py 
        designer/src/forms/wizards: AddDropDown.py AddPage.py 

Log message:
        more work on the Add Dropdown wizard (THIS IS NOT WORKING YET! HAVING 
MOUSE ISSUES!)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GDataSource.py.diff?cvsroot=OldCVS&tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/dbdrivers/_static/DBdriver.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/forms/wizards/AddDropDown.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/forms/wizards/AddPage.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/common/src/GDataSource.py
diff -c gnue/common/src/GDataSource.py:1.36 gnue/common/src/GDataSource.py:1.37
*** gnue/common/src/GDataSource.py:1.36 Wed Jul  3 11:58:32 2002
--- gnue/common/src/GDataSource.py      Thu Jul 25 01:36:08 2002
***************
*** 303,308 ****
--- 303,325 ----
  
  ######
  #
+ #
+ #
+ ######
+ class GStaticSet(GObjects.GObj):
+   def __init__(self, parent=None):
+      GObjects.GObj(self, parent, type="GDStaticSet")
+ 
+ class GStaticSetRow(GObjects.GObj):
+   def __init__(self, parent=None):
+      GObjects.GObj(self, parent, type="GDStaticSetRow")
+ 
+ class GStaticSetField(GObjects.GObj):
+   def __init__(self, parent=None):
+      GObjects.GObj(self, parent, type="GDStaticSetField")
+ 
+ ######
+ #
  # Used by client GParsers to automatically pull supported xml tags
  #
  ######
***************
*** 346,351 ****
--- 363,383 ----
              'detaillink':  {
                 'Typecast': GTypecast.text } },
           'ParentTags': None },
+       'staticset': {
+          'BaseClass': GStaticSet,
+          'SingleInstance': 1,
+          'Attributes': {
+             'fields':        {
+                'Typecast': GTypecast.text,
+                'Required': 1 } },
+          'ParentTags': ('datasource',) },
+       'staticsetrow': {
+          'BaseClass': GStaticSetRow,
+          'SingleInstance': 1,
+          'ParentTags': ('staticset',) },
+       'staticsetfield': {
+          'BaseClass': GStaticSetField,
+          'ParentTags': ('staticsetrow',) },
    }
  
    # Add conditional elements
Index: gnue/common/src/dbdrivers/_static/DBdriver.py
diff -c gnue/common/src/dbdrivers/_static/DBdriver.py:1.3 
gnue/common/src/dbdrivers/_static/DBdriver.py:1.4
*** gnue/common/src/dbdrivers/_static/DBdriver.py:1.3   Mon Sep 17 16:36:57 2001
--- gnue/common/src/dbdrivers/_static/DBdriver.py       Thu Jul 25 01:36:08 2002
***************
*** 16,22 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # Copyright 2001 Free Software Foundation
  #
  # FILE:
  # _static/DBdriver.py
--- 16,22 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # Copyright 2001-2002 Free Software Foundation
  #
  # FILE:
  # _static/DBdriver.py
***************
*** 30,36 ****
  
  from gnue.common import GDebug
  import string
! from gnue.common.GDataObjects import * 
  
  
  ###########################################################
--- 30,36 ----
  
  from gnue.common import GDebug
  import string
! from gnue.common.GDataObjects import *
  
  
  ###########################################################
***************
*** 40,54 ****
  ###########################################################
  class STATIC_DataObject (DataObject): 
  
!   def __init__(self): 
      DataObject.__init__(self)
      self.triggerExtensions = TriggerExtensions(self)
  
!   def _createResultSet(self, conditions={}, readOnly=0, 
masterRecordSet=None): 
      return STATIC_ResultSet(self, masterRecordSet=masterRecordSet)
  
    # We don't do logins
!   def getLoginFields(self): 
      return ()
  
    # We don't do connections (we are connectionless)
--- 40,54 ----
  ###########################################################
  class STATIC_DataObject (DataObject): 
  
!   def __init__(self):
      DataObject.__init__(self)
      self.triggerExtensions = TriggerExtensions(self)
  
!   def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
      return STATIC_ResultSet(self, masterRecordSet=masterRecordSet)
  
    # We don't do logins
!   def getLoginFields(self):
      return ()
  
    # We don't do connections (we are connectionless)
***************
*** 67,84 ****
  
  ###########################################################
  #
! # 
! # 
  ###########################################################
! class STATIC_ResultSet(ResultSet): 
  
!   def __init__(self, dataObject, cursor=None, defaultValues={}, 
masterRecordSet=None): 
      ResultSet.__init__(self, dataObject, \
              cursor, defaultValues, masterRecordSet)
      self._recordSetClass = STATIC_RecordSet
  
  
!   # Returns 1=DataObject has uncommitted changes 
    def isPending(self):
      return 0    # Static DataObjects cannot have pending changes :)
  
--- 67,84 ----
  
  ###########################################################
  #
! #
! #
  ###########################################################
! class STATIC_ResultSet(ResultSet):
  
!   def __init__(self, dataObject, cursor=None, defaultValues={}, 
masterRecordSet=None):
      ResultSet.__init__(self, dataObject, \
              cursor, defaultValues, masterRecordSet)
      self._recordSetClass = STATIC_RecordSet
  
  
!   # Returns 1=DataObject has uncommitted changes
    def isPending(self):
      return 0    # Static DataObjects cannot have pending changes :)
  
***************
*** 86,92 ****
    def post(self):
      # Leave this here in case (for some bizarro reason)
      # a bound dataobject uses us as a master
!     for record in (self._cachedRecords): 
        record.post()
  
    # Returns 1=Field is bound to a database field
--- 86,92 ----
    def post(self):
      # Leave this here in case (for some bizarro reason)
      # a bound dataobject uses us as a master
!     for record in (self._cachedRecords):
        record.post()
  
    # Returns 1=Field is bound to a database field
***************
*** 94,100 ****
      return 0
  
    # Load cacheCount number of new records
!   def _loadNextRecord(self): 
      return 0
  
  
--- 94,100 ----
      return 0
  
    # Load cacheCount number of new records
!   def _loadNextRecord(self):
      return 0
  
  
***************
*** 130,145 ****
  
  ######################################
  #
! #  The following hashes describe 
  #  this driver's characteristings.
  #
  ######################################
  
  #
  #  All datasouce "types" and corresponding DataObject class
! # 
! supportedDataObjects = { 
!   'object': STATIC_DataObject
  }
  
  
--- 130,145 ----
  
  ######################################
  #
! #  The following hashes describe
  #  this driver's characteristings.
  #
  ######################################
  
  #
  #  All datasouce "types" and corresponding DataObject class
! #
! supportedDataObjects = {
!   'static': STATIC_DataObject
  }
  
  
Index: gnue/designer/src/forms/wizards/AddDropDown.py
diff -c gnue/designer/src/forms/wizards/AddDropDown.py:1.3 
gnue/designer/src/forms/wizards/AddDropDown.py:1.4
*** gnue/designer/src/forms/wizards/AddDropDown.py:1.3  Mon Jul 22 19:04:59 2002
--- gnue/designer/src/forms/wizards/AddDropDown.py      Thu Jul 25 01:36:08 2002
***************
*** 22,28 ****
  # forms/wizards/AddDropdown.py
  #
  # DESCRIPTION:
! # Implements a basic form template
  #
  # NOTES:
  # While functional, the primary purpose of this wizard is
--- 22,28 ----
  # forms/wizards/AddDropdown.py
  #
  # DESCRIPTION:
! # Add a dropdown entry to a form, creating any datasources if necessary.
  #
  # NOTES:
  # While functional, the primary purpose of this wizard is
***************
*** 36,53 ****
  #
  # Steps
  #
! # 0. Get Title             Goto step 1
! # 1. Select Connection     Goto step 2
! # 2. Select Table          Goto step 3
! # 3. Select Fields         Goto step 4 or 7
! # 4. Select Master         Goto step 5
! # 5. Select Master Keys    Goto step 6
! # 6. Select Detail Keys    Goto step 7
! # 7. Add another?          Goto step 1,2, or 8
! # 8. Complete.
  #
  
- 
  class AddDropDownWizard(FormPrePositioningTemplate):
  
  
--- 36,46 ----
  #
  # Steps
  #
! # 0. Get id/field/[Existing Datasource/New Datasource /Static Set]
! # 1. Select / create datasource
! # 2. Select key field + description field
  #
  
  class AddDropDownWizard(FormPrePositioningTemplate):
  
  
***************
*** 76,105 ****
    #
    # Return the markup for a specific page
    #
!   def GetStep(self, step):
  
!     # 0 - Get name / Source (existing datasource, new 
!     #     bound datasource, fixed set of choices)
!     # 1 - Select / Create Source
  
  
      #
!     # Step #0 / Get Name
      #
!     if step == '0':
  
!       content = [WizardText('This will insert a new dropdown-style entry.'),
!                  WizardInput('name',label='Object Name:',required=1,size=20)]
  
-       if hasattr(self.form,'tabbed') and self.form.tabbed:
-         content.append(WizardInput('caption', label='Tab Caption: ', 
required=1,
-                                           size=20))
  
!       return   { 'title': 'Add Dropdown-style Entry',
!                  'content': content,
!                  'prev': None,
                   'next': None }
  
  
  
    ###############
--- 69,203 ----
    #
    # Return the markup for a specific page
    #
!   def GetStep(self, stepCode):
! 
!     if stepCode == '1':
!       if self.variables['datasource'] == sourcesOfData[0]:
!         stepCode = '1:new'
!       elif self.variables['datasource'] == sourcesOfData[1]:
!         stepCode = '1:reuse'
!       else:
!         stepCode = '1:fixed'
! 
!     #
!     # Step #1 / Get Title, et al
!     #
!     if stepCode == '0':
  
!       if self.__firstConnection:
!         self.variables['connection'] == self.__firstConnection
  
+       return   { 'title': 'Add Dropdown Entry',
+                  'content': (WizardText('To create your dropdown, I need to 
know some basic information. \n'
+                                         'First, what field will store the 
dropdown\'s value?'),
+                              WizardInput('name', label='Field name:', 
required=1,
+                                          size=40),
+                              WizardText('Where will this dropdown pull its 
data?'),
+                              WizardInput('datasource', label='Source:', 
required=1,
+                                          maxSelections=-1, orderable=1,
+                                          set=((0,'Create a new datasource'),
+                                               (1,'Use an existing 
datasource'),
+                                               (2,'Specify a static list of 
valid choices' )))
+                             ),
+                  'prev': None,
+                  'next': '1' }
  
      #
!     # Step #2 [New Datasource] / Get Connection
      #
!     elif stepCode == '1:new':
!       return   { 'title': 'Datasource Connection',
!                  'content': (WizardText('What connection should this form use 
to connect to the \ndatabase?'),
!                              WizardInput('connection',label='Connection:', 
required=1,
!                                          set=self.GetAvailableConnections()),
!                              WizardText('You may be asked to login to this 
connection.')),
!                  'prev': '0',
!                  'next': '2:new' }
  
!     #
!     # Step #3 [New Datasource] / Get Table
!     #
!     elif stepCode == '2:new':
!       return   { 'title': 'Select Validator Table/Source',
!                  'content': (WizardText('Now, please select the table the 
dropdown will\nuse to populate its data set.'),
!                              WizardInput('table', label='Table:', required=1, 
lines=5,
!                                          
set=self.GetAvailableSources(self.variables['connection'])), ),
!                  'prev': '1:new',
!                  'next': '3:new' }
  
  
!     #
!     # Step #4 [New Datasouce] / Get key/description fields
!     #
!     elif stepCode == '3:new':
! 
!       return   { 'title': 'Select Key/Description fields',
!                  'content': (WizardText('Which field will be the "key"? 
(i.e., which\nfield contains the value that will\nbe stored in the database?)'),
!                              WizardInput('key', label='Key Field:', 
required=1,
!                                          maxSelections=1,
!                                          set=self.GetAvailableFields( \
!                                                 self.variables['connection'],
!                                                 self.variables['table'])),
!                              WizardText('Which field will be the 
"description" value?'),
!                              WizardInput('descr', label='Description:', 
required=1,
!                                          maxSelections=1,
!                                          set=self.GetAvailableFields( \
!                                                 self.variables['connection'],
!                                                 self.variables['table']))),
!                  'prev': '2:new',
                   'next': None }
  
+     #
+     # Step #2 [reuse Datasource] / Get DataSource
+     #
+     elif stepCode == '1:reuse':
+       return   { 'title': 'Datasource Connection',
+                  'content': (WizardText('What connection should this form use 
to connect to the \ndatabase?'),
+                              WizardInput('connection',label='Connection:', 
required=1,
+                                          set=self.__GetExistingDatasources()),
+                              WizardText('You may be asked to login to this 
connection.')),
+                  'prev': '0',
+                  'next': '2:reuse' }
+ 
+     #
+     # Step #3 [Reuse Datasouce] / Get key/description fields
+     #
+     elif stepCode == '2:reuse':
+ 
+       datasource = self.__datasourceMap[self.variables['source']]
+ 
+ 
+       return   { 'title': 'Select Key/Description fields',
+                  'content': (WizardText('Which field will be the "key"? 
(i.e., which\nfield contains the value that will\nbe stored in the database?)'),
+                              WizardInput('key', label='Key Field:', 
required=1,
+                                          maxSelections=1,
+                                          set=self.GetAvailableFields( \
+                                                 datasource.database,
+                                                 datasource.table)),
+                              WizardText('Which field will be the 
"description" value?'),
+                              WizardInput('descr', label='Description:', 
required=1,
+                                          maxSelections=1,
+                                          set=self.GetAvailableFields( \
+                                                 datasource.database,
+                                                 datasource.table))),
+                  'prev': '1:reuse',
+                  'next': None }
+ 
+ 
+     #
+     # Step #2 [Static set] / Get Data Set
+     #
+     elif stepCode == '1:fixed':
+ 
+       return   { 'title': 'Enter data set',
+                  'content': (WizardText('Please enter the values the dropdown 
box\nshould use. Enter in the format: val1:Display1|val2:display2|...\n(For 
example, Y:Yes|N:No|M:Maybe'),
+                              WizardInput('dataset', label='Data Set:', 
required=1, lines=5,
+                                          size=40) ),
+                  'prev': '0',
+                  'next': None }
+ 
+ 
+ 
  
  
    ###############
***************
*** 110,118 ****
    #
    def ValidateStep(self, stepCode):
  
!     # The Simple wizard uses basic "required"
!     # settings in the page markup, so doesn't
!     # need any special validation.
      return None
  
  
--- 208,214 ----
    #
    def ValidateStep(self, stepCode):
  
!     # TODO: This should validate step 1:fixed to verify the dataset is valid
      return None
  
  
***************
*** 125,140 ****
    #
    def Finalize(self):
  
!     attrs = {'name': self.variables['name'] or 'Dropdown_1'}
  
!     try:
!       attrs['caption'] = self.variables['caption'] or 'New Tab'
!     except KeyError:
!       pass
  
-     page = self.AddElement('page', self.form, attrs)
  
      return 1
  
  
  
--- 221,304 ----
    #
    def Finalize(self):
  
!     #
!     # Set up or retrieve our datasource
!     #
  
!     # Create new datasource
!     if self.variables['datasource'] == 0:
!       datasource = self.AddElement('datasource', self.form,
!         { 'name': "dtsDrp_%s_%s" % (self.variables['table'],
!                                     self.variables['name']),
!           'database': self.variables['connection'],
!           'prequery': 1,
!           'table': self.variables['table'] } )
!       keyfield = self.variables['key']
!       descrfield = self.variables['descr']
! 
!     # Reuse existing datasource
!     elif self.variables['datasource'] == 1:
!       datasource = self.__datasourceMap[self.variables['source']]
!       keyfield = self.variables['key']
!       descrfield = self.variables['descr']
! 
!     # Create a "static" datasource
!     else:
!       datasource = self.AddElement('datasource', self.form,
!         { 'name': "dtsDrpStatic%s" % self.variables['name'],
!           'type': "static" } )
!       keyfield = 'key'
!       descrfield = 'descr'
!       # Add staticset
!       ss = self.AddElement( 'staticset', datasource,
!                             { 'fields': 'key,descr' } )
!       # And each row...
!       for r in string.split(self.variables['dataset'],'|'):
!         try:
!           key, descr = string.split(r,':',1)
!         except ValueError:
!           pass
!         ssr = self.AddElement('staticsetrow', ss)
!         self.AddElement('staticsetfield',ssr,{'_content_': key})
!         self.AddElement('staticsetfield',ssr,{'_content_': descr})
! 
! 
!     #
!     # Create the dropdown
!     #
! 
!     # TODO: Make sure self.current produces a Block
!     self.AddElement('datasource', self.current.findChildOfType('GFBlock'),
!                     { 'name': 'fld%s' % self.variables['name'],
!                       'field': self.variables['name'],
!                       'x': self.x,
!                       'y': self.y,
!                       'width': self.width or 10,
!                       'height': 1,
!                       'fk_source': datasource.name,
!                       'fk_key': key,
!                       'fk_description': descr } )
  
  
      return 1
+ 
+ 
+   ###############
+   #
+   # Internal stuff
+   # Get a list of all existing datasources
+   #
+   def __getExistingDatasources(self):
+     self.__firstConnection = None
+     self.__datasourceSet = []
+     self.__datasourceMap = []
+     for child in self.form._children:
+       if child._type == 'GFDataSource' and hasattr(child,'table'):
+         self.__datasourceSet.append((child.name,"%s (%s)" % (child.name, 
child.table)))
+         self.__datasourceMap[child.name] = child
+         if not self.__firstConnection:
+           self.__firstConnection = child.database
+ 
  
  
  
Index: gnue/designer/src/forms/wizards/AddPage.py
diff -c gnue/designer/src/forms/wizards/AddPage.py:1.4 
gnue/designer/src/forms/wizards/AddPage.py:1.5
*** gnue/designer/src/forms/wizards/AddPage.py:1.4      Fri Jul 19 19:21:12 2002
--- gnue/designer/src/forms/wizards/AddPage.py  Thu Jul 25 01:36:08 2002
***************
*** 22,33 ****
  # forms/wizards/AddPage.py
  #
  # DESCRIPTION:
! # Implements a basic form template
  #
  # NOTES:
! # While functional, the primary purpose of this wizard is
! # as a "learning-by-example" tool.
! 
  
  from gnue.designer.forms.TemplateSupport import *
  from gnue.designer import VERSION
--- 22,31 ----
  # forms/wizards/AddPage.py
  #
  # DESCRIPTION:
! # Adds a blank page to the form
  #
  # NOTES:
! #
  
  from gnue.designer.forms.TemplateSupport import *
  from gnue.designer import VERSION



reply via email to

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