Package conduit :: Package gtkui :: Module Database :: Class GenericDBListStore
[hide private]

Class GenericDBListStore

source code


gtk.TreeModel implementation that saves and stores data directly to and from a sqlite database. A simple LRU cache is included to lower the number of required SQL queries.

Instance Methods [hide private]
 
__init__(self, table, genericDB)
Creates a new GenericDBListStore.
source code
 
_on_inserted(self, db, oid) source code
 
_on_modified(self, db, oid) source code
 
_on_deleted(self, db, oid) source code
 
_get_n_rows(self)
Returns the number of rows found in our loaded table inside the sqlite database.
source code
 
_get_columns(self)
Returns the number of columns found in our sqlite table.
source code
 
_get_oid(self, offset)
Returns the oid of the row at offset.
source code
 
_get_value(self, oid, index)
Returns the value for a column in the table with a row id of oid.
source code
 
_get_next_oid(self, oid)
Returns the next oid after passed oid.
source code
 
_get_offset(self, oid)
Returns the offset of oid in the sqlite table.
source code
 
on_get_flags(self)
Returns the gtk.TreeModelFlags for the gtk.TreeModel implementation.
source code
 
on_get_n_columns(self)
Returns the number of columns found in the table metadata.
source code
 
on_get_column_type(self, index)
All columns in sqlite are accessed via (char*).
source code
 
on_get_iter(self, path)
Traslates a gtk.TreePath to a gtk.TreeIter.
source code
 
on_get_path(self, rowref)
Returns the rowrefs offset in the table which is used to generate the gtk.TreePath.
source code
 
on_get_value(self, rowref, column)
Returns the data for a rowref at the givin column.
source code
 
on_iter_next(self, rowref)
Returns the next oid found in the sqlite table.
source code
 
on_iter_children(self, rowref)
Retruns children for a given rowref.
source code
 
on_iter_has_child(self, rowref)
Always returns False as List based TreeModels do not have children.
source code
 
on_iter_n_children(self, rowref)
Returns the number of children a row has.
source code
 
on_iter_nth_child(self, rowref, n)
Returns the oid of the nth child from rowref.
source code
 
on_iter_parent(self, child)
Always returns None as lists do not have parent nodes.
source code
Class Variables [hide private]
  OID_CACHE = True
Method Details [hide private]

__init__(self, table, genericDB)
(Constructor)

source code 

Creates a new GenericDBListStore.

Parameters:
    filename -- the filename of the sqlite database.
    table -- the name of the table to manage.

_get_oid(self, offset)

source code 

Returns the oid of the row at offset.

Parameters:
    offset -- the rows offset from 0.

Decorators:
  • @DB.lru_cache(0)

_get_value(self, oid, index)

source code 

Returns the value for a column in the table with a row id
of oid.

Parameters:
    oid -- the rows internal oid.
    column -- the column index.

Decorators:
  • @DB.lru_cache(0)

_get_next_oid(self, oid)

source code 

Returns the next oid after passed oid.

Note: for some reason unknown to me, gtk.TreeView or
perhaps the GenericTreeModel finds it neccessary to
iterate through every iter from the root node through
n_children. Because of this, we will fetch row ids in
sets of 1024 and cache them to speed things up.

Parameters:
    oid -- the current oid.

Decorators:
  • @DB.lru_cache(0)

_get_offset(self, oid)

source code 

Returns the offset of oid in the sqlite table.

Parameters:
    oid -- the oid of the row to check

on_get_flags(self)

source code 
Returns the gtk.TreeModelFlags for the gtk.TreeModel implementation. The gtk.TreeIter data is derived from the database oids for records and therefore is persistant across row deletion and inserts.

on_get_column_type(self, index)

source code 
All columns in sqlite are accessed via (char*). Therefore, all of our column types will pass that right along and allow the consumers to typecast as needed.

on_get_iter(self, path)

source code 
Traslates a gtk.TreePath to a gtk.TreeIter. This is done by finding the oid for the row in the database at the same offset as the path.

on_get_value(self, rowref, column)

source code 

Returns the data for a rowref at the givin column.

Parameters:
    rowref -- the rowref passed back in the on_get_iter
                 method.
    column -- the integer offset of the column desired.

on_iter_next(self, rowref)

source code 

Returns the next oid found in the sqlite table.

Parameters:
    rowref -- the oid of the current iter.

on_iter_children(self, rowref)

source code 

Retruns children for a given rowref. This will always be
None unless the rowref is None, which is our root node.

Parameters:
    rowref -- the oid of the desired row.

on_iter_n_children(self, rowref)

source code 
Returns the number of children a row has. Since only the root node may have children, we return 0 unless the request is made for the count of all rows. Requesting the row count is done by passing None as the rowref.

on_iter_nth_child(self, rowref, n)

source code 

Returns the oid of the nth child from rowref. This will
only return a value if rowref is None, which is the
root node.

Parameters:
    rowref -- the oid of the row.
    n -- the row offset to retrieve.