commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7803 - trunk/gnue-common/src/datasources


From: reinhard
Subject: [gnue] r7803 - trunk/gnue-common/src/datasources
Date: Mon, 8 Aug 2005 16:41:13 -0500 (CDT)

Author: reinhard
Date: 2005-08-08 16:41:12 -0500 (Mon, 08 Aug 2005)
New Revision: 7803

Modified:
   trunk/gnue-common/src/datasources/GDataSource.py
Log:
Cleanup, docstrings, comments.


Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py    2005-08-08 21:40:52 UTC 
(rev 7802)
+++ trunk/gnue-common/src/datasources/GDataSource.py    2005-08-08 21:41:12 UTC 
(rev 7803)
@@ -85,36 +85,63 @@
     self.primarykeyseq = None
     self.requery = True
 
+    # GConnections object (connection manager). GDataSource must have a
+    # _connections because it can be a top level object (when used with
+    # DataSourceWrapper)
     self._connections = None
-    self._connection = None             # GConnection object
-    self.__master = None                # Master DataSource object
-    self._masterPkFields = []           # M/D link fields in the master table
-    self._masterFkFields = []           # M/D link fields in the detail table
-    self._primarykeyFields = []         # Primary key fields of this table
-    self._staticCondition = None        # Condition from <conditions> child
-    self._fieldReferences = {}
-    self._defaultData = {}
-    self._rowidField = None
 
+    self._toplevelParent = None # Needs to be set by subclass
+                                # so that _topObject gets set
+    self._topObject = None
+
+    # GConnection object. Forms accesses this variable :(
+    self._connection = None
+
+    # Master DataSource object
+    self.__master = None
+
+    # Master/detail link fields in the master table
+    self.__masterPkFields = []
+
+    # Master/detail link fields in the detail table
+    self.__masterFkFields = []
+
+    # Primary key fields of this table
+    self.__primarykeyFields = []
+
+    # Rowid field name
+    self.__rowidField = None
+
+    # Condition from <conditions> child
+    self.__staticCondition = None
+
+    # Sort order definition from <sortorder> child
+    self.__sortorder = None
+
+    # Refenrenced fields (fields bound to a database column)
+    self.__fieldReferences = {}
+
+    # Default data for new records per field
+    self.__defaultData = {}
+
     # Dictionary with the keys being GDataSource objects and the values being
     # (pk_fields, fk_fields) tuples.
     self.__details = {}
 
+    # The current result set
+    self.__currentResultSet = None
+
     # We maintain our own event controller, so an object interested in *our*
     # events doesn't get the events of other datasources
     self.__eventController = events.EventController ()
     self.registerEventListeners = self.__eventController.registerEventListeners
 
+    # Initialization steps
     self._inits = [self.__primaryInit, self.__secondaryInit,
                    self.__tertiaryInit]
-    self._currentResultSet = None
-    self._toplevelParent = None # Needs to be set by subclass
-                                # so that _topObject gets set
-    self._topObject = None
-    self.sorting = None
 
+    # Definitions for triggers
     self._triggerGlobal = True
-
     self._triggerFunctions = {
         'createResultSet': {'function': self.__trigger_createResultSet},
         'simpleQuery'    : {'function': self.__trigger_simpleQuery},
@@ -123,9 +150,7 @@
         'call'           : {'function': self.__trigger_call},
         'getCondition'   : {'function': self.getCondition},
         'setCondition'   : {'function': self.setCondition},
-        'count'          : {'function': self.__trigger_get_recordCount}
-    }
-
+        'count'          : {'function': self.__trigger_get_recordCount}}
     self._triggerProperties = {
         'extensions' : {'get'   : self.__trigger_get_extensions,
                         'direct': 1},
@@ -133,8 +158,7 @@
                         'direct': 1},
         'order_by'   : {'get'   : self.__trigger_get_order_by,
                         'set'   : self.__trigger_set_order_by,
-                        'direct': 1}
-    }
+                        'direct': 1}}
 
 
   # ---------------------------------------------------------------------------
