commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7783 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2


From: reinhard
Subject: [gnue] r7783 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2 sql/interbase sql/maxdb sql/mysql sql/oracle sql/postgresql sql/sqlite2 sql/sqlite3
Date: Thu, 4 Aug 2005 13:27:55 -0500 (CDT)

Author: reinhard
Date: 2005-08-04 13:27:53 -0500 (Thu, 04 Aug 2005)
New Revision: 7783

Modified:
   trunk/gnue-common/src/datasources/drivers/Base/Behavior.py
   trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/mysql/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py
Log:
Cleanup, docstrings, comments.


Modified: trunk/gnue-common/src/datasources/drivers/Base/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/Behavior.py  2005-08-04 
17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/Base/Behavior.py  2005-08-04 
18:27:53 UTC (rev 7783)
@@ -61,21 +61,29 @@
   This class must be subclassed by all database drivers that want to offer
   schema support.
 
-  @cvar _maxIdLength: maximum length of an identifier or None if no restriction
-  @cvar _type2native: dictionary mapping field-types to native datatypes
+  @cvar _maxIdLength_: maximum length of an identifier or None if no
+    restriction.
+  @cvar _type2native_: dictionary mapping field-types to native datatypes.
 
   @ivar _current: GSchema instance with the connection's current schema. This
-    tree will be set by writeSchema ()
+    tree will be set by writeSchema ().
   @ivar _new: GSchema instance with the schema as it should look like after
-    writeSchema ()
+    writeSchema ().
   @ivar _diff: GSchema instance containing the difference between _current and
     _new. All items in this tree have an additional attribute '_action' which
     determines the item's state within the diff. It can be one of 'add',
     'change' or 'remove'.
+  @ivar _lookups: dictionary where the keys are global identifiers that have
+    already been used in this connection, used to avoid duplicate global
+    identifier names.
+  @ivar _elements: dictionary with the keys being table names and values being
+    dictionaries where the keys are local identifiers that have already been
+    used within that table. This is used to avoid duplicate local identifier
+    names.
   """
 
-  _maxIdLength = None                   # Maximum length of an identifier
-  _type2native = {}                     # Mapping between GSD-Types and natives
+  _maxIdLength_ = None                  # Maximum length of an identifier
+  _type2native_ = {}                    # Mapping between GSD-Types and natives
 
 
   # ---------------------------------------------------------------------------
@@ -93,10 +101,14 @@
     """
 
     self.__connection = connection
-    self._lookups     = {}      # Name-conversion mapping for element names
-    self._elements    = {}      # Per table mapping of elements
 
+    # Name-conversion mapping for element names
+    self._lookups = {}
 
+    # Per table mapping of elements
+    self._elements = {}
+
+
   # ---------------------------------------------------------------------------
   # Nice string representation
   # ---------------------------------------------------------------------------
@@ -106,28 +118,21 @@
     return "<Behavior for connection %s at %d>" % \
         (self.__connection.name, id (self))
 
+
   # ---------------------------------------------------------------------------
-  # Read schema information from connection and return it as GSchema tree
+  # Create a new database
   # ---------------------------------------------------------------------------
 
-  def readSchema (self):
+  def createDatabase (self):
     """
-    Retrieve the connection's schema information and return it as L{GSchema}
-    object tree.
-
-    @return: current schema as L{GSchema} object tree.
+    Create a new database specified by the associated connection.
     """
 
-    result = GSchema.GSSchema ()
-    author = self.__module__.replace ('gnue.common.datasources.drivers.', '')
-    title  = u_("DB-Export of %s") % self.__connection.name
-    result.buildAndInitObject (**{'author': author, 'title': title})
+    gEnter (8)
+    self._createDatabase_ ()
+    gLeave (8)
 
-    self._readSchema_ (result)
 
-    return result
-
-
   # ---------------------------------------------------------------------------
   # Update the current connection's schema with the given schema
   # ---------------------------------------------------------------------------
