Decorators

class Decore

Object of class Decore is the main class of the framework. It is responsible for registering the elements and provides the API.

app(title, desc=None, allow_guest=True)

A function for opening a GUI dashboard application. It is used as a “Decorator”.

Parameters:
title : str

The title of the app.

allow_guest : bool

Specifies whether guest access (anonynus) is permitted. The value True allows automatic login as a guest. The value False refuses to send the metadata to the frontend and refers to the login page.

@decore.app(title='My App', allow_guest=False)
def main():
    pass
base(icon=None, title=None, desc=None, role=0, model=<Model: Decore_model>, private=False, stretch=False, navigation: ~typing.Literal['hide', 'main-top', 'main-bottom'] = 'main-top')

A function for registering a Base in the GUI dashboard application. It is used as a “Decorator”.

Base is the carrier element for the View and the template for the data source in the frontend.

Parameters:
icon : str

The symbol of the Base.

title : str

The Base title.

desc : str

The description of the Base.

model : Model

The Base data model.

@decore.base(icon='mdi-account', title='Person', desc='A basis for managing personal data', model=Person)
class Person_base:
    pass
view(parent_id=None, icon=None, title=None, desc=None, role=0, type: 'blank' | 'table' = 'table', fields=[], filters=[], query={}, pag_type: 'client' = 'client', pag_recs=16)

A function for registering a View. It is used as a “Decorator”.

A View is a container for displaying data.

Parameters:
parent_id : str

The ID of the parent element. Only to be set if the View is to be rendered in a different Base.

icon : str

The View icon.

title : str

The title of the View.

desc : str

The description of the View.

type : Literal['table']

Specifies how the data records are displayed. The value table represents the data records in a table.

fields : list

The fields that are displayed in the View.

filters : list

The filters that are displayed in the View.

query : dict

The query that is displayed in the View.

pag_type : Literal['client']

Selects the method how the data records of the view are loaded. The value client loads all data records at once and leaves the page structure to the frontend.

pag_recs : int

Specifies how many data records should be displayed on one page of the View. 16 is the default setting.

@decore.view(icon='mdi-account', title='Person', desc='A view for managing personal data', type='table', fields=[Person.id, Person.name, Person.age], filters=[Person.name, Person.age], query={'name__eq': 'Kemo'}, pag_type='client', pag_recs=16)
def person_view():
    pass
dialog(parent_id=None, icon=None, title=None, desc=None, role=0, type: 'standard' = 'standard', display: 'modal' | 'draw-half' | 'draw-full' = 'draw-half', activator: 'empty' | 'first' | 'last' | 'default' | 'context' | 'click' = 'none')

A function for registering a dialog. It is used as a “Decorator”.

The dialog is the carrier element for widgets

Parameters:
parent_id : str

The ID of the parent element. Only to be set if the dialog is to be rendered in a View of another Base.

icon : str

The symbol of dialog.

title : str

The title of the dialog.

desc : str

The description of the dialog.

type : Literal['standard']

Specifies how the dialog will display the widgets. The standard value displays the subordinate widgets and sub-widgets one below the other.

display : Literal['modal', 'draw-half', 'draw-full']

The display type of the dialog. The default value is draw-half.

activator : Literal['none', 'default', 'context', 'click']

The activator type of the dialog. With the value none the dialog is displayed immediately at the OnLoad event of the view. The value default displays the dialog in the top menu of the view. The value context represents the dialog in the context menu of an item in the view. The value click displays the dialog when you click on a data record.

@decore.dialog(icon='mdi-account', title='Person', desc='A dialog for managing personal data', type='standard', display='drawer', activator='default-menu')
def person_dialog():
    pass
widget(parent_id=None, icon=None, title=None, desc=None, role=0, type: 'default' | 'info' | 'form' | 'table' = 'default', layout='cera', fields=[])

A function for registering a widget. It is used as a “Decorator”.

A widget is used to display and interact with the data set. It receives the data specified by the dialog activator. The value none transfers the last data record of the database table. The value default transfers a data record filled only with default values. The value context transfers the data record that was selected in the context menu of the View. And click transfers the data record that was clicked on.

Widgets, which are assigned to a dialog from a foreign Base, supplement the relational fields of a default item of the foreign data source with the data of the activated item. (The sentence is crap to understand, but it does exactly what it does). In the sample application, I use this when assigning “Contracts” to a “Person”.

However, there are also widgets that can display several data records. As in the previous example, the relations are also used here to display only data that has something to do with the selected item.

Parameters:
parent_id : str

The ID of the parent element. Only to be set if the widget is to be rendered in a dialog of another Base.

icon : str

The icon of the widget.

title : str

The title of the widget.

desc : str

The description of the widget.

type : Literal['default', 'info', 'form', 'table']

Specifies how the widget will display the data. The default value is default.

fields : list

The fields that are displayed in the widget.

@decore.widget(icon='mdi-account', title='Person', desc='A widget for managing personal data', type='form', layout='cera', fields=[Person.name, Person.age])
def person_widget():
    pass
action(parent_id=None, icon=None, title=None, desc=None, role=0, type: 'standard' | 'submit' = 'standard', activator: 'default' | 'context' | 'click' = 'none', errors=True)

A function for registering an action. It is used as a “Decorator”.

An action is the actual interaction between the user and the backend.

Parameters:
parent_id : str

The ID of the parent element. Only to be set if the action is to be rendered in a widget of another Base.

icon : str

The symbol of action.

title : str

The title of the campaign.

desc : str

The description of the action.

type : Literal['standard', 'submit']

Specifies what the action can do. The default value is standard.

activator : Literal['default', 'context', 'click']

Specify how the action is triggered.

errors : bool

Specifies whether the action can return validation errors. The default value is True. (At the moment, this only affects the submit type).

@decore.action(icon='mdi-account', title='Person', desc='A action for managing personal data', type='submit')
def sample_action(item, **kwargs):
    pass

The actions run through a module that processes the data received and passes it to the decorated function as a keyword parameter. Everything can be found in the kwargs and you simply make them available. The item parameter is an example of this and represents the data set returned by the frontend. To find out what else is in the kwargs, please use the debugger.

function(type: 'shot' | 'work' = 'shot')

A function for registering a function in the parent base. It is used as a “Decorator”.

A function is run directly after the metadata pool has been compiled. Functions can be used to extend the logic, prepare things or perform background tasks. They act as instance methods of the Base and thus maintain the object-oriented approach.

Parameters:
type : Literal['shot', 'work']

Specifies how a function is run. With the value shot it is only run once. The value work is run in a thread and can therefore process loops that never end until the main thread ends.

@decore.function(type='shot')
def sample_function(self):
    pass