@@ -171,7 +195,7 @@
   # ---------------------------------------------------------------------------
 
   def __trigger_delete (self):
-    self._currentResultSet.current.delete ()
+    self.__currentResultSet.current.delete ()
 
   # ---------------------------------------------------------------------------
 
@@ -183,7 +207,7 @@
     if self._connection._need_rollback_after_exception_:
       raise Exceptions.FunctionNotAvailable
     self.postAll ()
-    result = self._currentResultSet.current.call (name, params)
+    result = self.__currentResultSet.current.call (name, params)
     self.requeryAll ()
     return result
 
@@ -195,20 +219,20 @@
   # ---------------------------------------------------------------------------
 
   def __trigger_get_recordCount (self):
-    if self._currentResultSet:
-      return len (self._currentResultSet)
+    if self.__currentResultSet:
+      return len (self.__currentResultSet)
     else:
       return 0
 
   # ---------------------------------------------------------------------------
 
   def __trigger_get_order_by (self):
-    return self.sorting
+    return self.__sortorder
 
   # ---------------------------------------------------------------------------
 
   def __trigger_set_order_by (self, value):
-    self.sorting = self.__convertOrderBy (value)
+    self.__sortorder = self.__convertOrderBy (value)
 
 
   # ---------------------------------------------------------------------------
@@ -222,9 +246,9 @@
       self.connection = self.database
       del self.database
 
-    # order_by attribute: set self.sorting
+    # order_by attribute: set self.__sortorder
     if hasattr (self, 'order_by'):
-      self.sorting = self.__convertOrderBy (self.order_by)
+      self.__sortorder = self.__convertOrderBy (self.order_by)
 
     # explicitfields attribute: reference them
     if hasattr (self, 'explicitfields'):
@@ -234,17 +258,17 @@
 
     # primarykey attribute: remember them and reference them
     if hasattr (self, 'primarykey'):
-      self._primarykeyFields = self.primarykey.split (',')
+      self.__primarykeyFields = self.primarykey.split (',')
       # Make sure the primary key is included in the field references
-      self.referenceFields (self._primarykeyFields)
+      self.referenceFields (self.__primarykeyFields)
 
-    # <condition> child: set self._staticCondition
-    self._staticCondition = self.findChildOfType ('GCCondition')
+    # <condition> child: set self.__staticCondition
+    self.__staticCondition = self.findChildOfType ('GCCondition')
 
-    # <sortorder> child: set self.sorting
+    # <sortorder> child: set self.__sortorder
     sortorder = self.findChildOfType ('GCSortOrder')
     if sortorder:
-      self.sorting = sortorder.sorting
+      self.__sortorder = sortorder.sorting
 
     # <staticset> child: set self._staticSet
     self._staticSet = self.findChildOfType ('GDStaticSet')
@@ -252,7 +276,7 @@
     # <sql> child: set self._rawSQL
     self._rawSQL = self.findChildOfType ('GDSql')
 
-    return GObjects.GObj._buildObject(self)
+    return GObjects.GObj._buildObject (self)
 
 
   # ---------------------------------------------------------------------------
@@ -280,18 +304,18 @@
       # Check if the connection has a fixed primary key name
       primarykeyFields = self._connection._primarykeyFields_
       if primarykeyFields:
-        self._primarykeyFields = primarykeyFields
-        self.referenceFields (self._primarykeyFields)
+        self.__primarykeyFields = primarykeyFields
+        self.referenceFields (self.__primarykeyFields)
 
       # Include the rowid in list of field references
       rowidField = self._connection._rowidField_
       if rowidField:
         # TODO: checks if the rowid is available and should be used go here:
-        # 1. if primary key should be prefered, don't set self._rowidField
+        # 1. if primary key should be prefered, don't set self.__rowidField
         # 2. try if rowidField is available in current table/view