@@ -145,42 +150,105 @@
       to create/update the schema.
     """
 
+    checktype (schema, GSchema.GSchema)
+
+    gEnter (8)
+
     self._current = self.readSchema ()
-    self._diff    = self._current.diff (schema, self._maxIdLength)
+    self._diff    = self._current.diff (schema, self._maxIdLength_)
     self._new     = schema
 
     self._lookups  = self.__getLookups (self._current)
     self._elements = {}
 
-    gDebug (2, self._diff.dumpXML ())
+    gDebug (8, "Necessary schema changes:")
+    gDebug (8, self._diff.dumpXML ())
 
-    return self._writeSchema_ (self._current, self._new, self._diff, 
simulation)
+    result = self._writeSchema_ (self._current, self._new, self._diff,
+        simulation)
 
+    gLeave (8, result)
 
+
   # ---------------------------------------------------------------------------
-  # Create a new database
+  # Read schema information from connection and return it as GSchema tree
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def readSchema (self):
     """
+    Retrieve the connection's schema information and return it as L{GSchema}
+    object tree.
+
+    @return: current schema as L{GSchema} object tree.
+    """
+
+    gEnter (8)
+
+    result = GSchema.GSSchema ()
+    author = self.__module__.replace ('gnue.common.datasources.drivers.', '')
+    title  = u_("DB-Export of %s") % self.__connection.name
+    result.buildAndInitObject (**{'author': author, 'title': title})
+
+    self._readSchema_ (result)
+
+    return gLeave (8, result)
+
+
+  # ---------------------------------------------------------------------------
+  # Virtual methods to be implemented by descendants
+  # ---------------------------------------------------------------------------
+
+  def _createDatabase_ (self):
+    """
     Create a new database specified by the associated connection.
     """
+    raise NotImplementedError
 
+  # ---------------------------------------------------------------------------
+
+  def _writeSchema_ (self, current, new, diff, simulation = False):
+    """
+    Change the schema for the connection. This method must be overwritten by
+    descendants.
+
+    @param current: Current state of the backend schema as found out by
+      L{_readSchema_}.
+    @param new: New, desired state of the backend schema.
+    @param diff: L{GSchema} object tree only containing the elements that have
+      to be added.
+    @param simulation: if set to True, the schema should not be changed in the
+      backend, but only the command string should be generated and returned.
+    @return: command string to change the schema as desired.
+    """
     raise NotImplementedError
 
+  # ---------------------------------------------------------------------------
 
+  def _readSchema_ (self, parent):
+    """
+    Retrieve the connection's schema information and return it as L{GSchema}
+    object tree. This method must be overwritten by descendants.
+
+    @param parent: top level L{GSchema.GSchema} object to be used as root for
+      the created tree.
+    """
+    raise NotImplementedError
+
+
   # ---------------------------------------------------------------------------
-  # Merge two tripples of sequences
+  # Merge two triples of sequences
   # ---------------------------------------------------------------------------
 
-  def mergeTriple (self, result, source):
+  def _mergeTriple (self, result, source):
     """
     Merge the sequences in the given triples and return the first one (which
     has been changed as a side effect too).
 
+    This function is useful for descendants to build the command string for
+    schema changes.
+
     @param result: triple of sequences which get extended
     @param source: triple of sequences to extend the result with
-
     @return: triple of merged sequences
     """
 
@@ -197,20 +265,22 @@
   # Make sure a given identifier doesn't exceed maximum length
   # ---------------------------------------------------------------------------
 
-  def shortenName (self, name, stripLast = False):
+  def _shortenName (self, name, stripLast = False):
     """
     Return the longest usable part of a given identifier.
 
+    This function is useful for descendants to create identifiers when adding
+    new objects to the schema.
+
     @param name: identifier to be checked
     @param stripLast: if True, the last character is cut off if name has at
