/[gnue]/gnue-common/src/datasources/GDataSource.py
ViewVC logotype

Diff of /gnue-common/src/datasources/GDataSource.py

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

revision 1.64 by siesel, Mon Oct 6 20:25:42 2003 UTC revision 1.65 by jcater, Tue Nov 25 17:01:29 2003 UTC
# Line 37  from gnue.common.datasources import GCon Line 37  from gnue.common.datasources import GCon
37  from gnue.common.formatting import GTypecast  from gnue.common.formatting import GTypecast
38  from gnue.common.datasources import GConditions  from gnue.common.datasources import GConditions
39    
   
40  ########################################################################  ########################################################################
41  #  #
42  # Class that handles DataSources.  This is a subclass of GObj, which  # Class that handles DataSources.  This is a subclass of GObj, which
# Line 106  class GDataSource(GObjects.GObj): Line 105  class GDataSource(GObjects.GObj):
105      except AttributeError:      except AttributeError:
106        pass        pass
107      try:      try:
108        # TODO: This **really** needs to be deprecated and        # TODO: This might be deprecated;
109        # TODO: should be using <sorting> tags        # TODO: should be using <sorting> tags
110        for field in string.split(self.order_by,','):        for field in string.split(self.order_by,','):
111          if field[-5:].lower() == ' desc':          if field[-5:].lower() == ' desc':
# Line 177  class GDataSource(GObjects.GObj): Line 176  class GDataSource(GObjects.GObj):
176      self._connections = connectionManager      self._connections = connectionManager
177    
178    def initialize(self):    def initialize(self):
179        print self.name
180      if not self.connection:      if not self.connection:
181        # We are a connectionless datasource (virtual?)              # We are a connectionless datasource (virtual?)
182        # We have to bind to something, so bind to empty or static driver        # We have to bind to something, so bind to empty or static driver
183        if not self.type=="static":        if not self.type=="static":
184          from gnue.common.datasources.drivers.special.unbound import Driver          from gnue.common.datasources.drivers.special.unbound import Driver
185          GDebug.printMesg (7, 'Using empty data driver')          GDebug.printMesg (7, 'Using empty data driver')
186          dataObject = Driver.supportedDataObjects['object']()          dataObject = Driver.supportedDataObjects['object'](None)
187    
188        else:        else:
189          from gnue.common.datasources.drivers.special.static import Driver          from gnue.common.datasources.drivers.special.static import Driver
190          GDebug.printMesg (7, 'Using static data driver')          GDebug.printMesg (7, 'Using static data driver')
191          dataObject = Driver.supportedDataObjects['object']()          dataObject = Driver.supportedDataObjects['object'](None)
192    
193          for child in self._children:          for child in self._children:
194            if isinstance(child, GStaticSet):            if isinstance(child, GStaticSet):
# Line 241  class GDataSource(GObjects.GObj): Line 241  class GDataSource(GObjects.GObj):
241    
242    def connect(self):    def connect(self):
243      if self.connection != None:      if self.connection != None:
244        self._connections.\        self._connections.requestConnection(self._dataObject)
245             requestConnection(self._dataObject, self.connection)  
246    
247    def getDataObject(self):    def getDataObject(self):
248      return self._dataObject      return self._dataObject
249    
250        
251    def referenceField(self, field, defaultValue=None):    def referenceField(self, field, defaultValue=None):
252      GDebug.printMesg(7,'Field %s implicitly referenced' % field)      GDebug.printMesg(7,'Field %s implicitly referenced' % field)
253      self._fieldReferences[field] = ""      self._fieldReferences[field] = ""
# Line 255  class GDataSource(GObjects.GObj): Line 255  class GDataSource(GObjects.GObj):
255      if defaultValue != None:      if defaultValue != None:
256        self._defaultValues[field] = defaultValue        self._defaultValues[field] = defaultValue
257    
258    def referenceFields(self, fields):    def referenceFields(self, fields):
259      for field in fields:      for field in fields:
260        if (type(field) == types.StringType) or \        if type(field) == types.StringType:
          (type(field) == types.UnicodeType):  
261          self.referenceField(field)          self.referenceField(field)
262        else:        else:
263          self.referenceField(*field)          self.referenceField(*field)
264          
265    def referenceUnboundField(self, field, defaultValue=None):    def referenceUnboundField(self, field, defaultValue=None):
266      GDebug.printMesg(7,'Field %s implicitly referenced' % field)      GDebug.printMesg(7,'Field %s implicitly referenced' % field)
267      self._unboundFieldReferences[field] = 1      self._unboundFieldReferences[field] = 1
# Line 554  def getXMLelements(updates={}): Line 553  def getXMLelements(updates={}):
553  # Wrapper for standalone DataSources  # Wrapper for standalone DataSources
554  # (i.e., not in context of a GObj tree)  # (i.e., not in context of a GObj tree)
555  #  #
556  def DataSourceWrapper(connections=None, fields=(), attributes={}, init=1):  def DataSourceWrapper(connections=None, fields=(), attributes={}, init=1, unicodeMode=0):
557    source = _DataSourceWrapper()    source = _DataSourceWrapper()
558        
559    if connections:    if connections:

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65

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