-        if not self._primarykeyFields:
-          self._rowidField = rowidField
-          self.referenceField (self._rowidField)
+        if not self.__primarykeyFields:
+          self.__rowidField = rowidField
+          self.referenceField (self.__rowidField)
 
     # Add ourselves into the "global" datasource dictionary
     self._topObject._datasourceDictionary [self.name.lower ()] = self
@@ -336,21 +360,21 @@
       # Get the primary key fields from the "masterlink" attribute
       if not hasattr (self, 'masterlink'):
         raise Exceptions.MissingMasterlinkError (self.name)
-      self._masterPkFields = [s.strip () for s in self.masterlink.split (',')]
-      self.__master.referenceFields (self._masterPkFields)
+      self.__masterPkFields = [s.strip () for s in self.masterlink.split (',')]
+      self.__master.referenceFields (self.__masterPkFields)
 
       # Get the foreign key fields from the "detaillink" attribute
       if not hasattr (self, 'detaillink'):
         raise Exceptions.MissingDetaillinkError (self.name)
-      self._masterFkFields = [s.strip () for s in self.detaillink.split (',')]
-      self.referenceFields (self._masterFkFields)
+      self.__masterFkFields = [s.strip () for s in self.detaillink.split (',')]
+      self.referenceFields (self.__masterFkFields)
 
       # Check if the number of fields matches
-      if len (self._masterPkFields) != len (self._masterFkFields):
+      if len (self.__masterPkFields) != len (self.__masterFkFields):
         raise Exceptions.MasterDetailFieldMismatch (self.name)
 
-      self.__master._addDetail (self, self._masterPkFields,
-          self._masterFkFields)
+      self.__master._addDetail (self, self.__masterPkFields,
+          self.__masterFkFields)
 
 
   # ---------------------------------------------------------------------------
@@ -369,6 +393,13 @@
   # ---------------------------------------------------------------------------
 
   def setConnectionManager (self, connectionManager):
+    """
+    Set the connection manager (L{GConnections.GConnections} instance for this
+    datasource.
+
+    @param connectionManager: the connection manager instance.
+    """
+
     self._connections = connectionManager
 
 
@@ -377,22 +408,39 @@
   # ---------------------------------------------------------------------------
 
   def setCondition (self, mycondition):
-    self._staticCondition = mycondition
+    """
+    Set the static condition for this datasource. This condition is used in any
+    query, additionally to the condition given in L{createResultSet}.
 
+    @param mycondition: condition in prefix notation, dictionary notation or as
+      a L{GConditions} object tree.
+    """
 
+    self.__staticCondition = mycondition
+
+
   # ---------------------------------------------------------------------------
   # Return the static condition for this datasource
   # ---------------------------------------------------------------------------
 
   def getCondition (self):
-    return self._staticCondition
+    """
+    Returns the static condition for this datasource, as set in setCondition or
+    as defined in XML.
+    """
 
+    return self.__staticCondition
 
+
   # ---------------------------------------------------------------------------
   # Get the master datasource of this datasource
   # ---------------------------------------------------------------------------
 
   def getMaster (self):
+    """
+    Return the master datasource of this datasource.
+    """
+
     return self.__master
 
 
@@ -401,6 +449,10 @@
   # ---------------------------------------------------------------------------
 
   def hasMaster (self):
+    """
+    Return True if this datasource is a detail of another datasource.
+    """
+
     return self.__master is not None
 
 
@@ -409,7 +461,19 @@
   # ---------------------------------------------------------------------------
 
   def _addDetail (self, dataSource, pkFields, fkFields):
