queryproxy

Proxies representing the results of a query

class camelot.view.proxy.queryproxy.QueryTableProxy(admin, query=None, max_number_of_rows=10, cache_collection_proxy=None)[source]

The QueryTableProxy contains a limited copy of the data in the SQLAlchemy model, which is fetched from the database to be used as the model for a QTableView

append(o)[source]

Add an object to this collection, used when inserting a new row, overwrite this method for specific behaviour in subclasses

get_collection()[source]

In case the collection is requested of a QueryProxy, we will return a collection getter for a collection that reuses the data already queried by the collection proxy, and available in the cache.

We do this to :

  1. Prevent an unneeded query when the collection is used to fetch an object already fetched by the query proxy (eg when a form is opened on a table view)
  2. To make sure the index of an object in the query proxy is the same as the index in the returned collection. Should we do the same query twice (once to fill the query proxy, and once to fill the returned collection), the same object might appear in a different row. eg when a form is opened in a table view, the form contains another record than the selected row in the table.
get_query()[source]
Returns:the query used to fetch the data, this is not the same as the one set by set_value, as sorting and filters will modify it
set_filter(list_filter, value)[source]

Set the filter mode for a specific filter

Parameters:
set_value(query)[source]
Parameters:query – the Query to display
sort(column, order)[source]

Overwrites the QAbstractItemModel.sort() method