proxy Package

proxy Package

Proxy objects for the model that live in the GUI thread and are able to respond immediately. They do so by keeping a local copy of the data of the real model

We take copies of the data in the elixir model, because accessing an attribute on the model, might cause an sql query which might take a long time, and might freeze the gui

class camelot.view.proxy.ValueLoading[source]

Bases: object

Class indicating that a value was not yet loaded into the proxy

collection_proxy Module

Proxy representing a collection of entities that live in the model thread.

The proxy represents them in the gui thread and provides access to the data with zero delay. If the data is not yet present in the proxy, dummy data is returned and an update signal is emitted when the correct data is available.

class camelot.view.proxy.collection_proxy.CollectionProxy(*args, **kwargs)[source]

Bases: PyQt4.QtCore.QAbstractTableModel

The CollectionProxy contains a limited copy of the data in the actual collection, usable for fast visualisation in a QTableView

the CollectionProxy has some class attributes that can be overwritten when subclassing it :

  • header_icon : the icon to be used in the vertical header
append(*args, **kwargs)[source]
append_object(*args, **kwargs)[source]

Append an object to this collection, set the possible defaults and flush the object if possible/needed

Parameters:obj – the object to be added to the collection
Returns:the new number of rows in the collection
append_row(*args, **kwargs)[source]
Parameters:object_getter – a function that returns the object to be put in the

appended row.

columnCount(index=None)[source]
copy_row(*args, **kwargs)[source]

Copy the entity associated with this row to the end of the collection :param row: the row number

data(*args, **kwargs)[source]
Returns:the data at index for the specified role

This function will return ValueLoading when the data has not yet been fetched from the underlying model. It will then send a request to the model thread to fetch this data. Once the data is readily available, the dataChanged signal will be emitted

Using Qt.UserRole as a role will return all the field attributes of the index.

Using Qt.UserRole+1 will return the object of which an attribute is displayed in that specific cell

exception_signal
flags(index)[source]

Returns the item flags for the given index

getColumns()[source]
Returns:the columns as set by the setColumns method
getData(*args, **kwargs)[source]

Generator for all the data queried by this proxy

getItemDelegate()[source]
Returns:a DelegateManager for this model, or None if no DelegateManager yet available

a DelegateManager will be available once the item_delegate_changed signal has been emitted

getRowCount(*args, **kwargs)[source]
get_admin()[source]

Get the admin object associated with this model

get_collection(*args, **kwargs)[source]
get_validator()[source]
handleRowUpdate(*args, **kwargs)[source]

Handles the update of a row when this row might be out of date

handle_entity_create(sender, entity)[source]

Handles the entity signal, indicating that the model is out of date

handle_entity_delete(sender, entity)[source]

Handles the entity signal, indicating that the model is out of date

handle_entity_update(sender, entity)[source]

Handles the entity signal, indicating that the model is out of date

hasUnflushedRows()[source]

The model has rows that have not been flushed to the database yet, because the row is invalid

headerData(*args, **kwargs)[source]

In case the columns have not been set yet, don’t even try to get information out of them

header_icon = Icon('tango/16x16/places/folder.png')
item_delegate_changed_signal
map_to_source(sorted_row_number)[source]

Converts a sorted row number to a row number of the source collection

max_number_of_rows[source]

The maximum number of rows to be displayed at once

refresh(*args, **kwargs)[source]
remove(*args, **kwargs)[source]
remove_objects(*args, **kwargs)[source]
Parameters:objects_to_remove – a list of objects that need to be removed

from the collection :param delete: True if the objects need to be deleted

remove_rows(*args, **kwargs)[source]

Remove the entity associated with this row from this collection @param rows: a list with the numbers of the rows to remove @param delete: delete the entity as well

The rows_removed signal will be emitted when the removal was successful, otherwise the exception_signal will be emitted.

revertRow(*args, **kwargs)[source]
rowCount(index=None)[source]
row_changed_signal
rows_removed_signal
setColumns(*args, **kwargs)[source]

Callback method to set the columns

Parameters:columns – a list with fields to be displayed of the form [(‘field_name’, field_attributes), ...] as

returned by the getColumns method of the ElixirAdmin class

setData(index, value, role=2)[source]

Value should be a function taking no arguments that returns the data to be set

This function will then be called in the model_thread

setRowCount(rows)[source]

Callback method to set the number of rows @param rows the new number of rows

set_collection_getter(collection_getter)[source]
sort(*args, **kwargs)[source]

reimplementation of the QAbstractItemModel its sort function

class camelot.view.proxy.collection_proxy.DelayedProxy(*args, **kwargs)[source]

Bases: object

A proxy object needs to be constructed within the GUI thread. Construct a delayed proxy when the construction of a proxy is needed within the Model thread. On first occasion the delayed proxy will be converted to a real proxy within the GUI thread

class camelot.view.proxy.collection_proxy.EmptyRowData[source]

Bases: object

class camelot.view.proxy.collection_proxy.ProxyDict[source]

Bases: dict

Subclass of dictionary to fool the QVariant object and prevent it from converting dictionary keys to whatever Qt object, but keep everything python

class camelot.view.proxy.collection_proxy.SortingRowMapper[source]

Bases: dict

Class mapping rows of a collection 1:1 without sorting and filtering, unless a mapping has been defined explicitly

camelot.view.proxy.collection_proxy.strip_data_from_object(*args, **kwargs)[source]

For every column in columns, get the corresponding value from the object. Getting a value from an object is time consuming, so using this function should be minimized. :param obj: the object of which to get data :param columns: a list of columns for which to get data

camelot.view.proxy.collection_proxy.stripped_data_to_unicode(*args, **kwargs)[source]

Extract for each field in the row data a ‘visible’ form of data

queryproxy Module

Proxies representing the results of a query

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

Bases: camelot.view.proxy.collection_proxy.CollectionProxy

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

getData(*args, **kwargs)[source]

Generator for all the data queried by this proxy

getRowCount(*args, **kwargs)[source]
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_getter()[source]
remove(o)[source]
setQuery(*args, **kwargs)[source]

Set the query and refresh the view

sort(*args, **kwargs)[source]

Overwrites the QAbstractItemModel.sort() method

Table Of Contents

This Page


Comments
blog comments powered by Disqus