FeretUI client internals

feretui module

Feretui.

Small web client to build an admin user interface without any link with a framework.

This project is not a nodejs project. The client is generated with static templates. The javascrip library Htmx to improve the capability to manipulate the DOM and to add HTTP verb (DELETE, PUT, PATCH).

The client is not a Framework, and don’t use any web-server, orm, connector Frameworks. The goal is to separate the concept between both.

In a classical project the database, the ORM model’s and the user interface is declared on the same place. They are both the same configuration. But It is a mistake, because that limit the possibility and force to have only entry point by the user interface. The rules as required, readonly, … should be depending only on the user-interface. It is possible to define an interface based on more than one Model, or with another constraints.

To isolate it about the web-server projects, This project add objects to do absctract with web server:

FeretUI include to mecanism of templating:

  • feretui.template.Template : Import template by addons, the template can be modified by another template file. They are compiled by id and language. The compiled template are stored.

  • jinja.

The both are used in the same time, the internal allow the modularity, and jinja allow the loop and setter the variable inside the template

[my/template.tmpl]

<template id="my-template">
  <ul>
    {% for tag in tags %}
    <li>{{ tag }}</li>
    {% endfor %}
  </ul>
</template>

import of the template file

myferet.register_template_file('my/template.tmpl')

render the template

template_str = myferet.render_template(
    session, 'my-template', tags=['foo', 'bar'])

If the template need a static file (js, css, image), it is possible to add this static in existing client

myferet.register_js('my-lib.js', 'path in the filesystem')
myferet.register_css('my-lib.css', 'path in the filesystem')
myferet.register_image('my-picture.png', 'path in the filesystem')

Note

Python os lib give helper to find the path where the module is installed.

Note

An existing entrypoint is called at during the initialisation of the instance. In this entrypoint you may declare any static you need feretui.feretui.FeretUI.register_addons_from_entrypoint().

FeretUI include theme mecanism base on Bulma watch. It is easier to add your new theme file with feretui.feretui.FeretUI.register_theme().

myferet.register_theme('my-theme', 'path in the filesystem')

FeretUI add Action mechanism. The actions are callbacks and take as arguments the request and the argument of the action.

FeretUI allow to add page mecanisme. The page are function and take as arguments the session and the querystring or the body.

@myferet.register_page(
    name='my-page',
    template='''
        <template id="my-page">
            <div>My page</div>
        </template>
    '''
)
def my_page(feretui, session, option):
    return feretui.render_template(session, 'my-page')

In the case of the fully static page.

myferet.register_static_page(
    'my-static-page',
    '''
        <div>...</div>
    '''
)

or

from feretui.pages import static_page

