commit-gnue
[Top][All Lists]
Advanced

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

gnue appserver/src/geasBClass.py common/src/dat...


From: Jason Cater
Subject: gnue appserver/src/geasBClass.py common/src/dat...
Date: Mon, 17 Feb 2003 02:31:10 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    03/02/17 02:31:09

Modified files:
        appserver/src  : geasBClass.py 
        common/src/datasources: GDataSource.py 

Log message:
        added a DataSourceWrapper convenience function for standalone 
datasources

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/geasBClass.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/datasources/GDataSource.py.diff?tr1=1.58&tr2=1.59&r1=text&r2=text

Patches:
Index: gnue/appserver/src/geasBClass.py
diff -c gnue/appserver/src/geasBClass.py:1.4 
gnue/appserver/src/geasBClass.py:1.5
*** gnue/appserver/src/geasBClass.py:1.4        Sat Feb  1 10:02:45 2003
--- gnue/appserver/src/geasBClass.py    Mon Feb 17 02:31:06 2003
***************
*** 19,27 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasBClass.py,v 1.4 2003/02/01 15:02:45 reinhard Exp $
  
! from gnue.common import GDataSource,GConditions
  import geasInstance
  import string
  
--- 19,27 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasBClass.py,v 1.5 2003/02/17 07:31:06 jcater Exp $
  
! from gnue.common.datasources import GDataSource,GConditions
  import geasInstance
  import string
  
***************
*** 41,64 ****
  
  
    def _populate (self):
!     self._datasource = GDataSource.GDataSource ()
!     # TODO: get the table name from the class name
!     self._datasource.buildObject (name = "",
!                                 database = self._session._database,
!                                 table = self._classname)
!     self._datasource.setConnectionManager (self._session._connections)
! 
!     # bug fix should be moved into common after the freeze
!     self._datasource._datasourceDictionary={}
! 
!     # set the field to sort (has to be called before phase init
      if hasattr(self,"_sort"):
!       self._datasource.order_by=string.joinfields(self._sort,",")
      
!     self._datasource.phaseInit ()
!     # TODO: get the column names from the prefetch field names
!     for field in self._prefetch:
!       self._datasource.referenceField (field)
  
      if hasattr(self,"_conditionTree"):
        self._resultset = self._datasource.createResultSet(self._conditionTree)
--- 41,61 ----
  
  
    def _populate (self):
!   
      if hasattr(self,"_sort"):
!       sorting = string.joinfields(self._sort,",")
!     else: 
!       sorting = None
      
!     self._datasource = GDataSource.DataSourceWrapper(
!                             connections=self._session._connections, 
!                             fields=self._prefetch, 
!                             init=1, 
!                             attributes = {
!                                "name": "tmp", 
!                                "connection": self._session._database,
!                                "table": self._classname, 
!                                "order_by": sorting } )
  
      if hasattr(self,"_conditionTree"):
        self._resultset = self._datasource.createResultSet(self._conditionTree)
Index: gnue/common/src/datasources/GDataSource.py
diff -c gnue/common/src/datasources/GDataSource.py:1.58 
gnue/common/src/datasources/GDataSource.py:1.59
*** gnue/common/src/datasources/GDataSource.py:1.58     Tue Jan  7 11:49:42 2003
--- gnue/common/src/datasources/GDataSource.py  Mon Feb 17 02:31:09 2003
***************
*** 29,41 ****
  # HISTORY:
  #
  
! import GDebug
! import GDataObjects
! import GObjects
! import sys, string
! import GConnections
! import GTypecast
! import GConditions
  
  
  ########################################################################
--- 29,41 ----
  # HISTORY:
  #
  
! from gnue.common.apps import GDebug
! from gnue.common.datasources import GDataObjects
! from gnue.common.definitions import GObjects
! import sys, string, types
! from gnue.common.datasources import GConnections
! from gnue.common.formatting import GTypecast
! from gnue.common.datasources import GConditions
  
  
  ########################################################################
***************
*** 62,71 ****
      self._inits =[self.primaryInit, self.secondaryInit, self.tertiaryInit]
      self._currentResultSet = None
      self._resultSetListeners = []
!     self._toplevelParent = self._type # Needs to be set by subclass
                                        # so that _topObject gets set
      self._topObject = None
-     self._datasourceDictionary={}
  
      #
      # trigger support
--- 62,70 ----
      self._inits =[self.primaryInit, self.secondaryInit, self.tertiaryInit]
      self._currentResultSet = None
      self._resultSetListeners = []
!     self._toplevelParent = None # Needs to be set by subclass
                                        # so that _topObject gets set
      self._topObject = None
  
      #
      # trigger support
***************
*** 239,244 ****
--- 238,244 ----
    def getDataObject(self):
      return self._dataObject
  
+     
    def referenceField(self, field, defaultValue=None):
      GDebug.printMesg(7,'Field %s implicitly referenced' % field)
      self._fieldReferences[field] = ""
***************
*** 246,251 ****
--- 246,258 ----
      if defaultValue != None:
        self._defaultValues[field] = defaultValue
  
+   def referenceFields(self, fields): 
+     for field in fields: 
+       if type(field) == types.StringType: 
+         self.referenceField(field)
+       else: 
+         self.referenceField(*field)
+       
    def referenceUnboundField(self, field, defaultValue=None):
      GDebug.printMesg(7,'Field %s implicitly referenced' % field)
      self._unboundFieldReferences[field] = 1
***************
*** 255,261 ****
  
  
    #
!   # The following are a simple wrapper arround the datasource's dataobject
    # to hide the dataobject from the app programmer
    #
    def hasMaster(self):
--- 262,268 ----
  
  
    #
!   # The following are a simple wrapper around the datasource's dataobject
    # to hide the dataobject from the app programmer
    #
    def hasMaster(self):
***************
*** 535,538 ****
    return xmlElements
  
  
! 
--- 542,572 ----
    return xmlElements
  
  
! #
! # Wrapper for standalone DataSources
! # (i.e., not in context of a GObj tree)
! #
! def DataSourceWrapper(connections=None, fields=(), attributes={}, init=1):
!   source = _DataSourceWrapper()
!   
!   if connections: 
!     source.setConnectionManager(connections)
!   
!   if init: 
!     source.buildAndInitObject(**attributes)
!   else: 
!     source.buildObject(**attributes)
!     
!   if fields: 
!     source.referenceFields(fields)
!   
!   return source
!   
!   
! def _DataSourceWrapper(GDataSource): 
!   def __init__(self, *args, **parms): 
!     GDataSource.__init__(self, *args, **parms)
!     self._datasourceDictionary={}
!     self._toplevelParent = self._type
!     
!     
\ No newline at end of file




reply via email to

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