Keep track of static data loaded into the database. This class keeps track of data inserted into the database by storing the primary key and the class name of the inserted data, and associating this with a fixture key specified by the developer.
The developer can then use the fixture key to find out if this data has been stored in the database, or to update it in future versions of the application.
Only classes which have an integer field as their primary key can be tracked.
Find data that has been stored for a fixture key.
Parameters: |
|
---|---|
Returns: | a instance of type entity, or None if no fixture is found |
Find the fixture key for an object of type entity with primary key
Parameters: |
|
---|---|
Returns: | a string with the fixture_key that refers to this data, None if no such data is found |
Find out if an object was stored in the database through the fixture mechanism and return its fixture_key and fixture_class
Parameters: | obj – the object stored in the database |
---|---|
Returns: | (fixture_key, fixture_class) if the object was registered |
through the fixture mechanism, (None, None) otherwise
Load all fixture keys of a certain entity class in batch.
Parameters: | entity – the class of the stored data |
---|---|
Returns: | a dictionary mapping the primary key of a on object of type entity to a tuple of type (fixture key, fixture class) |
Find the Fixture instance that refers to the data stored for a fixture key.
Parameters: |
|
---|---|
Returns: | a Fixture instance refering to the stored data, or None of no data was found. |
Store data in the database through the fixture mechanism, to be able to keep track of it later.
Parameters: |
|
---|---|
Returns: | an object of type entity, either created or modified |
Remove all data of a certain class from the database, if it was stored through the fixture mechanism.
Parameters: | entity – the class of the stored data |
---|
Remove data from the database, if it was stored through the fixture mechanism.
Parameters: |
|
---|
Keep track of the version the fixtures have in the current database, the subversion revision number is a good candidate to be used as a fixture version.
Returns: | an integer representing the current version, 0 if no version found |
---|
Get the current version of the fixtures in the database for a certain fixture class.
Parameters: | fixture_class – the fixture class for which to get the version |
---|
Set the current version of the fixtures in the database for a certain fixture class.
Parameters: |
|
---|
version