myferet.register_page(name='my-page')(static_page('my-page-id))

To display the page a menu mecanism exist to call the render method of the page.

myferet.register_toolbar_right_menus([
    ToolBarMenu(
        'My static page',
        page='my-static-page',
        description="Go to my static page"
    ),
])

They are two main type of menu:

The helpers to register or get them are:

The client FeretUI add WTForm mecanism. The goal is to display easily formulaire in the pages and validate the entry in the actions.

To link the form with the translation and the bulma renderer you must inherit feretui.form.FeretUIForm.

If you need to register a password you must use the validator feretui.form.Password

The resource is a set of page and form to represent a data and tools to manipulate this data.

The client FeretUI add translation mechanism. This mecanism can be declared with addon’s name attribute. This attribute is used to extract the translation of FeretUI or an additionnal project. The translated object are:

To export the translation, the console script export-feretui-catalog extract all the translation messages in pot file.

from feretui import FeretUI, Session


myferet = FeretUI()
session = Session()

@route('an/url')
def do_something(request):
    frequest = Request(
        session=session,
        method=Request.POST,
        body=request.body.read(),
        headers=dict(request.headers),
    )
    response = myferet.execute_action(frequest, 'action-arg1-arg2')
    return response.body

feretui.feretui module

Module feretui.feretui.

A FeretUI instance represent one client. Each instance is a specific clent. Each client are isolated.

from feretui import FeretUI, Session, Request

myferet = FeretUI()
session = Session()
request = Request(session=session)

response = myferet.render(request)

The static files, themes and templates can be added:

class feretui.feretui.FeretUI(base_url: str = '/feretui', title: str = 'FeretUI')[source]

Feretui class.

Attributes

  • base_url[str] : The url for this client

  • title[str] : The title of the html head

  • jinja_env[Environment] : The environnement of jinja

  • template[:class: feretui.template.Template]: Templates load

  • statics[dict[str, str]]: The static filepath on server stored by name

  • css_import[list[str]] : List of the urls of the css to load

  • js_import[list[str]] : List of the urls of the script javascript to load

  • images[dict[str, str]] : List of the image and their url

  • themes[dict[str, str]] : List of the theme and their url

  • fonts[dict[str, str]] : List of the font and their url

  • actions[dict[str, Callable]] : List of the action callables

  • pages[dict[str, Callable]] : List of the pages

  • menus[dict[str, feretui.menus.ToolBarMenu]] : the key are left or right the value are instances of the menu.

  • asides[dict[str, feretui.menus.AsideMenu]] : The key is the code for the aside-menu page, the values are the instance of the menu.

  • resources[dict[str, :class:`feretui.resource.Resource]] : The key is the code of the resource and value the class.

The instance provide methodes to use

execute_action(request: Request, action_name: str) Response[source]

Execute a stored action.

Get and execute the action stored in the client. The parameters need for the good working of the action must be passed by the body or the querystring from the request.

request = Request(...)
myferet.execute_action(request, 'my_action')
Parameters:
Returns:

The result of the action

Return type:

feretui.response.Response

export_catalog(output_path: str, version: str, addons: str | None = None) None[source]

Export the catalog at the POT format.

FeretUI.export_catalog(
    'feretui/locale/feretui.pot', addons='feretui')
Parameters:
  • output_path (str) – The path where write the catalog

  • version (str) – The version of the catalog

  • addons (str) – The addons where the message come from

get_aside_menus(code: str) list[AsideMenu][source]

Return the aside menus link with the code.

Parameters:

code (str) – The code of the aside

Returns:

The menus to render

Return type:

list[feretui.menus.AsideMenu

get_image_url(name: str) str[source]

Get the url for a picture.

Parameters:

name (str) – The name of the picture

Returns:

The url to get it

Return type:

str

get_page(pagename: str) Callable[[FeretUI, Session, dict], str][source]

Return the page callable.

myferet.get_page('my-page')
Parameters:

pagename (str) – The name of the page

Returns:

the callable

Return type:

Callable[ [FeretUI, feretui.session.Session, dict], str]

get_resource(code: str) Resource[source]

Return the resource instance.

Parameters:

code (feretui.resource.Resource) – The code of the instance

Returns:

The instance of the resource

Return type:

feretui.resource.Resource

Exception:

feretui.exceptions.UnexistingResourceError

get_static_file_path(filename: str) str[source]

Get the path in the filesystem for static file name.

Parameters:

name (str) – The name of the static

Returns:

The filesystem path

Return type:

str

get_theme_url(session: Session) str[source]

Return the theme url in function of the session.

Parameters:
Returns:

the url to import stylesheep

Return type:

str

load_catalog(catalog_path: str, lang: str) None[source]

Load a specific catalog for a language.

::

FeretUI.load_catalog(‘feretui/locale/fr.po’, ‘fr’)

Parameters:
  • catalog_path (str) – Path of the catalog

  • lang (str) – Language code

load_internal_catalog(lang: str) None[source]

Load a specific catalog for a language defined by feretui.

::

FeretUI.load_internal_catalog(‘fr’)

Parameters:

lang (str) – Language code

register_action(function: Callable[[FeretUI, Request], Response]) Callable[[FeretUI, Request], Response][source]

Register an action.

It is a Decorator to register an action need by the client or the final project.

The action is a callable with two params:

@myferet.register_action
def my_action(feretui, request):
    return Response(...)
Parameters:

function (Callable[[FeretUI, feretui.request.Request], feretui.response.Response]) – The action callable to store

Returns:

The stored action callable

Return type:

Callable[[FeretUI, feretui.request.Request], feretui.response.Response]

register_addons_from_entrypoint() None[source]

Get the static from the entrypoints.

The declaration of the entryt point is done in the pyproject.toml of your project

[project.entry-points."feretui.addons"]
feretui = "feretui.feretui:import_feretui_addons"

Here the method call is import_feretui_addons().

register_aside_menus(code: str, menus: list[AsideMenu], addons: str | None = None) None[source]

Register a menu in an aside page.

myferet.register_aside_menus(
    'my-aside', [
        AsideMenu(...),
    ],
)
Parameters:
  • code (str) – The code of the aside

  • menus (list[feretui.menus.AsideMenu]) – The menus to register

  • addons (str) – The addons where the message come from

Exception:

feretui.exceptions.MenuError

register_auth_menus(menus: list[ToolBarButtonMenu], addons: str | None = None) None[source]

Register the auth menus.

myferet.register_auth_menus([
    ToolBarButtonMenu(...),
])
Parameters:
Exception:

feretui.exceptions.MenuError

register_css(name: str, filepath: str, compress: bool = True) None[source]

Register a stylesheet file to import in the client.

Parameters:
  • name (str) – name of the file see in the html url

  • filepath (str) – Path in server file system

  • compress (bool) – if True compress the csv

register_font(name: str, filepath: str) None[source]

Register a theme file to use it in the client.

Parameters:
  • name (str) – name of the font see in the html url

  • filepath (str) – Path in server file system

register_form(addons: str | None = None) Callable[source]

Register a WTForm.

This a decorator.

@myferet.register_form()
class MyForm(FeretUIForm):
    foo = StringField()
Parameters:

addons (str) – The addons where the message come from

register_image(name: str, filepath: str) None[source]

Register an image file to use it in the client.

Parameters:
  • name (str) – name of the image see in the html url

  • filepath (str) – Path in server file system

register_js(name: str, filepath: str) None[source]

Register a javascript file to import in the client.

Parameters:
  • name (str) – name of the file see in the html url

  • filepath (str) – Path in server file system

register_page(name: str | None = None, templates: Iterable[str] | None = None, forms: Iterable[FeretUIForm] | None = None, addons: str | None = None) Callable[source]

Register a page.

This is a decorator to register a page.

A page is a function :

  • Params

    • FeretUI

    • Session

    • dict

  • return the strof the html page

@myferet.register_page()
def my_page(feretui, session, options):
    return ...

By default the name is the name of the decorated callable. but this nae can be overritting

@myferet.register_page(name='my_page')
def _my_page(feretui, session, options):
    return ...

If need, the templates can be passed in the decorator and are added in the templates librairy

@myferet.register_page(template=[
    '''
        <template id="...">
            ...
        </template>
    '''
])
def my_page(feretui, session, options):
    return ...

You can register a WTForm

class MyForm(FeretUIForm):
    ...

@myferet.register_page(forms=[MyForm])
def my_page(feretui, session, options):
    return ...
Parameters:
  • name (str) – The name of the pages stored in FeretUI.pages

  • templates (list[str]) – The str of the template to load

  • forms – The WTForm to register at the same time

  • addons (str) – The addons where the message come from

Returns:

Return a decorator

Return type:

Callable

register_resource(addons: str | None = None) None[source]

Register and build the resource instance.

myferet.register_resource(
    'code of the resource',
    'label',
)
class MyResource(Resource):
    pass
Parameters:

addons (str) – The addons where the message come from

register_static_page(name: str, template: str, templates: Iterable[str] | None = None, addons: str | None = None) None[source]

Register a page.

This method register the page template and the callable to serve it without additionnal callable.

myferet.register_static_page('my-page', '<div>My Page</div>')

If need, the templates can be passed in the decorator and are added in the templates librairy

myferet.register_static_page(
    'my-page',
    '<div>My Page</div>',
    template=[
        '''
            <template id="...">
                ...
            </template>
        '''
    ]
)
Parameters:
  • name (str) – The name of the pages stored in FeretUI.pages

  • templates (Iterable[str]) – The str of the additionnal templates to load

  • addons (str) – The addons where the message come from

register_template_file(template_path: str, addons: str | None = None) None[source]

Import a template file in FeretUI.

The template file is imported in feretui.template.Template, and it is declared in the feretui.translation.Translation.

It is possible to load more than one template file.

myferet.register_template_file('path/of/template.tmpl')
Parameters:
  • template_path (str) – The template file path to import the instance of FeretUI

  • addons (str) – The addons where the message come from

register_template_from_str(template: str, addons: str | None = None) None[source]

Import a template string in FeretUI.

The template string is imported in feretui.template.Template, and it is declared in the feretui.translation.Translation.

It is possible to load more than one template string.

myferet.register_template_from_str('''
    <template id="my-template">
        ...
    </template>
''')
Parameters:
  • template (str) – The template to import the instance of FeretUI

  • addons (str) – The addons where the message come from

register_theme(name: str, filepath: str) None[source]

Register a theme file to use it in the client.

Parameters:
  • name (str) – name of the theme see in the html url

  • filepath (str) – Path in server file system

register_toolbar_left_menus(menus: list[ToolBarMenu], addons: str | None = None) None[source]

Register a menu in the left part of the toolbar.

myferet.register_toolbar_left_menus([
    ToolBarMenu(...),
])
Parameters:
Exception:

feretui.exceptions.MenuError

register_toolbar_right_menus(menus: list[ToolBarMenu], addons: str | None = None) None[source]

Register a menu in the right part of the toolbar.

myferet.register_toolbar_right_menus([
    ToolBarMenu(...),
])
Parameters:
Exception:

feretui.exceptions.MenuError

register_user_menus(menus: list[ToolBarMenu], addons: str | None = None) None[source]

Register a menu in the dropdown in the user menu.

myferet.register_user_menus([
    ToolBarMenu(...),
])
Parameters:
Exception:

feretui.exceptions.MenuError

render(request: Request) Response[source]

Return the render of the main page.

Parameters:

request – The feretui request

Returns:

Return the html page athrough a feretui Response

Return type:

class:

feretui.response.Response

render_template(session: Session, template_id: str, **kwargs) str[source]

Get a compiled template.

The compiled template from feretui.template.Template, This template is translated in function of the lang attribute of the session. All the named arguments is used by jinja librairy to improve the render.

myferet.render_template(session, 'my-template')

The jinja render is done after the compilation of the template. Because the template is stored in function of the declared templates and the language. The jinja depend of the execution in function of the parameter and can be saved but recomputed at each call.

Parameters:
  • session (feretui.session.Session) – The user feretui’s session

  • template_id (str) – The identify of the template

Returns:

The compiled templated through feretui.template.Template and jinja

Return type:

str

feretui.feretui.import_feretui_addons(feretui: FeretUI) None[source]

Import the main static used by FeretUI client.

Parameters:

feretui (FeretUI) – Instance of the client.

feretui.request module

Module feretui.request.

It is the request object used by feretui. FeretUI can’t decode any request from any web-server.

The adapter to connect the web-server with this request must be write by another libray or by the developper.

Example with bottle:

from bottle import request, route
from feretui import FeretUI, Request, Session

myferet = FeretUI()
session = Session()

@route('/feretui/action/<action>', method=['GET', 'POST'])
def call_action(action):
    frequest = Request(
        method=getattr(Request, request.method),
        querystring=request.query_string,
        form=MultiDict(request.forms),
        params=request.params.dict,
        headers=dict(request.headers),
        session=session,
    )
    res = myferet.do_action(frequest, action)
    ...
class feretui.request.Request(session: Session | None = None, method: RequestMethod = POST, form: MultiDict | None = None, params: MultiDict | None = None, querystring: str | None = None, headers: dict[str, str] | None = None)[source]

Description of the request.

This object is just a description of the web-server request.

Parameters:
  • session (Session) – User session

  • method (RequestMethod) – [Request.POST], the request method

  • form (MultiDict) – [None]

  • querystring (str) – [None]

  • params (dict) – [None]

  • headers (dict[str, str]) – [None]

Exception:

feretui.exceptions.RequestFormError

Exception:

feretui.exceptions.RequestNoSessionError

Exception:

feretui.exceptions.RequestWrongSessionError

DELETE = DELETE

DELETE request method

GET = GET

GET request method

PATCH = PATCH

PATCH request method

POST = POST

Post request method

PUT = PUT

PUT request method

get_base_url_from_current_url() dict[str, list[str]][source]

Get the querystring from the current client URL.

Returns:

The converted querystring.

Return type:

dict[str, list[str]]

get_query_string_from_current_url() dict[str, list[str]][source]

Get the querystring from the current client URL.

Returns:

The converted querystring.

Return type:

dict[str, list[str]]

get_url_from_dict(base_url: str = '/', querystring: dict[str, Any] | None = None) str[source]

Return an url.

The url is built in function the ain_url and the querystring.

Parameters:
  • base_url (str) – [/], the base url before the querystring.

  • querystring (dict[str, Any]) – [None], the querystring.

Returns:

Return the URL.

Return type:

str

class feretui.request.RequestMethod(method: str)[source]

RequestMethod.

feretui.response module

Module feretui.response.

It is the response object used by feretui to return any result quering by the client.

This reponse can not be used directly by web serving. The adapter to connect the web-serving with this response must be write by another libray or by the developper.

Example with bottle:

from bottle import response, route
from feretui import FeretUI

myferet = FeretUI()

@route('/feretui/action/<action>', method=['GET', 'POST'])
def post_action(action):
    ...
    res = myferet.do_action(frequest, action)
    for k, v in res.headers.items():
        response.set_header(k, v)

    return res.body,
class feretui.response.Response(body: str | None = '', status_code: int = 200, headers: dict[str, str] | None = None)[source]

Description of the response.

This object is just a description to inform the web-server library the return of FeretUI

from feretui import Response


response = Response('<div>This is a template</div>')
Parameters:
  • body (Any) – [‘’], response return to the web-serving.

  • status_code (int) – [200], the status code of the response.

  • headers (dict[str, str]) – Optionnal, additionnal headers.

feretui.session module

Module feretui.session.

This is a internal session, it represent the session of the web-server but with only the entry need by the client

The session can be overwritting by the developper:

from feretui import Session


session = Session()
class feretui.session.LoginForm(*args, **kwargs)[source]

WTform for the login.

class feretui.session.Session(user: str | None = None, lang: str = 'en', theme: str = 'default', **kwargs: dict)[source]

Description of the session.

The session can be overwritting by the developper:

from feretui import Session


class MySession(Session):
    pass

You should overwrite the methods to link the session with your user model.

Attributes

  • [user: str = None] : User name of the session

  • [lang: str = ‘en’] : The language use by the user session

  • [theme: str = ‘default’] : The ui theme use by the user session

class LoginForm(*args, **kwargs)

WTform for the login.

class SignUpForm(*args, **kwargs)

WTform for sign up.

login(form: FeretUIForm) None[source]

Login.

Parameters:

form – the WTForm object

logout() None[source]

Logout.

signup(form: FeretUIForm) bool[source]

Signup.

Parameters:

form – the WTForm object

to_dict() dict[source]

Return the value of the session as a dict.

class feretui.session.SignUpForm(*args, **kwargs)[source]

WTform for sign up.

feretui.template module

Template behaviours.

The goal of this Templating is to give the templating modulare, overwritable, translable and cachable without complex behaviours.

The complex behaviours is given by jinja.

Each FeretUI instance have his own instance of Template class. The stored templates could be deferents.

The templates are declared in file and imported with Template.load_file().

<templates>
    <template id="my-template-1">
        <div>My template</div>
    </template>
    <template id="my-template-2">
        <div>My other template</div>
    </template>
</templates>

It is possible to extend an existing template.

<template extend="my-template>
  <!-- ... -->
</template>

It is possible to create a new template from an existing template.

<template id="my-new-template" extend="my-template>
  <!-- ... -->
</template>

To modify a template with extend, use the tags include and xpath.

  • include : Include another template at this location

    <template id="tmpl-a">
      <!-- ... -->
           <include template="tmpl-b"></include>
      <!-- ... -->
    </template>
    
  • xpath insert: Insert in a tag path

    <template extend="my-template">
      <xpath expression=".//my-tag" type="insert">
        <!-- ... -->
      </xpath>
    </template>
    
  • xpath insertBefore: Insert before the tag path

    <template extend="my-template">
      <xpath expression=".//my-tag" type="insertBefore">
        <!-- ... -->
      </xpath>
    </template>
    
  • xpath insertAfter: Insert after the tag path

    <template extend="my-template">
      <xpath expression=".//my-tag" type="insertAfter">
        <!-- ... -->
      </xpath>
    </template>
    
  • xpath replace: Replace the tag path

    <template extend="my-template">
      <xpath expression=".//my-tag" type="replace">
        <!-- ... -->
      </xpath>
    </template>
    
  • xpath remove: Remove the tag path

    <template extend="my-template">
      <xpath expression=".//my-tag" type="remove">
      </xpath>
    </template>
    

For the xpath the expression attribute use xpath of lxml.

Warning

The parser used to manipulate the html is lxml, the html must be parsed. So the jinja command must not break the parser.

feretui.template.JINJA_REGEXES = ['\\{\\{ .* \\}\\}', '\\{% .* %\\}']

Regex to indicate if the text is a command jinja

class feretui.template.Template(translation: Translation)[source]

html templating framework, the need is to manipulate web template.

tmpl = Template()
tmpl.load_file(file_pointer_1)
tmpl.load_file(file_pointer_2)
tmpl.load_file(file_pointer_3)
tmpl.load_file(file_pointer_N)
tmpl.compîle()

Attributes

  • known [dict]:

    internal store of the raw templates and inherits.

  • compiled [dict[lang: dict[id: HtmlElement]]]:

    The compiled template, ready to use and store by lang.

  • compiled_str [dict[lang: dict[encoding: dict[id: HtmlElement]]]]:

    The compiled encoded template, ready to use and store by lang.

  • translation [feretui.translation.Translation]:

    instance of the translation for this instance of Template

apply_xpath(description: XPathDescription, lang: str, name: str) None[source]

Apply the xpath from XPathDescription.

Parameters:
  • description (XPathDescription) – The xpath description

  • lang (str) – The langage use for the include.

  • name (str) – The id of the template.

Exception:

feretui.exceptions.TemplateError

compile(lang: str = 'en') None[source]

Compile all the templates for a specific lang.

Parameters:

lang (str) – [en], The langage use for the include.

compile_template(lang: str, name: str) HtmlElement[source]

Compile a specific template in function of the lang.

The compiled template is stored to get it quuickly at the next call.

Parameters:
  • lang (str) – The langage use for the include.

  • name (str) – The id of the template.

Returns:

The compiled template

Return type:

HtmlElement

compile_template_i18n(tmpl: HtmlElement, action_callback: Callable[[str, str], None]) None[source]

Compile the translation for a node.

Parameters:
  • tmpl (HtmlElement) – The node to translate.

  • action_callback (Callback[[str, str], None]) – The callback use to translate or to store in the catalog

export_catalog(po: POFile) None[source]

Export the template translation in the catalog.

Parameters:

po (PoFile) – The catalog from the feretui.translation.Translation.

get_elements(lang: str, name: str) list[HtmlElement][source]

Return the store templates for one id, and apply include on them.

Parameters:
  • lang (str) – The langage use for the include.

  • name (str) – The id of the template.

Returns:

The list of the templates

Return type:

list[HtmlElement]

get_template(name: str, lang: str = 'en', tostring: bool = True, encoding: str = 'unicode') HtmlElement | str[source]

Return a specific template.

Parameters:
  • name (str) – name of the template to export

  • lang – [en] The template lang

  • tostring (bool) – [True] If True the template will be returned as a string.

  • encoding (str) – [unicode] The default encoding of the template when tostring is True

Returns:

The compiled template in the defined lang.

Return type:

HtmlElement or str

get_translation(lang: str, name: str, text: str, suffix: str) str[source]

Get the translation.

Parameters:
  • lang (str) – The langage use for the include.

  • name (str) – The id of the template.

  • text (str) – The default text to translate.

  • suffix (str) – suffix to put in the context

Returns:

The translated message

Return type:

str

get_xpath(element: HtmlElement) list[XPathDescription][source]

Find and return the xpath found in the template.

Parameters:

element (HtmlElement) – The root node of the template

Returns:

The xpath nodes description

Return type:

list[XPathDescription]

get_xpath_attributes(elements: list[HtmlElement]) list[dict[str, str]][source]

Find and return the attibutes in the xpath.

Parameters:

elements (list[HtmlElement]) – The node where are the attribute node

Returns:

The list of the attibutes.

Return type:

list[dict[str, str]]

Exception:

feretui.exceptions.TemplateError

has_template(template_id: str) bool[source]

Return True if the template exist in the view.

Parameters:

template_id (str) – the template id

Returns:

bool.

load_file(openedfile: IO, ignore_missing_extend: bool = False) None[source]

Load a file from the file descriptor.

File format

<templates>
    <template id="...">
        ...
    </template>
</templates>
Parameters:
  • openedfile (IO) – file descriptor

  • ignore_missing_extend (bool) – [False] use in the case of the export the catalog. If True the missing extends are ignored.

Exception:

feretui.exceptions.TemplateError

load_template(element: HtmlElement, ignore_missing_extend: bool = False) None[source]

Load one specific template.

Parameters:
  • element (HtmlElement) – The element node to load.

  • ignore_missing_extend (bool) – [False] use in the case of the export the catalog. If True the missing extends are ignored.

Exception:

feretui.exceptions.TemplateError

load_template_from_str(template: str) None[source]

Load a template from string.

Parameters:

template (str) – The template to load.

tostring(template: HtmlElement, encoding: str) str | bytes[source]

Return the template as a string.

Parameters:
  • template (HtmlElement) – The template to convert to string

  • encoding (str) – The encoding use for the string

Returns:

the template in string mode

Return type:

bytes or str

xpath(lang: str, name: str, expression: str, mult: bool) list[HtmlElement][source]

Apply the xpath on template id and get nodes.

Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – if True the return will take only the first element in the list.

Returns:

the nodes from xpath expression

Return type:

list[HtmlElement]

xpath_attributes(lang: str, name: str, expression: str, mult: bool, attributes: dict[str, str]) None[source]

Apply a xpath with action=”attributes”.

<template id="..." extend="other template">
    <xpath expression="..." action="attributes">
        <attribute key="value"/>
        <attribute foo="bar"/>
    </xpath>
</template>
Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – If true, xpath can apply on all the element found

  • attributes (dict[str, str]) – attributes to apply

xpath_insert_after(lang: str, name: str, expression: str, mult: bool, elements: list[HtmlElement]) None[source]

Apply a xpath with action=”insertAfter”.

<template id="..." extend="other template">
    <xpath expression="..." action="insertAfter">
        ...
    </xpath>
</template>
Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – If true, xpath can apply on all the element found

  • elements (list[HtmlElement]) – children of the xpath to insert

xpath_insert_before(lang: str, name: str, expression: str, mult: bool, elements: list[HtmlElement]) None[source]

Apply a xpath with action=”insertBefore”.

<template id="..." extend="other template">
    <xpath expression="..." action="insertBefore">
        ...
    </xpath>
</template>
Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – If true, xpath can apply on all the element found

  • elements (list[HtmlElement]) – children of the xpath to insert

xpath_insert_inside(lang: str, name: str, expression: str, mult: bool, elements: list[HtmlElement]) None[source]

Apply a xpath with action=”insertInside”.

<template id="..." extend="other template">
    <xpath expression="..." action="insert">
        ...
    </xpath>
</template>
Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – If true, xpath can apply on all the element found

  • elements (list[HtmlElement]) – children of the xpath to insert

xpath_remove(lang: str, name: str, expression: str, mult: bool) None[source]

Apply a xpath with action=”remove”.

<template id="..." extend="other template">
    <xpath expression="..." action="remove"/>
</template>
Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – If true, xpath can apply on all the element found

xpath_replace(lang: str, name: str, expression: str, mult: bool, elements: list[HtmlElement]) None[source]

Apply a xpath with action=”replace”.

<template id="..." extend="other template">
    <xpath expression="..." action="replace">
        ...
    </xpath>
</template>
Parameters:
  • lang (str) – lang for the translation

  • name (str) – The id of the template

  • expression (str) – xpath regex to find the good node

  • mult (bool) – If true, xpath can apply on all the element found

  • elements (list[HtmlElement]) – children of the xpath to insert

class feretui.template.XPathDescription(expression: str | None = None, mult: bool | None = None, action: str | None = None, elements: list[HtmlElement] | None = None)[source]

Xpath description object.

Attributes

  • expression: str, the xpath expression

  • mult: bool, If False, take only the first

  • action: str, The action to do in the xpath

  • elements: list[HtmlElement], the node in the xpath

param expression:

the xpath expression

type expression:

str

param mult:

If False, take only the first

type mult:

bool

param action:

The action to do in the xpath

type action:

str

param elements:

the list of the node from the xpath

type elements:

list[HtmlElement]

feretui.template._minify_text_and_tail(el: Element) None[source]

Minimify the text and the tail of an etree.Element.

_minify_text_and_tail(
    etree.fromstring('''
        <div>
            Minimify
            <strong> Me </strong>
            !
        </div>
    )
''')
== Etree.fromstring(
    '<div>Minimify<strong>Me</strong>!</div>'
)
Parameters:

el (etree.Element) – The node to minimify.

feretui.template.decode_html(html_string: str) str[source]

Convert html string to html string markup.

Parameters:

html_string – The html to convert

Returns:

The converted html

Return type:

str[unicode]

Exception:

UnicodeDecodeError

feretui.template.get_translated_message(text: str | None) str | None[source]

Return the text to translate.

If the text if link with a jinja command or whatever int the JINJA_REGEXES().

Parameters:

text – The initiale text or jinja commande

Returns:

The text to translate

Return type:

str

feretui.actions module

Module feretui.actions.

The actions is called by the feretui.feretui.FeretUI.execute_action().

The availlable actions are:

feretui.actions.goto(feretui: FeretUI, request: Request) str[source]

Render the page and change the url in the browser.

the page is an entry in the query string of the request.

If in-aside is in the querystring, It is mean that the page is rendering inside the page aside-menu and the url to push have to keep this information.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

feretui.actions.login_password(feretui: FeretUI, request: Request) str[source]

Login the user.

Used the LoginForm passed in the request.session.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

feretui.actions.login_signup(feretui: FeretUI, request: Request) str[source]

Signup actions.

Used the SignUpForm passed in the request.session.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

feretui.actions.logout(feretui: FeretUI, request: Request) str[source]

Logout actions.

Used the SignUpForm passed in the request.session.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

feretui.actions.resource(feretui: FeretUI, request: Request) str[source]

Resource entry point actions.

Used the SignUpForm passed in the request.session.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

feretui.pages module

Module feretui.pages.

The page is the html inside the main in the html body.

def my_page(feretui, session, options):
    vals = {
        ...
    }
    return feretui.render_template(session, 'my-page', **vals)

The availlable pages are:

To protect them in function of the user see:

  • func:

    feretui.helper.page_for_authenticated_user_or_goto

  • func:

    feretui.helper.page_for_unauthenticated_user_or_goto

feretui.pages.aside_menu(feretui: FeretUI, session: Session, options: dict) str[source]

Return the aside_page in the aside_page.

Parameters:
Returns:

The html page in

Return type:

str

Exception:

feretui.exceptions.PageError

feretui.pages.homepage(feretui: FeretUI, session: Session, options: dict) str[source]

Return the homepage.

Parameters:
Returns:

The html page in

Return type:

str

feretui.pages.login(feretui: FeretUI, session: Session, options: dict) str[source]

Return the login form page.

If the user is already authenticated, the page will be mark as forbidden.

Parameters:
Returns:

The html page in

Return type:

str

feretui.pages.page_404(feretui: FeretUI, session: Session, options: dict) str[source]

Return the page 404.

The page name is passed on the dict to display the good name to display.

Parameters:
Returns:

The html page

Return type:

str

feretui.pages.page_forbidden(feretui: FeretUI, session: Session, options: dict) str[source]

Return the page forbidden.

The page name is passed on the dict to display the good name to display.

Parameters:
Returns:

The html page

Return type:

str

feretui.pages.resource_page(feretui: FeretUI, session: Session, options: dict) str[source]

Return the resource page.

Parameters:
Returns:

The html page in

Return type:

str

Exception:

feretui.exceptions.PageError

feretui.pages.signup(feretui: FeretUI, session: Session, options: dict) str[source]

Return the signup form page.

If the user is already authenticated, the page will be mark as forbidden.

Parameters:
Returns:

The html page in

Return type:

str

feretui.pages.static_page(template_id: str) Callable[source]

Return the template linked the template_id.

Parameters:

template_id – The template_id

Returns:

The html page

Return type:

Callable

Exception:

feretui.exceptions.PageError

feretui.menus module

Menu mecanism.

Define the menu class to display its and define the actions call when the menus are clicked.

The menus are splited in two groups.

myferet.register_aside_menus('aside1', [
    AsideHeaderMenu('Menu A1', children=[
        AsideMenu('Sub Menu A11', page='submenu11'),
        AsideMenu('Sub Menu A12', page='submenu12'),
    ]),
])
myferet.register_aside_menus('aside2', [
    AsideHeaderMenu('Menu A2', children=[
        AsideMenu('Sub Menu A21', page='submenu21'),
        AsideMenu('Sub Menu A22', page='submenu22'),
    ]),
])
myferet.register_toolbar_left_menus([
    ToolBarDropDownMenu('Menu Tb1', children=[
        ToolBarMenu(
            'Menu Tb11', page="aside-menu", aside="aside1",
            aside_page='submenu11',
        ),
        ToolBarDividerMenu(),
        ToolBarMenu(
            'Menu Tb12', page="aside-menu", aside="aside2",
            aside_page='submenu22',
        ),
    ]),
    ToolBarMenu('Menu Tb2', page="my-page"),
])

Helper exist to compute the visibility:

myferet.register_toolbar_left_menus([
    ToolBarDropDownMenu('Menu Tb1', children=[
        ToolBarMenu(
            'Menu Tb11', page="aside-menu", aside="aside1",
            aside_page='submenu11',
        ),
        ToolBarDividerMenu(),
        ToolBarMenu(
            'Menu Tb12', page="aside-menu", aside="aside2",
            aside_page='submenu22',
        ),
    ], visible_callback=menu_for_authenticated_user
    ),
    ToolBarMenu(
        'Menu Tb2',
        page="my-page",
        visible_callback=menu_for_unauthenticated_user
    ),
])
class feretui.menus.AsideHeaderMenu(label: str, children: list[ToolBarMenu] | None = None, **kwargs: dict[str, str])[source]

Hieracal menu for aside.

menu = AsideHeaderMenu(
    'Label',
    children=[AsideMenu('My label')])
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'aside-header-menu'

The template id to display in the Menu.render()

class feretui.menus.AsideMenu(label: str, **kwargs: dict[str, str])[source]

Menu class for the aside menu page.

menu = AsideMenu('My label')
if menu.is_visible(session):
    menu.render(myferet, session)
get_url(feretui: FeretUI, querystring: dict[str, str]) str[source]

Return the url to put in hx-get attribute of the a tag.

Parameters:
  • feretui (feretui.feretui.FeretUI) – The feretui client instance.

  • querystring – The querysting to pass at the api

Returns:

The url

Return type:

str

template_id: str = 'aside-menu'

The template id to display in the Menu.render()

class feretui.menus.AsideUrlMenu(label: str, url: str, **kw: dict[str, str])[source]

Menu class to add a link to another web api.

menu = AsideUrlMenu('My label', url="https://bulma.io")
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'aside-url-menu'

The template id to display in the Menu.render()

class feretui.menus.ChildrenMenu(children: list[Menu])[source]

Mixin children class.

This mixin add children behaviour for:

is_visible(session: Session) bool[source]

Return True if the menu can be rendering.

Parameters:

session (feretui.session.Session) – The session of the user

Returns:

True

Return type:

bool

render(feretui: FeretUI, session: Session) str[source]

Return the html of the menu.

Parameters:
Returns:

The html

Return type:

str

class feretui.menus.Menu(label: str, icon: str | None = None, description: str | None = None, visible_callback: Callable | None = None, **querystring: dict[str, str])[source]

Mixin class Menu.

All the menu inherit this class. It is added behaviours:

  • Translated label

  • Translated description (tooltip)

  • icon

  • querystring

  • render

menu = Menu(
    'My label',
    visible_callback=menu_for_authenticated_user,
)
if menu.is_visible(session):
    menu.render(myferet, session)
get_description(feretui: FeretUI, session: Session) str[source]

Return the translated description.

Parameters:
Returns:

The description translated in the user lang

Return type:

str

get_label(feretui: FeretUI, session: Session) str[source]

Return the translated label.

Parameters:
Returns:

The label translated in the user lang

Return type:

str

get_url(feretui: FeretUI, querystring: dict[str, str]) str[source]

Return the url to put in hx-get attribute of the a tag.

Parameters:
  • feretui (feretui.feretui.FeretUI) – The feretui client instance.

  • querystring – The querysting to pass at the api

Returns:

The url

Return type:

str

is_visible(session: Session) bool[source]

Return True if the menu can be rendering.

Parameters:

session (feretui.session.Session) – The session of the user

Returns:

True

Return type:

bool

render(feretui: FeretUI, session: Session) str[source]

Return the html of the menu.

Parameters:
Returns:

The html

Return type:

str

template_id: str = None

The template id to display in the Menu.render()

class feretui.menus.ToolBarButtonMenu(label: str, css_class: str | None = None, **kwargs: dict[str, str])[source]

Menu class for the toolbar.

menu = ToolBarButtonMenu('My label')
if menu.is_visible(session):
    menu.render(myferet, session)
render(feretui: FeretUI, session: Session) str[source]

Return the html of the menu.

Parameters:
Returns:

The html

Return type:

str

template_id: str = 'toolbar-button-menu'

The template id to display in the Menu.render()

class feretui.menus.ToolBarButtonUrlMenu(label: str, url: str, visible_callback: Callable | None = None, **kw: dict[str, str])[source]

Menu class for the toolbar.

menu = ToolBarButtonUrlMenu('My label')
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'toolbar-button-url-menu'

The template id to display in the Menu.render()

class feretui.menus.ToolBarButtonsMenu(children: ToolBarMenu, visible_callback: Callable | None = None)[source]

Menu class for the toolbar.

menu = ToolBarButtonMenu([
    ToolBarButtonMenu('My label'),
])
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'toolbar-buttons-menu'

The template id to display in the Menu.render()

class feretui.menus.ToolBarDividerMenu(visible_callback: Callable | None = None)[source]

Simple Divider.

render(feretui: FeretUI, session: Session) str[source]

Return the html of the menu.

Parameters:
Returns:

The html

Return type:

str

template_id: str = 'toolbar-divider-menu'

The template id to display in the Menu.render()

class feretui.menus.ToolBarDropDownMenu(label: str, children: list[ToolBarMenu] | None = None, **kwargs: dict[str, str])[source]

DropDown for toolbar.

menu = ToolBarDropDownMenu(
    'Label',
    children=[ToolBarMenu('My label')])
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'toolbar-dropdown-menu'

The template id to display in the Menu.render()

class feretui.menus.ToolBarMenu(label: str, **kwargs: dict[str, str])[source]

Menu class for the toolbar.

menu = ToolBarMenu('My label')
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'toolbar-menu'

The template id to display in the Menu.render()

class feretui.menus.ToolBarUrlMenu(label: str, url: str, **kw: dict[str, str])[source]

Menu class to add a link to another web api.

menu = ToolBarUrlMenu('My label', url="https://bulma.io")
if menu.is_visible(session):
    menu.render(myferet, session)
template_id: str = 'toolbar-url-menu'

The template id to display in the Menu.render()

class feretui.menus.UrlMenu[source]

Mixin class for give an external url.

get_url(feretui: FeretUI, querystring: dict[str, str]) str[source]

Return the external url from the querystring.

Parameters:
  • feretui (feretui.feretui.FeretUI) – The feretui client instance.

  • querystring – The querysting to pass at the api

Returns:

The url

Return type:

str

feretui.form module

Module feretui.form.

Addons for WTForms. The form is usefull to create a formular in a page.

The class FeretUIForm are behaviour like:

The wrappers, excepted _no wrap(), added behaviours in kwargs of the __call__ method of the field:

  • readonly : Put the field in a readonly mode

  • no-label : Donc display the label but keep the bulma class in th field div

Added the also the validators

class feretui.form.FeretUIForm(*args, **kwargs)[source]

Form base class.

The goal is to give at the Form used by FeretUI the behaviour like:

  • translation

  • bulma renderer

It is not required to used it. If the translation or the renderer is not automaticly done by FeretUI.

class MyForm(FeretUIForm):
    name = StringField()
DEFAULT_WRAPPER(session: Session, field: Field, **kwargs: dict) Markup

Render input field.

Parameters:
Returns:

The renderer of the widget as html.

Return type:

Markup

class Meta[source]

Meta class.

Added * Translation * Bulma render

bind_field(form: Form, unbound_field: UnboundField, options: dict) Field[source]

Bind the field to the form.

Added translation for the field

get_translations(form: FeretUIForm) FormTranslations[source]

Return Translation class.

Parameters:

form (FeretUIForm) – The form instance

Returns:

The translation class to link feretui translation.

Return type:

FormTranslations

render_field(field: Field, render_kw: dict) Markup[source]

Render the field.

Parameters:

field (Field) – The field to render

Returns:

The renderer of the widget as html.

Return type:

Markup

classmethod export_catalog(translation: Translation, po: POFile) None[source]

Export the Form translation in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

classmethod get_context() str[source]

Return the context for the translation.

classmethod register_translation(message: str) str[source]

Register a translation come from validator.

Some text is defined in the validator or WTForms addons. They can not be export easily. This register give the possibility for the devloper to define their.

class feretui.form.FormTranslations(form: FeretUIForm)[source]

Class who did the link between Form and FeretUI translations.

gettext(string: str) str[source]

Return the translation.

ngettext(singular: str, plural: str, n: int) str[source]

Return the translation.

class feretui.form.Password(min_size: int = 12, max_size: int | None = None, has_lowercase: bool = True, has_uppercase: bool = True, has_letters: bool = True, has_digits: bool = True, has_symbols: bool = True, has_spaces: bool = False)[source]

Password validator.

It is a generic validator for WTForms. It is based on the library password-validator.

class MyForm(Form):
    password = PasswordField(validators=[Password()])
Parameters:
  • min_size (int) – The minimal size of the password. If None then no minimal size.

  • max_size (int) – The maximal size. If None then no maximal size.

  • has_lowercase (bool) – If True the password must have one or more lowercase. If False the password must not have any lowercase If None no rule on the lowercase

  • has_uppercase (bool) – If True the password must have one or more uppercase. If False the password must not have any uppercase If None no rule on the uppercase

  • has_letters (bool) – If True the password must have one or more letters. If False the password must not have any letters If None no rule on the letters

  • has_digits (bool) – If True the password must have one or more digits. If False the password must not have any digits If None no rule on the digits

  • has_symbols (bool) – If True the password must have one or more symbols. If False the password must not have any symbols If None no rule on the symbols

  • has_spaces (bool) – If True the password must have one or more spaces. If False the password must not have any spaces If None no rule on the spaces

feretui.form.get_field_translations(form_cls: Form, unbound_field: UnboundField, options: dict, callback: Callable) tuple[tuple, dict][source]

Find the attribute to translate and apply the callback.

feretui.form.gettext(form: Form, string: str, context_suffix: str = '') str[source]

Translate the string.

feretui.form.no_wrap(feretui: FeretUI, session: Session, field: Field, **kwargs: dict) Markup[source]

Render the field widget.

Parameters:
Returns:

The renderer of the widget as html.

Return type:

Markup

feretui.form.wrap_bool(feretui: FeretUI, session: Session, field: Field, **kwargs: dict) Markup[source]

Render boolean field.

Parameters:
Returns:

The renderer of the widget as html.

Return type:

Markup

feretui.form.wrap_input(feretui: FeretUI, session: Session, field: Field, **kwargs: dict) Markup[source]

Render input field.

Parameters:
Returns:

The renderer of the widget as html.

Return type:

Markup

feretui.form.wrap_radio(feretui: FeretUI, session: Session, field: Field, **kwargs: dict) Markup[source]

Render radio field.

Parameters:
Returns:

The renderer of the widget as html.

Return type:

Markup

feretui.resources modules

Resource modules.

The resource is generally a set of views (page and form). This view construct the page and define the render and the action for the resource.

To help the contruction of the view some mixins exist:

The decorator feretui.feretui.FeretUI.register_resource() call the feretui.resources.resource.Resource.build() method and register the resource in feretui.

@myferet.register_resource()
class MyResource(LResource, Resource):
    code = 'the identifier of the resource'
    label = 'The label'

To add the resource in the toolbar menu, an attribute exist in the Resource class (only if build).

myferet.register_toolbar_left_menus([
    MyResource.menu,
])
class feretui.resources.LCRUDResource[source]

LCRUDResource class.

This class is a mixin, it inherit the mixins:

class MetaViewCreate[source]

Meta view class for create.

class MetaViewDelete[source]

Meta view class for delete.

class MetaViewList[source]

Meta view class for list.

class MetaViewRead[source]

Meta view class for read.

class MetaViewUpdate[source]

Meta view class for update.

Module feretui.resource.

The main class to create a resource.

class feretui.resources.resource.Resource[source]

Resource class.

class Form[source]

The Form class.

static action_security(func: Callable) Callable

Raise an exception if the user is not authenticated.

It is a decorator

@myferet.register_action
@action_for_authenticated_user
def my_action(feretui, request):
    return Response(...)
Returns:

a wrapper function:

Return type:

Callable

Exception:

ActionUserIsNotAuthenticatedError

classmethod build() None[source]

Build the additional part of the resource.

build_view(view_cls_name: str) View[source]

Return the view instance in fonction of the MetaView attributes.

Parameters:

view_cls_name (str) – name of the meta attribute

Returns:

An instance of the view

Return type:

feretui.resources.view.View

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

get_label(feretui: FeretUI, session: Session) str[source]

Return the translated label.

Parameters:
Return type:

str.

get_meta_view_class(view_cls_name: str) list[source]

Return all the meta view class.

Parameters:

view_cls_name (Class) – The name of the meta class

Returns:

list of the class

Return type:

list

render(feretui: FeretUI, session: Session, options: dict) str[source]

Render the resource.

Parameters:
Returns:

The html page in

Return type:

str.

router(feretui: FeretUI, request: Request) Response[source]

Resource entry point actions.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

Module feretui.responses.view.

The main class to construct a view

class feretui.resources.view.View(resource: Resource)[source]

View class.

class Form[source]

Form class.

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

get_form_cls() FeretUIForm[source]

Return the Form for the view.

get_label(feretui: FeretUI, session: Session) str[source]

Return the translated label.

Parameters:
Return type:

str.

get_transition_url(feretui: FeretUI, options: dict, **kwargs: dict[str, str]) str[source]

Return the query string of a transition.

Parameters:
  • feretui (feretui.feretui.FeretUI) – The feretui client

  • options (dict) – the main query string

  • kwargs (dict) – the new entries

Returns:

The querystring

Return type:

str.

goto(feretui: FeretUI, request: Request) Response[source]

Change the view type and renderer it.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

render(feretui: FeretUI, session: Session, options: dict) str[source]

Render the view.

Parameters:
Returns:

The html page in

Return type:

str.

class feretui.resources.view.ViewForm[source]

View Form for translation.

classmethod get_context() str[source]

Return the context for the translation.

feretui.resources.view.view_action_validator(methods: list[RequestMethod] | None = None) Callable[source]

Validate the action callback.

class MyView:

    @view_action_validator(methods=[RequestMethod.POST])
    def my_action(self, feretui, request):
        return Response(...)

Note

The response of the callback must be a feretui.response.Response

Parameters:

methods (list[feretui.request.RequestMethod]) – The request methods of the action, if None the action can be called with any request method, else allow only the defined request methods.

Returns:

a wrapper function:

Return type:

Callable

feretui.resources.common’s module.

class feretui.resources.common.ActionsMixinForView(*args: tuple, **kwargs: dict)[source]

ActionsMixinForView class.

Render the actions buttons aside

call(feretui: FeretUI, request: Request) Response[source]

Call a method on the resource.

Note

If the method called return None then the view is rerendering

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

Exception:

ViewActionError

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

get_actions(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the actionset list renderer.

Parameters:
Returns:

The html pages

Return type:

list[str]

get_call_kwargs(request: Request) dict[source]

Return the kwargs for the call with this view.

Parameters:

request (feretui.request.Request) – request params

Returns:

the kwargs from params

Return type:

dict

class feretui.resources.common.LabelMixinForView[source]

LabelMixinForView class.

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

get_label(feretui: FeretUI, session: Session) str[source]

Return the translated label.

Parameters:
Return type:

str.

class feretui.resources.common.MultiView(*args: tuple, **kwargs: dict)[source]

MultiView class.

Render the buttons for view multi.

class Filter[source]

Filter’s Form.

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

filters(feretui: FeretUI, request: Request) Response[source]

Change the filters and rerender.

The type of modification of the filter depend of the request method:

  • POST : add a filter

  • DELETE : remove a filter

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

get_actions(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the actionset list renderer.

Parameters:
Returns:

The html pages

Return type:

list[str]

get_filter_cls() FeretUIForm[source]

Return the Filter Form for the view.

get_header_buttons(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the buttons for the multi view.

Parameters:
Returns:

The html pages

Return type:

list[Markup]

goto_delete(feretui: FeretUI, request: Request) Response[source]

Goto the delete page.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

pagination(feretui: FeretUI, request: Request) Response[source]

Change the pagination call by the resource router.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

render_kwargs(feretui: FeretUI, session: Session, options: dict) dict[source]

Return the dict of parameter need for the muti view.

Parameters:
Returns:

the named attributes

Return type:

dict

class feretui.resources.common.TemplateMixinForView[source]

TemplateMixinForView class.

compile(node: Element) Element[source]

Transform the template to add some javascript behaviours.

Parameters:

node (HtmlElement) – The main node to transform

Returns:

new node

Return type:

HtmlElement

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

get_compiled_template(feretui: FeretUI, session: Session, template_id: str) str[source]

Get the template for this view.

Parameters:
get_header_buttons(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the buttons for the multi view.

Parameters:
Returns:

The html pages

Return type:

list[Markup].

render(feretui: FeretUI, session: Session, options: dict) str[source]

Render the view.

Parameters:
Returns:

The html page in

Return type:

str.

render_kwargs(feretui: FeretUI, session: Session, options: dict) dict[source]

Get kwarg of the view for render.

Parameters:
Returns:

The kwargs

Return type:

dict.

set_body_template(feretui: FeretUI, session: Session, parent: Element) Element[source]

Add the body template.

Parameters:

Add the footer template.

Parameters:
set_form_template(feretui: FeretUI, session: Session, parent: Element) Element[source]

Add the form node in the template.

Parameters:
set_header_template(feretui: FeretUI, session: Session, parent: Element) None[source]

Add the header template.

Parameters:

feretui.resources.actions’s module.

Declare the actions.

class feretui.resources.actions.Action(label: str, method: str, icon: str | None = None, description: str | None = None, visible_callback: Callable | None = None)[source]

Action class.

Define an action in actionset in the view meta.

get_url(feretui: FeretUI, session: Session, options: dict) str[source]

Return the hx-post url.

Parameters:
Returns:

The html

Return type:

Markup

is_visible(session: Session) bool[source]

Return True is the action should be displayed.

Parameters:

session (feretui.session.Session) – The session of the user

Return type:

bool

render(feretui: FeretUI, session: Session, options: dict, resource_code: str, view_code: str) Markup[source]

Return the html of the action.

Parameters:
Returns:

The html

Return type:

Markup

class feretui.resources.actions.ActionI18nMixin[source]

Mixin to declare and get the translation.

export_catalog(translation: Translation, po: POFile) None[source]

Export the menu translation in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

get_description() str[source]

Return the translated description.

Returns:

The label translated in the user lang

Return type:

str

get_label() str[source]

Return the translated label.

Returns:

The label translated in the user lang

Return type:

str

class feretui.resources.actions.Actionset(label: str, actions: list[Action], icon: str | None = None, description: str | None = None)[source]

Actionset class.

The Actionset is a set of action with a label.

This need to group the action in the same place

export_catalog(translation: Translation, po: POFile) None[source]

Export the translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

is_visible(session: Session) bool[source]

Return True is the action should be displayed.

Parameters:

session (feretui.session.Session) – The session of the user

Return type:

bool

render(feretui: FeretUI, session: Session, options: dict, resource_code: str, view_code: str) Markup[source]

Return the html of the action.

Parameters:
  • feretui (feretui.feretui.FeretUI) – The feretui client instance.

  • session (feretui.session.Session) – The session of the user

  • options (dict) – The querystring

  • resource_code (str) – the code of the resource

  • view_code (str) – the code of the view

Returns:

The html

Return type:

Markup

class feretui.resources.actions.GotoViewAction(label: str, view: str, icon: str | None = None, description: str | None = None, visible_callback: Callable | None = None)[source]

Action class.

Define an action in actionset in the view meta.

get_url(feretui: FeretUI, session: Session, options: dict) str[source]

Return the hx-post url.

Parameters:
Returns:

The html

Return type:

Markup

class feretui.resources.actions.SelectedRowsAction(label: str, method: str, icon: str | None = None, description: str | None = None, visible_callback: Callable | None = None)[source]

SelectedRowsAction class.

This action is not disabled when an entry is selected.

Module feretui.resources.list.

The List resource represent data under html table.

myferet.register_resource(
)
class MyResource(LResource, Resource):
    code = 'code of the resource',
    label = 'label',

    class MetaViewList:
        pass
class feretui.resources.list.DefaultViewList[source]

Default value for the view list.

class feretui.resources.list.LResource[source]

LResource class.

MetaViewList

alias of DefaultViewList

build_view(view_cls_name: str) Resource[source]

Return the view instance in fonction of the MetaView attributes.

Parameters:

view_cls_name (str) – name of the meta attribute

Returns:

An instance of the view

Return type:

feretui.resources.view.View

filtered_reads(form_cls: FeretUIForm, filters: list[tuple[str, list[str]]], offset: int, limit: int) dict[source]

Return the dataset of the list.

should return a dict with 2 key * forms: list of instance of form_cls * total: number of the exisinting entries without offset and limit

Warning

must be overwriting

Parameters:
  • form_cls (feretui.form.FeretUIForm) – Form of the list view

  • filters (list[tuple[str, list[str]]]) – The filters choosen in the list

  • offset (int) – The start of the plage of the dataset

  • limit (int) – The size of the plage of the dataset

Returns:

the dataset

Return type:

dict

class feretui.resources.list.ListView(*args: tuple, **kwargs: dict)[source]

List view.

get_call_kwargs(request: Request) dict[source]

Return the kwargs of the call method.

render(feretui: FeretUI, session: Session, options: dict) str[source]

Render the view.

Parameters:
Returns:

The html page in

Return type:

str.

widget(field: Field, **kwargs: dict) Markup[source]

Render the field for the view list.

feretui.resources.list.span_widget(field: Field) Markup[source]

Render a field in the td node.

Parameters:

field – The field of the form to render.

Type:

Field

Returns:

The html

Return type:

Markup

Module feretui.resources.list.

The List resource represent data under html table.

myferet.register_resource()
class MyResource(CResource, Resource):
    code = 'code of the resource',
    label = 'label',

    class MetaViewCreate:
        pass
class feretui.resources.create.CResource[source]

CResource class.

MetaViewCreate

alias of DefaultViewCreate

build_view(view_cls_name: str) Resource[source]

Return the view instance in fonction of the MetaView attributes.

Parameters:

view_cls_name (str) – name of the meta attribute

Returns:

An instance of the view

Return type:

feretui.resources.view.View

create(form: FeretUIForm) str[source]

Create an object from the form and return the primary key.

Warning

must be overwriting

Parameters:

form (feretui.form.FeretUIForm) – The instance of Form

Returns:

The primary key

Return type:

str

class feretui.resources.create.CreateView(resource: Resource)[source]

Create view.

get_header_buttons(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the buttons for the multi view.

Parameters:
Returns:

The html pages

Return type:

list[Markup]

render_kwargs(feretui: FeretUI, session: Session, options: dict) dict[source]

Get kwarg of the view for render.

Parameters:
Returns:

The kwargs

Return type:

dict.

save(feretui: FeretUI, request: Request) Response[source]

Change the pagination call by the resource router.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

set_form_template(feretui: FeretUI, session: Session, parent: Element) Element[source]

Add the form node in the template.

Parameters:
class feretui.resources.create.DefaultViewCreate[source]

Default value for the view read.

Module feretui.resources.list.

The List resource represent data under html table.

myferet.register_resource()
class MyResource(RResource, Resource):
    code = 'code of the resource',
    label = 'label',

    class MetaViewRead:
        pass
class feretui.resources.read.DefaultViewRead[source]

Default value for the view read.

class feretui.resources.read.RResource[source]

RResource class.

MetaViewRead

alias of DefaultViewRead

build_view(view_cls_name: str) Resource[source]

Return the view instance in fonction of the MetaView attributes.

Parameters:

view_cls_name (str) – name of the meta attribute

Returns:

An instance of the view

Return type:

feretui.resources.view.View

read(form_cls: FeretUIForm, pk: str) FeretUIForm[source]

Return an intance of the form.

Warning

must be overwriting

Parameters:
Returns:

the form instance

class feretui.resources.read.ReadView(*args: tuple, **kwargs: dict)[source]

Read view.

get_call_kwargs(request: Request) dict[source]

Return the kwargs of the call method.

get_header_buttons(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the buttons for the multi view.

Parameters:
Returns:

The html pages

Return type:

list[Markup]

render_kwargs(feretui: FeretUI, session: Session, options: dict) dict[source]

Get kwarg of the view for render.

Parameters:
Returns:

The kwargs

Return type:

dict.

set_body_template(feretui: FeretUI, session: Session, form: Element) None[source]

Add the body template.

Parameters:

Module feretui.resources.list.

The List resource represent data under html table.

myferet.register_resource()
class MyResource(CResource, Resource):
    code = 'code of the resource',
    label = 'label',

    class MetaViewCreate:
        pass
class feretui.resources.update.DefaultViewUpdate[source]

Default value for the view read.

class feretui.resources.update.EditView(resource: Resource)[source]

Create view.

get_header_buttons(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the buttons for the multi view.

Parameters:
Returns:

The html pages

Return type:

list[Markup]

render_kwargs(feretui: FeretUI, session: Session, options: dict) dict[source]

Get kwarg of the view for render.

Parameters:
Returns:

The kwargs

Return type:

dict.

save(feretui: FeretUI, request: Request) Response[source]

Change the pagination call by the resource router.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

set_form_template(feretui: FeretUI, session: Session, parent: Element) Element[source]

Add the form node in the template.

Parameters:
class feretui.resources.update.UResource[source]

UResource class.

MetaViewUpdate

alias of DefaultViewUpdate

build_view(view_cls_name: str) Resource[source]

Return the view instance in fonction of the MetaView attributes.

Parameters:

view_cls_name (str) – name of the meta attribute

Returns:

An instance of the view

Return type:

feretui.resources.view.View

read(form_cls: FeretUIForm, pk: str) FeretUIForm[source]

Return an intance of the form.

Warning

must be overwriting

Parameters:
Returns:

the form instance

update(forms: list[FeretUIForm]) None[source]

Update an object from the form.

Warning

must be overwriting

Parameters:

form (feretui.form.FeretUIForm) – The instance of Form

Module feretui.resources.list.

The List resource represent data under html table.

myferet.register_resource()
class MyResource(DResource, Resource):
    code = 'code of the resource',
    label = 'label',

    class MetaViewDelete:
        pass
class feretui.resources.delete.DResource[source]

DResource class.

MetaViewDelete

alias of DefaultViewDelete

build_view(view_cls_name: str) Resource[source]

Return the view instance in fonction of the MetaView attributes.

Parameters:

view_cls_name (str) – name of the meta attribute

Returns:

An instance of the view

Return type:

feretui.resources.view.View

delete(pks: list[str]) None[source]

Delete an object from the pks.

Warning

must be overwriting

Parameters:

pks (list[str]) – The primary keys

class feretui.resources.delete.DefaultViewDelete[source]

Default value for the view delete.

class feretui.resources.delete.DeleteView(resource: Resource)[source]

Delete view.

delete(feretui: FeretUI, request: Request) Response[source]

Change the pagination call by the resource router.

Parameters:
Returns:

The page to display

Return type:

feretui.response.Response

get_header_buttons(feretui: FeretUI, session: Session, options: dict) list[Markup][source]

Return the buttons for the multi view.

Parameters:
Returns:

The html pages

Return type:

list[Markup]

get_label_from_pks(pks: list[str]) list[str][source]

Return the label of the primary keys.

render_kwargs(feretui: FeretUI, session: Session, options: dict) dict[source]

Get kwarg of the view for render.

Parameters:
Returns:

The kwargs

Return type:

dict.

set_form_template(feretui: FeretUI, session: Session, parent: Element) Element[source]

Add the form node in the template.

Parameters:

feretui.helper module

Module feretui.helper.

The helper is function to help the integration of the client in an another project.

feretui.helper.action_for_authenticated_user(func: Callable) Callable[source]

Raise an exception if the user is not authenticated.

It is a decorator

@myferet.register_action
@action_for_authenticated_user
def my_action(feretui, request):
    return Response(...)
Returns:

a wrapper function:

Return type:

Callable

Exception:

ActionUserIsNotAuthenticatedError

feretui.helper.action_for_unauthenticated_user(func: Callable) Callable[source]

Raise an exception if the user is authenticated.

It is a decorator

@myferet.register_action
@action_for_unauthenticated_user
def my_action(feretui, request):
    return Response(...)
Returns:

a wrapper function:

Return type:

Callable

Exception:

ActionUserIsAuthenticatedError

feretui.helper.action_validator(methods: list[RequestMethod] | None = None) Callable[source]

Validate the action callback.

@myferet.register_action
@action_validator(methods=[RequestMethod.POST])
def my_action(feretui, request):
    return Response(...)

Note

The response of the callback must be a feretui.response.Response

Parameters:

methods (list[feretui.request.RequestMethod]) – The request methods of the action, if None the action can be called with any request method, else allow only the defined request methods.

Returns:

a wrapper function:

Return type:

Callable

feretui.helper.menu_for_authenticated_user(session: Session) bool[source]

Return True if the user is authenticated.

See the feretui.menus.Menu

Parameters:

session (feretui.session.Session) – The user session

Returns:

True if the user is authenticated

Return type:

bool

feretui.helper.menu_for_unauthenticated_user(session: Session) bool[source]

Return True if the user is not authenticated.

See the feretui.menus.Menu

Parameters:

session (feretui.session.Session) – The user session

Returns:

True if the user is not authenticated

Return type:

bool

feretui.helper.page_for_authenticated_user_or_goto(fallback_page: str | Callable) Callable[source]

Display the decorated page if the user is authenticated.

In the case or the user is not autenticated. The returned page is the fallback page.

@page_for_authenticated_user_or_goto('404')
def my_page(myferet, session, options):
    ...
Parameters:

fallback_page (str or the callable page) – The page if the user is not authenticated

Returns:

a decorator

Return type:

Callable

feretui.helper.page_for_unauthenticated_user_or_goto(fallback_page: str | Callable) Callable[source]

Display the decorated page if the user is not authenticated.

In the case or the user is autenticated. The returned page is the fallback page.

@page_for_unauthenticated_user_or_goto('forbidden')
def my_page(myferet, session, options):
    ...
Parameters:

fallback_page (str or the callable page) – The page if the user is authenticated

Returns:

a decorator

Return type:

Callable

feretui.thread module

feretui.translation module

Module feretui.translation.

The translation mechanism is used to translate the user interface.

The translation files is store in po file. To translate the pot in each language with PoEdit.

The translated object are:

The Translation class have two methods to manipulate the catalogs:

class feretui.translation.TranslatedFileTemplate(template_path: str, addons: str = 'feretui')[source]

TranslatedFileTemplate class.

Declare a template file as translatable. The instance is used to defined the template files where take the entries to export in the catalog

mytranslation = TranslatedFileTemplate(
    'path/of/the/teplate',
    'my.addons'
)

translation.add_translated_template(mytranslation)

To declare a TranslatedFileTemplate more easily, a helper exist on FeretUI feretui.feretui.FeretUI.import_templates_file().

Attributes

  • [path:str] : the template file path

  • [addons:str] : the addons of the template file

param template_path:

the template file path

type template_path:

str

param addons:

The addons where the message come from

type addons:

str

load(template: Template) None[source]

Load the template in the template instance.

Parameters:

template (feretui.template.Template) – template instance

class feretui.translation.TranslatedForm(form: FeretUIForm, addons: str = 'feretui')[source]

TranslatedForm class.

Declare a WTForm as translatable.

mytranslatedmenu = TranslatedForm(MyForm, 'my.addons')
translation.add_translated_form(mytranslation)

To declare a TranslatedForm more easily, The helpers exist on FeretUI :

Attributes

  • [form:FeretUIForm] : the form to translated

  • [addons:str] : the addons of the template file

param form:

the form class to translate

type form:

feretui.form.FeretUIForm

param addons:

The addons where the message come from

type addons:

str

export_catalog(translation: Translation, po: POFile) None[source]

Export the form translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

class feretui.translation.TranslatedMenu(menu: Menu, addons: str = 'feretui')[source]

TranslatedMenu class.

Declare a menu as translatable. The instance is used to defined the menu targeted to be exported in the catalog

mytranslatedmenu = TranslatedMenu(mymenu, 'my.addons')
translation.add_translated_menu(mytranslation)

To declare a TranslatedMenu more easily, The helpers exist on FeretUI :

Attributes

  • [menu:Menu] : the menu to translated

  • [addons:str] : the addons of the template file

param menu:

the menu to translate

type menu:

feretui.menus.Menu

param addons:

The addons where the message come from

type addons:

str

export_catalog(translation: Translation, po: POFile) None[source]

Export the menu translation in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

class feretui.translation.TranslatedResource(resource: Resource, addons: str = 'feretui')[source]

TranslatedForm class.

Declare a resource as translatable.

MyResource.build()
myresource = MyResource('Code', 'The label')
translation.add_translated_resource(myresource)

To declare a TranslatedForm more easily, The helpers exist on FeretUI :

Attributes

  • [resource:Resource] : the resource to translated

  • [addons:str] : the addons of the template file

param resource:

the resource instance to translate

type resource:

feretui.resource.Resource

param addons:

The addons where the message come from

type addons:

str

export_catalog(translation: Translation, po: POFile) None[source]

Export the resource translations in the catalog.

Parameters:
  • translation (Translation) – The translation instance to add also inside it.

  • po (PoFile) – The catalog instance

class feretui.translation.TranslatedStringTemplate(template: str, addons: str = 'feretui')[source]

TranslatedStringTemplate class.

Declare a template str as translatable. The instance is used to defined the template str where take the entries to export in the catalog

mytranslation = TranslatedStringTemplate(
    '''
      <template id="my-teplate">
         ...
      </template>
    ''',
    'my.addons'
)

translation.add_translated_template(mytranslation)

To declare a TranslatedStringTemplate more easily, a helper exist on FeretUI feretui.feretui.FeretUI.register_page().

Attributes

  • [path:str] : the template file path

  • [addons:str] : the addons of the template file

param template_path:

the template file path

type template_path:

str

param addons:

The addons where the message come from

type addons:

str

load(template: Template) None[source]

Load the template in the template instance.

Parameters:

template (feretui.template.Template) – template instance

class feretui.translation.TranslatedTemplate(addons: str = 'feretui')[source]

TranslatedTemplate class.

Declare a template. The instance is used to defined the template files where take the entries to export in the catalog

mytranslation = TranslatedTemplate('my.addons')
Translation.add_translated_template(mytranslation)

Attributes

  • [addons:str] : the addons of the template file

param addons:

The addons where the message come from

type addons:

str

load(template: Template) None[source]

Load the template in the template instance.

Parameters:

template (feretui.template.Template) – template instance

Exceptions:

TranslationError

class feretui.translation.Translation(feretui: FeretUI)[source]

Translation class.

This class is used to manipulate translation.

Warning

The behaviour work with thread local

add_translated_form(form: TranslatedForm) None[source]

Add in forms a TranslatedForm.

Parameters:

form (TranslatedForm) – The Form.

add_translated_menu(menu: TranslatedMenu) None[source]

Add in menus a TranslatedMenu.

Parameters:

menu (TranslatedMenu) – The menu.

add_translated_resource(resource: TranslatedResource) None[source]

Add in forms a TranslatedResource.

Parameters:

resource (TranslatedResource) – The resource instance.

add_translated_template(template: TranslatedTemplate) None[source]

Add in templates a TranslatedTemplate.

Parameters:

template (TranslatedTemplate) – The template.

define(context: str, message: str) POEntry[source]

Create a POEntry for a message.

Parameters:
  • context (str) – The context in the catalog

  • message (str) – The original message

Returns:

The poentry

Return type:

POEntry

export_catalog(output_path: str, version: str, addons: str | None = None) None[source]

Export a catalog template.

Parameters:
  • output_path (str) – The path where write the catalog

  • version (str) – The version of the catalog

  • addons (str) – The addons where the message come from

get(lang: str, context: str, message: str, message_as_default: bool = True) str[source]

Get the translated message from translations.

Parameters:
  • lang (str) – The language code

  • context (str) – The context in the catalog

  • message (str) – The original message

  • message_as_default (bool) – If True then when no translation is found it is return the message else return None

Returns:

The translated message

Return type:

str

has_lang(lang: str) bool[source]

Return True the lang is declared.

Parameters:

lang (str) – The language tested

Returns:

The verification

Return type:

bool

load_catalog(catalog_path: str, lang: str) None[source]

Load a catalog in translations.

Parameters:
  • catalog_path (str) – Path of the catalog

  • lang (str) – Language code

set(lang: str, poentry: POEntry) None[source]

Add a new translation in translations.

Parameters:
  • lang (str) – The language code

  • poentry (POEntry) – The poentry defined

feretui.exceptions module

Module feretui.exceptions.

Get the exceptions known by FeretUI:

exception feretui.exceptions.ActionAuthenticationError[source]

Exception raised by action mecanism in FeretUI object.

Inherits ActionError.

exception feretui.exceptions.ActionError[source]

Exception raised by action mecanism in FeretUI object.

Inherits FeretUIError.

exception feretui.exceptions.ActionUserIsAuthenticatedError[source]

Exception raised by action mecanism in FeretUI object.

Inherits ActionAuthenticationError.

exception feretui.exceptions.ActionUserIsNotAuthenticatedError[source]

Exception raised by action mecanism in FeretUI object.

Inherits ActionAuthenticationError.

exception feretui.exceptions.ActionValidatorError[source]

Exception raised by action mecanism in FeretUI object.

Inherits ActionError.

exception feretui.exceptions.FeretUIError[source]

Main exception of FeretUI.

exception feretui.exceptions.MenuError[source]

Exception raised by menu mecanism in FeretUI object.

Inherits FeretUIError.

exception feretui.exceptions.PageError[source]

Exception raised by page mecanism in FeretUI object.

Inherits FeretUIError.

exception feretui.exceptions.RequestError[source]

Exception raised by Request object.

Inherits FeretUIError.

exception feretui.exceptions.RequestFormError[source]

Exception raised by Request object.

Inherits RequestError.

exception feretui.exceptions.RequestNoSessionError[source]

Exception raised by Request object.

Inherits RequestSessionError.

exception feretui.exceptions.RequestSessionError[source]

Exception raised by Request object.

Inherits RequestError.

exception feretui.exceptions.RequestWrongSessionError[source]

Exception raised by Request object.

Inherits RequestSessionError.

exception feretui.exceptions.ResourceError[source]

Exception raised by resource mecanism in FeretUI object.

Inherits FeretUIError.

exception feretui.exceptions.TemplateError[source]

Exception raised by Template object.

Inherits FeretUIError.

exception feretui.exceptions.TranslationError[source]

Exception raised by Translation object.

Inherits FeretUIError.

exception feretui.exceptions.TranslationFormError[source]

Exception raised by Translation object.

Inherits TranslationError.

exception feretui.exceptions.TranslationMenuError[source]

Exception raised by Translation object.

Inherits TranslationError.

exception feretui.exceptions.TranslationResourceError[source]

Exception raised by Translation object.

Inherits TranslationError.

exception feretui.exceptions.UnexistingActionError[source]

Exception raised by action mecanism in FeretUI object.

Inherits ActionError.

exception feretui.exceptions.UnexistingResourceError[source]

Exception raised by resource mecanism in FeretUI object.

Inherits ResourceError.

exception feretui.exceptions.ViewActionError[source]

Exception raised by resource mecanism in FeretUI object.

Inherits ViewError.

exception feretui.exceptions.ViewError[source]

Exception raised by resource mecanism in FeretUI object.

Inherits ResourceError.

exception feretui.exceptions.ViewFormError[source]

Exception raised by resource mecanism in FeretUI object.

Inherits ViewError.