-        least maximum length. This way one could append another character
-        without violating length restrictions.
-
+      least maximum length. This way one could append another character without
+      violating length restrictions.
     @return: identifier with extra characters cut off
     """
 
     if self.__nameTooLong (name):
-      result = name [:self._maxIdLength - (stripLast and 1 or 0)]
+      result = name [:self._maxIdLength_ - (stripLast and 1 or 0)]
     else:
       result = name
 
@@ -218,53 +288,19 @@
 
 
   # ---------------------------------------------------------------------------
-  # Virtual method: read the connection's schema tree
-  # ---------------------------------------------------------------------------
-
-  def _readSchema_ (self, parent):
-    """
-    Retrieve the connection's schema information and return it as L{GSchema}
-    object tree. This method must be overwritten by descendants.
-
-    @param parent: parent object to use for the newly created GSchema object.
-    """
-
-    raise NotImplementedError
-
-
-  # ---------------------------------------------------------------------------
-  # Create code for merging the backend's schema to fit the given tree
-  # ---------------------------------------------------------------------------
-
-  def _writeSchema_ (self, current, new, diff, simulation = False):
-    """
-    Change the schema for the connection. This method must be overwritten by
-    descendants.
-
-    @param current: Current state of the backend schema as found out by
-      L{_readSchema_}.
-    @param new: New, desired state of the backend schema.
-    @param diff: L{GSchema} object tree only containing the elements that have
-      to be added.
-    @param simulation: if set to True, the schema should not be changed in the
-      backend, but only the command string should be generated and returned.
-    @return: command string to change the schema as desired.
-    """
-
-    raise NotImplementedError
-
-
-  # ---------------------------------------------------------------------------
   # Transform a GSField's type attribute into a usable 'native type'
   # ---------------------------------------------------------------------------
 
-  def _getNativetype_ (self, field):
+  def _getNativetype (self, field):
     """
     Get the apropriate native datatype for a given GSField's type attribute.
     If there is a method of the same name as the GSField's type this function
     will be called with the GSField as it's argument. If no such method is
-    available, but the GSField's type is listed in the '_type2native'
+    available, but the GSField's type is listed in the '_type2native_'
     dictionary, that value will be used. Otherwise an exception will be raised.
+
+    This function is useful for descendants when adding new fields to the
+    schema.
     
     @param field: GSField to get a native datatype for
     @return: string with the native datatype
@@ -276,8 +312,8 @@
       if hasattr (self, field.type):
         return getattr (self, field.type) (field)
 
-      elif field.type in self._type2native:
-        return self._type2native [field.type]
+      elif field.type in self._type2native_:
+        return self._type2native_ [field.type]
 
       raise MissingTypeTransformationError, field.type
 
@@ -289,11 +325,13 @@
   # Create a usable name for a seuquence like object
   # ---------------------------------------------------------------------------
 
-  def _getSequenceName_ (self, field):
+  def _getSequenceName (self, field):
     """
     Create a name suitable for a sequence like object using the table- and
     fieldname.
 
+    This function is intended to be used by descendants.
+
     @param field: GSField instance to create a sequence name for
     @return: string with a name for the given sequence
     """
@@ -307,31 +345,33 @@
     if self.__nameTooLong (result):
       result = "%s_seq" % (abs (id (field)))
 
-    return self.shortenName (result)
+    return self._shortenName (result)
 
 
   # ---------------------------------------------------------------------------
   # Create a unique name using a given lookup table
   # ---------------------------------------------------------------------------
 
-  def _getSafeName_ (self, name, prefix = None):
+  def _getSafeName (self, name, prefix = None):
     """
     Return a unique name based on the current lookup-table, which does not
     exceed the maximum identifier length. If the optional prefix argument is
     given it will be used for building lookup-keys.
 
+    This function is intended to be used by descendants.
+
     @param name: name to get a unique identifier for
     @param prefix: if given use this prefix for lookup-keys
 
-    @return: unique name of at most _maxIdLength characters 
+    @return: unique name of at most _maxIdLength_ characters 
     """
 
     count   = 0
     pattern = prefix and "%s_%%s" % prefix or "%s"