+    """
+    Add a detail datasource where this datasource is the master.
 
+    This method is called by the detail datasource to register itself at the
+    master.
+
+    @param dataSource: detail datasource.
+    @param pkFields: list of field names of the primary key fields in the
+      detail datasource.
+    @param fkFields: list of field names of the foreign kei fields in the
+      master datasource (i.e. in this datasource).
+    """
+
     self.__details [dataSource] = (pkFields, fkFields)
 
 
@@ -418,15 +482,22 @@
   # ---------------------------------------------------------------------------
 
   def referenceField (self, field, defaultValue = None):
+    """
+    Reference a bound field (i.e. bind it to a database column with the same
+    name).
 
+    @param field: Field name.
+    @param defaultValue: optional default value for newly inserted records.
+    """
+
     if self.type == 'unbound':
       gDebug (1, "Trying to bind field %s to unbound DataSource" % field)
       return
 
-    self._fieldReferences [field] = True
+    self.__fieldReferences [field] = True
 
     if defaultValue != None:
-      self._defaultData [field] = defaultValue
+      self.__defaultData [field] = defaultValue
 
 
   # ---------------------------------------------------------------------------
@@ -434,11 +505,18 @@
   # ---------------------------------------------------------------------------
 
   def referenceFields (self, fields):
+    """
+    Reference several bound fields at once (i.e. bind them to database columns
+    with the same names).
+
+    @param fields: List of field names.
+    """
+
     for field in fields:
       if isinstance (field, basestring):
-        self.referenceField(field)
+        self.referenceField (field)
       else:
-        self.referenceField(*field)
+        self.referenceField (*field)
 
 
   # ---------------------------------------------------------------------------
@@ -446,11 +524,23 @@
   # ---------------------------------------------------------------------------
 
   def referenceUnboundField(self, field, defaultValue=None):
+    """
+    Reference an unbound field.
 
+    Unbound fields are not bound to a database column. Values stored in unbound
+    fields are not persistent.
+
+    It is only necessary to explicitly reference an unbound field if a default
+    value should be set.
+
+    @param field: Field name.
+    @param defaultValue: optional default value for newly inserted records.
+    """
+
     gDebug (7,'Unbound Field %s implicitly referenced' % field)
 
     if defaultValue != None:
-      self._defaultData [field] = defaultValue
+      self.__defaultData [field] = defaultValue
 
 
   # ---------------------------------------------------------------------------
@@ -509,7 +599,7 @@
     newResultSet.close ()
 
     # If this is the current result set, then the UI has to follow the changes.
-    if resultSet == self._currentResultSet:
+    if resultSet == self.__currentResultSet:
       self.__eventController.dispatchEvent ('dsResultSetChanged',
           resultSet = resultSet)
 
@@ -521,12 +611,12 @@
   def __createResultSet (self, conditions = {}, readOnly = False,
       masterRecord = None):
 
-    cond = GConditions.combineConditions (conditions, self._staticCondition)
+    cond = GConditions.combineConditions (conditions, self.__staticCondition)
 
     # Add condition from master record
     mastercond = {}
     for (masterfield, detailfield) in zip (
-        self._masterPkFields, self._masterFkFields):
+        self.__masterPkFields, self.__masterFkFields):
       mastercond [detailfield] = masterRecord.getField (masterfield)
 
     cond = GConditions.combineConditions (cond, mastercond)
@@ -536,9 +626,9 @@
     if self.type == 'object':
       resultset.query ('object', self.cache,
           table      = self.table,
-          fieldnames = self._fieldReferences.keys (),
+          fieldnames = self.__fieldReferences.keys (),
           condition  = cond,
-          sortorder  = self.sorting and self.sorting or [],
+          sortorder  = self.__sortorder and self.__sortorder or [],
           distinct   = self.distinct)
 
     elif self.type == 'static':
@@ -579,9 +669,9 @@
   def __newResultSet (self, readOnly, masterRecord):
 
     # Merge the correct foreign key values into the default data dictionary
