Part of fixture.dataset View In Hierarchy
defines data to be loaded
a loader will typically want to load a dataset into a single storage medium. I.E. a table in a database.
Note that rows are always classes until the dataset instance has been loaded:
>>> class Flowers(DataSet): ... class violets: ... color = 'blue' ... class roses: ... color = 'red' ... >>> f = Flowers() >>> f.violets.color 'blue'
Row values can also be inherited from other rows, just as normal inheritance works in Python. See the primary_key Meta attribute above for how inheritance works on primary keys:
>>> class Recipes(DataSet): ... class chowder: ... is_soup = True ... name = "Clam Chowder" ... class tomato_bisque(chowder): ... name = "Tomato Bisque" ... >>> r = Recipes() >>> r.chowder.is_soup True >>> r.tomato_bisque.is_soup True
See DataSet.Meta for details
Class | Meta | configures a DataSet class. |
Method | __init__ | Undocumented |
Method | __iter__ | Undocumented |
Method | data | returns iterable key/dict pairs. |
Class Method | shared_instance | Undocumented |
Inherited from DataContainer:
Method | __contains__ | Undocumented |
Method | __getitem__ | Undocumented |
Method | __getattribute__ | Undocumented |
Method | __repr__ | Undocumented |
Method | get | Undocumented |
Method | _setdata | Undocumented |
returns iterable key/dict pairs.
You would only need to override this if you have a DataSet that will break unless it is ordered very specifically. Since class-style DataSet objects are just classes with attributes, its rows will be loaded in alphabetical order. The alternative is to define a DataSet as follows. However, note that this is not as functional as a class-style DataSet:
>>> class Birds(DataSet): ... def data(self): ... return ( ... ('blue_jay', dict( ... name="Blue Jay")), ... ('crow', dict( ... name="Crow")),) ... >>> b = Birds() >>> b.blue_jay.name 'Blue Jay' >>> b.crow.name 'Crow'