-    cname   = self.shortenName (name)
+    cname   = self._shortenName (name)
 
     while count < 10 and (pattern % cname) in self._lookups:
-      cname  = "%s%d" % (self.shortenName (name, True), count)
+      cname  = "%s%d" % (self._shortenName (name, True), count)
       count += 1
 
     self._lookups [pattern % cname] = None
@@ -345,7 +385,7 @@
 
   def __nameTooLong (self, name):
 
-    return self._maxIdLength is not None and len (name) > self._maxIdLength
+    return self._maxIdLength_ is not None and len (name) > self._maxIdLength_
 
 
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py        
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py        
2005-08-04 18:27:53 UTC (rev 7783)
@@ -57,10 +57,10 @@
   _alterMultiple   = True        # multiple fields in an alter table statement
   _extraPrimaryKey = False
 
-  _numbers     = ([], None, None)
-  _type2native = {'datetime': 'datetime',
-                  'time'    : 'time',
-                  'date'    : 'date'}
+  _numbers      = ([], None, None)
+  _type2native_ = {'datetime': 'datetime',
+                   'time'    : 'time',
+                   'date'    : 'date'}
 
   # ---------------------------------------------------------------------------
   # Generate a code sequence to match the requested schema
@@ -94,7 +94,7 @@
       for table in block.findChildrenOfType ('GSTable', False, True):
         # We do not drop tables
         if table._action in ['add', 'change']:
-          self.mergeTriple (result, self._createTable_ (table))
+          self._mergeTriple (result, self._createTable_ (table))
 
     code = prolog + main + epilog
 
@@ -159,7 +159,7 @@
         if self._alterMultiple:
           fcode = self._createFields_ (table)
           code = u"ALTER TABLE %s ADD (%s)" % (table.name, ", ".join 
(fcode[1]))
-          self.mergeTriple (result, (fcode [0], [code], fcode [2]))
+          self._mergeTriple (result, (fcode [0], [code], fcode [2]))
 
         else:
           for field in fields:
@@ -167,7 +167,7 @@
             code  = u"ALTER TABLE %s ADD %s" \
                     % (table.name, ", ".join (fcode [1]))
 
-            self.mergeTriple (result, (fcode [0], [code], fcode [2]))
+            self._mergeTriple (result, (fcode [0], [code], fcode [2]))
 
     # Create a new table
     else:
@@ -176,24 +176,24 @@
       pkey = table.findChildOfType ('GSPrimaryKey')
       if pkey is not None:
         triple = self._extraPrimaryKey and result or fcode
-        self.mergeTriple (triple, self._createPrimaryKey_ (pkey))
+        self._mergeTriple (triple, self._createPrimaryKey_ (pkey))
 
       code = u"CREATE TABLE %s (%s)" % (table.name, ", ".join (fcode [1]))
-      self.mergeTriple (result, (fcode [0], [code], fcode [2]))
+      self._mergeTriple (result, (fcode [0], [code], fcode [2]))
 
     # build all indices
     for index in table.findChildrenOfType ('GSIndex', False, True):
       if index._action == 'add':
-        self.mergeTriple (result, self._createIndex_ (index))
+        self._mergeTriple (result, self._createIndex_ (index))
 
     # build all constraints
     for constraint in table.findChildrenOfType ('GSUnique', False, True):
       if constraint._action == 'add':
-        self.mergeTriple (result, self._createConstraint_ (constraint))
+        self._mergeTriple (result, self._createConstraint_ (constraint))
 
     for constraint in table.findChildrenOfType ('GSForeignKey', False, True):
       if constraint._action == 'add':
-        self.mergeTriple (result, self._createConstraint_ (constraint))
+        self._mergeTriple (result, self._createConstraint_ (constraint))
 
     return result
 
@@ -216,10 +216,10 @@
 
     if isinstance (item, GSchema.GSTable):
       for field in item.findChildrenOfType ('GSField', False, True):
-        self.mergeTriple (result, self._processField_ (field))
+        self._mergeTriple (result, self._processField_ (field))
 
     elif isinstance (item, GSchema.GSField):