-    defaultData = self._defaultData.copy ()
+    defaultData = self.__defaultData.copy ()
     for (masterfield, detailfield) in zip (
-        self._masterPkFields, self._masterFkFields):
+        self.__masterPkFields, self.__masterFkFields):
       defaultData [detailfield] = masterRecord.getField (masterfield)
 
     # Create the ResultSet instance
@@ -589,10 +679,10 @@
         defaultData      = defaultData,
         connection       = self._connection,
         tablename        = self.table,
-        rowidField       = self._rowidField,
-        primarykeyFields = self._primarykeyFields,
+        rowidField       = self.__rowidField,
+        primarykeyFields = self.__primarykeyFields,
         primarykeySeq    = self.primarykeyseq,
-        boundFields      = self._fieldReferences.keys (),
+        boundFields      = self.__fieldReferences.keys (),
         requery          = self.requery,
         readonly         = readOnly,
         details          = self.__details,
@@ -604,8 +694,14 @@
   # ---------------------------------------------------------------------------
 
   def _activateResultSet (self, resultSet):
+    """
+    Make the given result set the active result set for this datasource.
 
-    self._currentResultSet = resultSet
+    The master calls this to activate the correct detail result sets for its
+    detail datasources.
+    """
+
+    self.__currentResultSet = resultSet
     self.__eventController.dispatchEvent ('dsResultSetActivated',
         resultSet = resultSet)
 
@@ -628,7 +724,7 @@
       self.__master.postAll ()
     else:
       try:
-        self._currentResultSet.post ()
+        self.__currentResultSet.post ()
       except:
         if self._connection._need_rollback_after_exception_:
           # we have to rollback now, all changes to the backend get lost, so we
@@ -637,7 +733,7 @@
         else:
           # we don't have to rollback, the changes done so far to the backend
           # are preserved, we requery so we have the the frontend updated
-          self._currentResultSet.requery ()
+          self.__currentResultSet.requery ()
         raise
 
 
@@ -658,7 +754,7 @@
     if self.__master:
       self.__master.requeryAll ()
     else:
-      self._currentResultSet.requery ()
+      self.__currentResultSet.requery ()
 
 
   # ---------------------------------------------------------------------------
@@ -718,32 +814,49 @@
 # =============================================================================
 
 class GCSortOrder (GObjects.GObj):
+  """
+  The sort order definition for a datasource.
+  """
 
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------
 
   def __init__ (self, parent = None):
+
     GObjects.GObj.__init__ (self, parent, type = 'GCSortOrder')
 
+
   # ---------------------------------------------------------------------------
   # Build Object
   # ---------------------------------------------------------------------------
 
   def _buildObject (self):
+
     self.sorting = []
     for item in self.findChildrenOfType ('GCSortField'):
       self.sorting.append ({'name': item.name,
                             'descending': item.descending,
                             'ignorecase': item.ignorecase})
 
+    return GObjects.GObj._buildObject (self)
 
+
 # =============================================================================
 # <sortfield>
 # =============================================================================
 
 class GCSortField (GObjects.GObj):
+  """
+  A field within a sort order definition.
+  """
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
   def __init__ (self, parent = None):
+
     GObjects.GObj.__init__ (self, parent, type = 'GCSortField')
 
 
@@ -752,7 +865,16 @@
 # =============================================================================
 
 class GSql (GObjects.GObj):
+  """
+  The definition of a raw SQL query string.
+  """
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
   def __init__ (self, parent = None):
+
      GObjects.GObj.__init__ (self, parent, type = 'GDSql')
 
 
@@ -761,55 +883,78 @@
 # =============================================================================
 
 class GStaticSet (GObjects.GObj):
+  """
+  A set of static data.
 
+  Static data is used whenever the values are predefined in the XML instead of
+  read from a database.
+  """
+
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------
 
   def __init__ (self, parent = None):
+
     GObjects.GObj.__init__ (self, parent, type = "GDStaticSet")
 
