Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.core.store¶
Defines the “store” and its “fields” .
During startup, Lino instantiates a “store” and its “fields” (aka “atomizers”) for every table. These were used originally for dealing with Sencha ExtJS GridPanels and FormPanels, but the concept turned out useful for other features.
Some usages specific to Sencha ExtJS:
for generating the JS code of the GridPanel definition
for generating an “atomized” JSON representation when rendering data for that GridPanel
for parsing the JSON sent by GridPanel and FormPanel
Other usages:
remote fields (
lino.core.fields.RemoteField
)render tables as text (
lino.core.renderer.TextRenderer.show_table()
andlino.core.requests.ActionRequest.row2text()
)
Functions
|
The holder is where the (potential) choices come from. |
|
Return the atomizer for this database field. |
Classes
|
A |
|
|
|
A |
|
An atomizer for all kinds of fields which use a ComboBox. |
|
|
|
|
|
|
|
A field whose value is the result of the get_row_permission method on that row. |
|
See also blog entries 20100803, 20111003, 20120901 |
|
|
|
|
|
An atomizer used for all ForeignKey fields. |
|
|
|
|
|
|
|
|
|
Deprecated. |
|
|
|
|
|
|
|
|
|
|
Common methods for |
|
|
StoreField for |
|
|
|
|
|
A Store is the collection of StoreFields for a given actor. |
|
Base class for the fields of a |
|
|
|
- class lino.core.store.StoreField(field, name, **options)¶
Bases:
object
Base class for the fields of a
Store
.- field¶
The database field (a subclass of django.db.models.fields.Field)
Note: value_from_object and full_value_from_object are similar, but for ForeignKeyStoreField and GenericForeignKeyField one returns the primary key while the latter returns the full instance.
- form2obj_default = None¶
because checkboxes are not submitted when they are off
- list_values_count = 1¶
Necessary to compute
Store.pk_index
.
- as_js(name)¶
Return a Javascript string which defines this atomizer as an object. This is used by
lino.modlib.extjs.ext_renderer
. and in case of virtual remote fields they use the virtual field’s delegate as_js method but with their own name.
- form2obj(ar, instance, post_data, is_new)¶
Test cases:
setting a CharField to ‘’ will store either ‘’ or None, depending on whether the field is nullable or not.
trading.Invoice.number may be blank
setting a Person.city to blank must not create a new Place “Select a Place…”
- format_value(ar, v)¶
Return a plain textual representation as a unicode string of the given value v. Note that v might be None.
- class lino.core.store.RelatedMixin¶
Bases:
object
Common methods for
ForeignKeyStoreField
andOneToOneStoreField
.
- class lino.core.store.ComboStoreField(field, name, **options)¶
Bases:
StoreField
An atomizer for all kinds of fields which use a ComboBox.
- class lino.core.store.ForeignKeyStoreField(field, name, **options)¶
Bases:
RelatedMixin
,ComboStoreField
An atomizer used for all ForeignKey fields.
- parse_form_value(v, obj, ar=None)¶
Convert the form field value (expected to contain a primary key) into the corresponding database object. If it is an invalid primary key, return None.
If this comes from a learning ComboBox (i.e.
can_create_choice
is True) the value will be the text entered by the user. In that case, callcreate_choice
.
- class lino.core.store.RequestStoreField(vf, delegate, name)¶
Bases:
StoreField
StoreField for
lino.core.fields.RequestField
.
- class lino.core.store.DisabledFieldsStoreField(store)¶
Bases:
SpecialStoreField
See also blog entries 20100803, 20111003, 20120901
Note some special cases:
lino.modlib.vat.VatDocument.total_incl
(readonly virtual PriceField) must be disabled and may not get submitted. ExtJS requires us to set this dynamically each time.JobsOverview.body (a virtual HtmlBox) or Model.workflow_buttons (a displayfield) must not have the ‘disabled’ css class.
after submitting a Lockable, the
- class lino.core.store.DisableEditingStoreField(store)¶
Bases:
SpecialStoreField
A field whose value is the result of the get_row_permission method on that row. New feature since /blog/2011/0830
- class lino.core.store.BooleanStoreField(field, name, **kw)¶
Bases:
StoreField
A
StoreField
for BooleanField.- parse_form_value(v, obj, ar=None)¶
Ext.ensible CalendarPanel sends boolean values as
- class lino.core.store.AutoStoreField(field, name, **kw)¶
Bases:
StoreField
A
StoreField
for AutoField
- class lino.core.store.MethodStoreField(field, name, **options)¶
Bases:
StoreField
Deprecated. See /blog/2012/0327. Still used for DISPLAY_MODE_HTML.
- lino.core.store.get_atomizer(holder, fld, name)¶
Return the atomizer for this database field.
An atomizer is an instance of a subclass of
StoreField
.
- lino.core.store.create_atomizer(holder, fld, name)¶
The holder is where the (potential) choices come from. It can be a model, an actor or an action. fld is a data element.
- class lino.core.store.Store(rh, **options)¶
Bases:
BaseStore
A Store is the collection of StoreFields for a given actor. Instantiated in kernel
- collect_fields(fields, *layouts)¶
fields is a pointer to either self.detail_fields or self.grid_fields. Each of these must contain a primary key field.
- form2obj(ar, form_values, instance, is_new)¶
Store the form_values into the instance by calling
form2obj()
for every store field.
- column_index(name)¶
Used to set disabled_actions_index. Was used to write definition of Ext.ensible.cal.CalendarMappings and Ext.ensible.cal.EventMappings