-      self.mergeTriple (result, self._processField_ (item))
+      self._mergeTriple (result, self._processField_ (item))
 
     return result
 
@@ -241,7 +241,7 @@
     if field._action == 'remove':
       return result
 
-    body.append ("%s %s" % (field.name, self._getNativetype_ (field)))
+    body.append ("%s %s" % (field.name, self._getNativetype (field)))
 
     if hasattr (field, 'defaultwith'):
       self._defaultwith_ (result, field)
@@ -332,7 +332,7 @@
     """
 
     result  = (pre, body, post) = ([], [], [])
-    keyName = self._getSafeName_ (pkey.name, "PK")
+    keyName = self._getSafeName (pkey.name, "PK")
     fields  = ", ".join ([field.name for field in \
                            pkey.findChildrenOfType ('GSPKField', False, True)])
 
@@ -375,7 +375,7 @@
       elements [ixKey] = None
 
     unique = hasattr (index, 'unique') and index.unique or False
-    ixName = self._getSafeName_ (index.name, "INDEX")
+    ixName = self._getSafeName (index.name, "INDEX")
     fields = index.findChildrenOfType ('GSIndexField', False, True)
 
     body.append (u"CREATE %sINDEX %s ON %s (%s)" % \
@@ -412,10 +412,10 @@
     else:
       elements [csKey] = None
 
-    csName  = self._getSafeName_ (constraint.name, "CONSTRAINT")
+    csName  = self._getSafeName (constraint.name, "CONSTRAINT")
 
     if isinstance (constraint, GSchema.GSForeignKey):
-      rfName  = self.shortenName (constraint.references)
+      rfName  = self._shortenName (constraint.references)
       fields  = constraint.findChildrenOfType ('GSFKField', False, True)
 
       code = u"ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) " \

Modified: trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py 
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py 
2005-08-04 18:27:53 UTC (rev 7783)
@@ -60,21 +60,21 @@
     self._GENFIELD = re.compile ('^.*NEW\.(\w+)\s*=\s*GEN_ID\s*\(.*\)',
         re.IGNORECASE)
 
-    self._maxIdLength   = 31
+    self._maxIdLength_  = 31
     self._alterMultiple = False
     self._maxVarchar    = 10921
     self._numbers       = [[(4, 'SMALLINT'), (9, 'INTEGER')], "NUMERIC(%s)",
                            "NUMERIC (%(length)s,%(scale)s)"]
 
-    self._type2native ['datetime'] = 'timestamp'
-    self._type2native ['boolean']  = 'boolean'
+    self._type2native_ ['datetime'] = 'timestamp'
+    self._type2native_ ['boolean']  = 'boolean'
 
 
   # ---------------------------------------------------------------------------
   # Create a new database
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def _createDatabase_ (self):
     """
     Create a new database for the associated connection. The password for the
     SYSDBA will be queried.
@@ -423,7 +423,7 @@
 
     if field.defaultwith == 'serial':
       table = field.findParentOfType ('GSTable')
-      seq   = self._getSequenceName_ (field)
+      seq   = self._getSequenceName (field)
 
       code [0].append (u"CREATE GENERATOR %s" % seq)
       code [2].append ( \

Modified: trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py     
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py     
2005-08-04 18:27:53 UTC (rev 7783)
@@ -56,21 +56,21 @@
                      # 'RESULT' : {'type': 'result' , 'name': _('Result 
Table')}
                      }
 
-    self._maxIdLength = 32
+    self._maxIdLength_ = 32
     self._maxVarchar  = 3999
     self._numbers = [[(5, 'SMALLINT'), (10, 'INTEGER')],
                      "FIXED (%s)",
                      "FIXED (%(length)s,%(scale)s)"]
 