+
   # ---------------------------------------------------------------------------
   # Build Object
   # ---------------------------------------------------------------------------
 
   def _buildObject (self):
+
     self.data = [staticsetrow.data for staticsetrow in self._children]
 
+    return GObjects.GObj._buildObject (self)
 
+
 # =============================================================================
 # <staticsetrow>
 # =============================================================================
 
 class GStaticSetRow (GObjects.GObj):
+  """
+  A row of static data.
+  """
 
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------
 
   def __init__ (self, parent = None):
+
      GObjects.GObj.__init__ (self, parent, type = "GDStaticSetRow")
 
+
   # ---------------------------------------------------------------------------
   # Build Object
   # ---------------------------------------------------------------------------
 
   def _buildObject (self):
+
     self.data = dict ([(staticsetfield.name, staticsetfield.value) \
                        for staticsetfield in self._children])
 
+    return GObjects.GObj._buildObject (self)
 
+
 # =============================================================================
 # <staticsetfield>
 # =============================================================================
 
 class GStaticSetField (GObjects.GObj):
+  """
+  A field in a static data row.
+  """
 
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------
 
   def __init__ (self, parent = None):
+
      GObjects.GObj.__init__ (self, parent, type = "GDStaticSetField")
 
 
@@ -818,33 +963,55 @@
 # =============================================================================
 
 class GConnection(GObjects.GObj):
-  def __init__(self, parent=None):
-    GObjects.GObj.__init__(self, parent, "GCConnection")
+  """
+  A connection defined in the XML instead of in connections.conf.
+  """
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self, parent = None):
+
+    GObjects.GObj.__init__ (self, parent, "GCConnection")
+
     self.comment = ""
-    self.name = ""
-    self._inits =[self.initialize]
+    self.name    = ""
+    self._inits  = [self.__initialize]
 
-  def _buildObject(self):
+
+  # ---------------------------------------------------------------------------
+  # Build Object
+  # ---------------------------------------------------------------------------
+
+  def _buildObject (self):
+
     self.name = self.name.lower ()
-    return GObjects.GObj._buildObject(self)
 
-  def initialize(self):
+    return GObjects.GObj._buildObject (self)
+
+
+  # ---------------------------------------------------------------------------
+  # Build Object
+  # ---------------------------------------------------------------------------
+
+  def __initialize (self):
+
     # Add our database connection information to the connections
     # manager, then let it handle everything from there.
-    root = self.findParentOfType(None)
-    root._instance.connections.\
-        addConnectionSpecification(self.name, {
+    root = self.findParentOfType (None)
+    root._instance.connections.addConnectionSpecification (self.name, {
            'name': self.name,
            'provider': self.provider,
            'dbname': self.dbname,
-           'host': self.host } )
+           'host': self.host })
 
 
 # =============================================================================
 # List of XML Elements
 # =============================================================================
 
