cute_mongo_forms.container.base

base.py : Base/example classes for containers (lists, forms, etc.). Containers use collections in various ways.

  • Copyright: 2017-2018 Sampsa Riikonen
  • Authors : Sampsa Riikonen
  • Date : 2017
  • Version : 0.2

This file is part of the cute_mongo_forms library

License: LGPLv3+ (see the COPYING.LESSER file)

Functions

dictionaryCheck(definitions, dic) Checks that dictionary has certain values, according to definitions
main()
noCheck(obj)
objectCheck(definitions, obj) Checks that object has certain attributes, according to definitions
parameterInitCheck(definitions, parameters, obj) Checks that parameters are consistent with a definition
test1()
test2()
typeCheck(obj, typ) Check type of obj, for example: typeCheck(x,int)

Classes

EditFormSet(**kwargs) Derived from FormSet.
FormSet(**kwargs) Group of forms.
List(**kwargs) Manages a QListWidget connected to a collection
Namespace() A dummy namespace
PermissionFormSet(**kwargs) A special FormSet derived from EditFormSet.
RowDialog(typenames[, title, parent])
class cute_mongo_forms.container.base.EditFormSet(**kwargs)[source]

Derived from FormSet. Here we have, additionally, buttons for creating new records, and for copying, saving and clearing them. This FormSet makes it possible to write into the collection.

class Signals[source]

Signals emitted by this class:

  • new_record(object) : emitted when a new record has been added. Carries the record _id.
  • save_record(object): emitted when a record has been saved. Carries the record _id.
class cute_mongo_forms.container.base.FormSet(**kwargs)[source]

Group of forms. Each form corresponds to a different Row class. Only one type of form is visible at a time.

Parameters at instantiation:

Parameters:collection – Collection object with row classes and the document collection
chooseForm_slot(element, element_old)[source]

Calling this slot chooses the form to be shown

Parameters:
  • element – an object that has _id and classname attributes
  • element_old – an object that has _id and classname attributes

This slot is typically connected to List classes, widget attribute’s, currentItemChanged method (List.widget is QListWidget that has currentItemChanged slot), so the element and element_old parameters are QListWidgetItem instances with extra attributes “_id” and “_classname” attached.

Queries the database for element._id

class cute_mongo_forms.container.base.List(**kwargs)[source]

Manages a QListWidget connected to a collection

Parameters at instantiation:

Parameters:collection – Collection object with records corresponding to Row classes
createItem()[source]

Overwrite in child classes to create custom items (say, sortable items, etc.)

makeLabel(entry)[source]

How to create a label from a database record. Overwrite in child classes.

update_slot(_id)[source]

Sending a signal to this slot updates the list.

Parameters:_id – Current item is set to this list item. None = request clear selection.
class cute_mongo_forms.container.base.PermissionFormSet(**kwargs)[source]

A special FormSet derived from EditFormSet. Links two tables together with foreign keys.

Parameters:
  • collection – Database collection. Database should have two foreign key columns
  • key1_name – Name of the column having the first foreign key
  • key1_name – Name of the column having the second foreign key
chooseRecord1_slot(element, element_old)[source]

Calling this slot chooses the current record from the first collection

Parameters:
  • element – an object that has _id and classname attributes
  • element_old – an object that has _id and classname attributes
chooseRecord2_slot(element, element_old)[source]

Calling this slot chooses the current record from the second collection

Parameters:
  • element – an object that has _id and classname attributes
  • element_old – an object that has _id and classname attributes
class cute_mongo_forms.container.base.SimpleForm(**kwargs)[source]

Embed the widget of a Row into another widget (for including button, extra labels, etc.)