-    self._type2native.update ({'boolean' : 'BOOLEAN',
-                               'datetime': 'TIMESTAMP'})
+    self._type2native_.update ({'boolean' : 'BOOLEAN',
+                                'datetime': 'TIMESTAMP'})
 
 
   # ---------------------------------------------------------------------------
   # Create a new database instance
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def _createDatabase_ (self):
     """
     Create a new database instance as defined by the connection's parameters.
     The user will be asked for a username and password who is member of the

Modified: trunk/gnue-common/src/datasources/drivers/sql/mysql/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/mysql/Behavior.py     
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/mysql/Behavior.py     
2005-08-04 18:27:53 UTC (rev 7783)
@@ -68,18 +68,18 @@
               'smallint','tinyint','float','real', 'double','decimal']:
       self._TYPEMAP [t] = ('number', 'number')
 
-    self._maxIdLength = 64
-    self._numbers     = [[(4, 'smallint'), (9, 'int'), (18, 'bigint')],
+    self._maxIdLength_ = 64
+    self._numbers      = [[(4, 'smallint'), (9, 'int'), (18, 'bigint')],
                          "decimal (%s,0)", "decimal (%(length)s,%(scale)s)"]
 
-    self._type2native ['boolean'] = "tinyint (1) unsigned"
+    self._type2native_ ['boolean'] = "tinyint (1) unsigned"
 
 
   # ---------------------------------------------------------------------------
   # Create a new database
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def _createDatabase_ (self):
     """
     Create a new database for the associated connection. In order to be
     successfull the current account must have enough privileges to create new

Modified: trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py    
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py    
2005-08-04 18:27:53 UTC (rev 7783)
@@ -58,11 +58,11 @@
      'all_synonym' : {'type': 'allsynonym',  'name': _('System Synonyms')}}
 
     self._pkPrecision   = 10
-    self._maxIdLength   = 31
+    self._maxIdLength_  = 31
     self._alterMultiple = False
     self._numbers       = [[], "number (%s)", "number (%(length)s,%(scale)s)"]
 
-    self._type2native.update ({'datetime': 'date', 'time': 'date'})
+    self._type2native_.update ({'datetime': 'date', 'time': 'date'})
 
 
   # ---------------------------------------------------------------------------
@@ -180,7 +180,7 @@
   # Create a new database
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def _createDatabase_ (self):
     """
     There's no support for creating databases atm, so a NotImplementedError
     will be raised.
@@ -204,7 +204,7 @@
 
     tablename = field.findParentOfType ('GSTable').name
     if field.defaultwith == 'serial':
-      seq = self._getSequenceName_ (field)
+      seq = self._getSequenceName (field)
       code [0].append (u"CREATE SEQUENCE %s MAXVALUE %s NOCYCLE" \
                        % (seq, "9" * self._pkPrecision))
 

Modified: trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py        
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py        
2005-08-04 18:27:53 UTC (rev 7783)
@@ -52,7 +52,7 @@
     self._RELKIND = {'v': {'type': 'view',  'name': _("Views")},
                      'r': {'type': 'table', 'name': _("Tables")}}
 
-    self._maxIdLength   = 31
+    self._maxIdLength_  = 31
     self._alterMultiple = False
     self._numbers       = [[(4, 'smallint'), (9, 'integer'), (18, 'bigint')],
                            "numeric (%s,0)", "numeric (%(length)s,%(scale)s)"]
@@ -72,15 +72,15 @@
     for item in ['timestamp', 'abstime']:
       self._TYPEMAP [item] = ('date', 'datetime')
 
-    self._type2native.update ({'boolean' : 'boolean',
-                               'datetime': 'timestamp without time zone'})
+    self._type2native_.update ({'boolean' : 'boolean',
+                                'datetime': 'timestamp without time zone'})
 
 
   # ---------------------------------------------------------------------------
   # Create a new database
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def _createDatabase_ (self):
     """
     Create the requested user and database using the tools 'createuser',
     'createdb' and 'dropuser'. Of course this function should better make use