-def getXMLelements(updates={}):
+def getXMLelements (updates = {}):
 
   xmlElements = {
       'datasource': {
@@ -1039,15 +1206,15 @@
   }
 
   # Add conditional elements
-  xmlElements.update(
-      GConditions.getXMLelements(
-          {'condition':{'ParentTags':('datasource',) } } ))
+  xmlElements.update (GConditions.getXMLelements (
+      {'condition': {'ParentTags': ('datasource',)}}))
 
-  for alteration in updates.keys():
-    xmlElements[alteration].update(updates[alteration])
+  for alteration in updates.keys ():
+    xmlElements [alteration].update (updates [alteration])
 
   # Connections will have the same parent as datasources
-  xmlElements['connection']['ParentTags'] = 
xmlElements['datasource']['ParentTags']
+  xmlElements ['connection']['ParentTags'] = \
+      xmlElements ['datasource']['ParentTags']
 
   return xmlElements
 
@@ -1056,35 +1223,47 @@
 # Wrapper for standalone DataSources (i.e., not in context of a GObj tree)
 # =============================================================================
 
-def DataSourceWrapper(connections=None, fields=(), attributes={}, init=True,
-    sql=""):
+def DataSourceWrapper (connections = None, fields = [], attributes = {},
+    init = True, sql = ""):
+  """
+  Wrapper function to use datasources outside an XML tree.
 
-  source = _DataSourceWrapper()
+  @param connections: Connection manager (L{GConnections.GConnections}
+    instance).
+  @param fields: List of field names to bind to the database.
+  @param attributes: Dictionary of attributes to set for the datasource (all
+    XML attributes can be used).
+  @param init: If set to False, does not initialize the datasource object.
+  @param sql: Optional raw SQL.
+  """
 
+  source = _DataSourceWrapper ()
+
   if sql:
-    s = GSql(source)
-    GParserHelpers.GContent(s,sql)
-    attributes['type'] = 'sql'
+    s = GSql (source)
+    GParserHelpers.GContent (s,sql)
+    attributes ['type'] = 'sql'
 
 
   if connections:
-    source.setConnectionManager(connections)
+    source.setConnectionManager (connections)
 
   if init:
-    source.buildAndInitObject(**attributes)
+    source.buildAndInitObject (**attributes)
   else:
-    source.buildObject(**attributes)
+    source.buildObject (**attributes)
 
   if fields:
-    source.referenceFields(fields)
+    source.referenceFields (fields)
 
   return source
 
+# -----------------------------------------------------------------------------
 
-class _DataSourceWrapper(GDataSource):
-  def __init__(self, *args, **parms):
-    GDataSource.__init__(self, *args, **parms)
-    self._datasourceDictionary={}
+class _DataSourceWrapper (GDataSource):
+  def __init__ (self, *args, **parms):
+    GDataSource.__init__ (self, *args, **parms)
+    self._datasourceDictionary= {}
     self._toplevelParent = self._type
 
 
@@ -1093,31 +1272,62 @@
 # =============================================================================
 
 class AppServerResourceError (errors.AdminError):
+  """
+  Abstract base class for errors when loading appserver resources.
+  """
   pass
 
+# -----------------------------------------------------------------------------
+
 class InvalidURLError (AppServerResourceError):
+  """
+  Invalid URL for an appserver resource.
+  """
   def __init__ (self, url):
     msg = u_("The URL '%s' is not a valid application server resource "
              "locator") % url
     AppServerResourceError.__init__ (self, msg)
 
+# -----------------------------------------------------------------------------
+
 class InvalidResourceTypeError (AppServerResourceError):
+  """
+  Invalid resource type for an appserver resource.
+  """
   def __init__ (self, resourceType):
     msg = u_("Resource type '%s' is not supported") % resourceType
     AppServerResourceError.__init__ (self, msg)
 
+# -----------------------------------------------------------------------------
+
 class ResourceNotFoundError (AppServerResourceError):
+  """
+  Requested appserver resource not found.
+  """
   def __init__ (self, resType, resName):
     msg = u_("Resource '%(name)s' of type '%(type)s' not found") \
           % {'type': resType,
              'name': resName}
     AppServerResourceError.__init__ (self, msg)
 
+
 # -----------------------------------------------------------------------------
 # Load a resource from appserver and return it as a file-like object
 # -----------------------------------------------------------------------------
 
 def getAppserverResource (url, paramDict, connections):
+  """
+  Load an appserver resource.
+
+  Appserver resources are XML definitions that are generated by appserver.
+
+  @param url: Resource URL. Must be in format
+    appserver://<connection>/<resourcetype>/<resourcename>
+  @param paramDict: Parameters to provide when requesting the resource. Valid
+    parameters depend on the resource type.
+  @param connections: Connection manager that can be used to connect to the
+    appserver backend.
+  """
   if url [:12].lower () != 'appserver://':
     raise InvalidURLError, url
 





reply via email to

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