Package gen :: Package db :: Module base :: Class Transaction
[frames] | no frames]

Class Transaction

source code


Define a group of database commits that define a single logical operation.

Instance Methods
 
__init__(self, msg, db, batch=False, no_magic=False)
Create a new transaction.
source code
 
get_description(self)
Return the text string that describes the logical operation performed by the Transaction.
source code
 
set_description(self, msg)
Set the text string that describes the logical operation performed by the Transaction.
source code
 
add(self, obj_type, handle, old_data, new_data)
Add a commit operation to the Transaction.
source code
 
get_recnos(self)
Return a list of record numbers associated with the transaction.
source code
 
get_record(self, recno)
Return a tuple representing the PrimaryObject type, database handle for the PrimaryObject, and a tuple representing the data created by the object's serialize method.
source code
 
__len__(self)
Return the number of commits associated with the Transaction.
source code
Method Details

__init__(self, msg, db, batch=False, no_magic=False)
(Constructor)

source code 

Create a new transaction.

A Transaction instance should not be created directly, but by the GrampsDbBase class or classes derived from GrampsDbBase. The db parameter is a list-like interface that stores the commit data. This could be a simple list, or a RECNO-style database object.

The batch parameter is set to True for large transactions. For such transactions, the list of changes is not maintained, and no undo is possible.

The no_magic parameter is ignored for non-batch transactions, and is also of no importance for DB backends other than BSD DB. For the BSDDB, when this paramter is set to True, some secondary indices will be removed at the beginning and then rebuilt at the end of such transaction (only if it is batch).

add(self, obj_type, handle, old_data, new_data)

source code 

Add a commit operation to the Transaction.

The obj_type is a constant that indicates what type of PrimaryObject is being added. The handle is the object's database handle, and the data is the tuple returned by the object's serialize method.

get_recnos(self)

source code 

Return a list of record numbers associated with the transaction.

While the list is an arbitrary index of integers, it can be used to indicate record numbers for a database.