parameters: (self, table, columns)
docstring: CreateOrExtendTable(table, columns)
  
          Create a new table in the database.
  
          If a table of this name already exists, extend it to have any
          additional columns present in the given list as well as
          all of its current columns.
docstring_summary: CreateOrExtendTable(table, columns)
docstring_tokens: CreateOrExtendTable ( table columns )
function: def CreateOrExtendTable(self, table, columns):
          """CreateOrExtendTable(table, columns)
  
          Create a new table in the database.
  
          If a table of this name already exists, extend it to have any
          additional columns present in the given list as well as
          all of its current columns.
          """
          assert isinstance(columns, list)
  
          try:
              self.CreateTable(table, columns)
          except TableAlreadyExists:
              # the table already existed, add any new columns
              txn = None
              try:
                  columnlist_key = _columns_key(table)
                  txn = self.env.txn_begin()
  
                  # load the current column list
                  oldcolumnlist = pickle.loads(
                      getattr(self.db, "get_bytes",
                          self.db.get)(columnlist_key, txn=txn, flags=db.DB_RMW))
                  # create a hash table for fast lookups of column names in the
                  # loop below
                  oldcolumnhash = {}
                  for c in oldcolumnlist:
                      oldcolumnhash[c] = c
  
                  # create a new column list containing both the old and new
                  # column names
                  newcolumnlist = copy.copy(oldcolumnlist)
                  for c in columns:
                      if not c in oldcolumnhash:
                          newcolumnlist.append(c)
  
                  # store the table's new extended column list
                  if newcolumnlist != oldcolumnlist :
                      # delete the old one first since we opened with DB_DUP
                      self.db.delete(columnlist_key, txn=txn)
                      getattr(self.db, "put_bytes", self.db.put)(columnlist_key,
                                  pickle.dumps(newcolumnlist, 1),
                                  txn=txn)
  
                  txn.commit()
                  txn = None
  
                  self.__load_column_info(table)
              except db.DBError, dberror:
                  if txn:
                      txn.abort()
                  if sys.version_info < (2, 6) :
                      raise TableDBError, dberror[1]
                  else :
                      raise TableDBError, dberror.args[1]
function_tokens: def CreateOrExtendTable ( self , table , columns ) : assert isinstance ( columns , list ) try : self . CreateTable ( table , columns ) except TableAlreadyExists : # the table already existed, add any new columns txn = None try : columnlist_key = _columns_key ( table ) txn = self . env . txn_begin ( ) # load the current column list oldcolumnlist = pickle . loads ( getattr ( self . db , "get_bytes" , self . db . get ) ( columnlist_key , txn = txn , flags = db . DB_RMW ) ) # create a hash table for fast lookups of column names in the # loop below oldcolumnhash = { } for c in oldcolumnlist : oldcolumnhash [ c ] = c # create a new column list containing both the old and new # column names newcolumnlist = copy . copy ( oldcolumnlist ) for c in columns : if not c in oldcolumnhash : newcolumnlist . append ( c ) # store the table's new extended column list if newcolumnlist != oldcolumnlist : # delete the old one first since we opened with DB_DUP self . db . delete ( columnlist_key , txn = txn ) getattr ( self . db , "put_bytes" , self . db . put ) ( columnlist_key , pickle . dumps ( newcolumnlist , 1 ) , txn = txn ) txn . commit ( ) txn = None self . __load_column_info ( table ) except db . DBError , dberror : if txn : txn . abort ( ) if sys . version_info < ( 2 , 6 ) : raise TableDBError , dberror [ 1 ] else : raise TableDBError , dberror . args [ 1 ]