@@ -412,7 +412,7 @@
     """
 
     if field.defaultwith == 'serial':
-      seq = self._getSequenceName_ (field)
+      seq = self._getSequenceName (field)
       code [0].append (u"CREATE SEQUENCE %s" % seq)
       field.default = "DEFAULT nextval ('%s')" % seq
 

Modified: trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py   
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py   
2005-08-04 18:27:53 UTC (rev 7783)
@@ -93,15 +93,15 @@
 
     DBSIG2.Behavior.__init__ (self, connection)
 
-    self._maxIdLength = 31
+    self._maxIdLength_ = 31
     self._alterMutliple = False
     self._numbers = [[(None, 'integer')], "", "numeric (%(length)s,%(scale)s)"]
 
     self._RELTYPE = {'table': {'type': 'table', 'name': _("Tables")},
                      'view' : {'type': 'view',  'name': _("Views")}}
 
-    self._type2native.update ({'boolean' : 'integer',
-                               'datetime': 'timestamp'})
+    self._type2native_.update ({'boolean' : 'integer',
+                                'datetime': 'timestamp'})
     self._passThroughTypes = ['date', 'datetime', 'time']
 
 
@@ -109,7 +109,7 @@
   # Create a new database
   # ---------------------------------------------------------------------------
 
-  def createDatabase (self):
+  def _createDatabase_ (self):
     """
     Create a new SQLite database for the associated connection.
     """
@@ -410,7 +410,7 @@
 
       # First find the original table
       for item in self._current.findChildrenOfType ('GSTable', False, True):
-        if item._id_ (self._maxIdLength) == table._id_ (self._maxIdLength):
+        if item._id_ (self._maxIdLength_) == table._id_ (self._maxIdLength_):
           original = item
           break
 
@@ -430,13 +430,13 @@
       body.append (u"CREATE TEMPORARY TABLE t1_backup (%s)" % ",".join 
(fields))
       body.append (u"INSERT INTO t1_backup SELECT %(fields)s FROM %(table)s" \
                    % {'fields': ", ".join (fields),
-                      'table' : self.shortenName (table.name)})
-      body.append (u"DROP TABLE %s" % self.shortenName (table.name))
+                      'table' : self._shortenName (table.name)})
+      body.append (u"DROP TABLE %s" % self._shortenName (table.name))
 
       # Build the new table using all new fields concatenated with the old
       # SQL-command.
       fcode = self._createFields_ (table)
-      self.mergeTriple (result, (fcode [0], [], fcode [2]))
+      self._mergeTriple (result, (fcode [0], [], fcode [2]))
 
       oldSQL  = parts.groups ()
       newBody = [", ".join (fcode [1])]
@@ -447,15 +447,15 @@
 
       body.append (cmd)
       body.append (u"INSERT INTO %(table)s SELECT %(fields)s FROM t1_backup" \
-                   % {'table' : self.shortenName (table.name),
+                   % {'table' : self._shortenName (table.name),
                       'fields': ",".join (nfields)})
       body.append (u"DROP TABLE t1_backup")
 
       # Finally create all indices as given by the new table
       for item in self._new.findChildrenOfType ('GSTable', False, True):
-        if item._id_ (self._maxIdLength) == table._id_ (self._maxIdLength):
+        if item._id_ (self._maxIdLength_) == table._id_ (self._maxIdLength_):
           for index in item.findChildrenOfType ('GSIndex', False, True):
-            self.mergeTriple (result, self._createIndex_ (index))
+            self._mergeTriple (result, self._createIndex_ (index))
 
           break
 

Modified: trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py   
2005-08-04 17:10:49 UTC (rev 7782)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py   
2005-08-04 18:27:53 UTC (rev 7783)
@@ -54,6 +54,6 @@
 
     Base.Behavior.__init__ (self, connection)
 
-    self._type2native.update ({'boolean' : 'boolean',
-                               'datetime': 'timestamp'})
+    self._type2native_.update ({'boolean' : 'boolean',
+                                'datetime': 'timestamp'})
     self._passThroughTypes.append ('boolean')





reply via email to

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