ERPBlok framework

Homepage controller

erpblok.client.homepage.get_homepage(request)

Redirect the homepage to the good page

if connected, redirect to the application page if databases found, redirect to the login page else redirect to the database manager

Client controller

erpblok.client.web.load_client(request)

Return the client main page

Login controllers

erpblok.client.login.get_login(request, database=None)

Display the login page

erpblok.client.login.get_login_logo(request)

Return the logo for thelogin page

erpblok.client.login.get_databases(request)
erpblok.client.login.post_login_connect(request)

Log the user, if the login and password are right

Return type:redirection if login/password is right else HTTPUnauthorized
erpblok.client.login.post_login_disconnect(request, database=None)

Logout the current user and do a redirect to the login page

Database manager controllers

erpblok.client.database.check_allow_database_manager()

raise an execption if the database manager is unactive :exception: pyramid.httpexceptions.HTTPNotFound

erpblok.client.database.check_db_manager_password(password)
erpblok.client.database.get_database(request)

Return the main page of the database manager

erpblok.client.database.get_menus(request)
erpblok.client.database.get_addons(request)
erpblok.client.database.get_databases(request)
erpblok.client.database.post_create_database(request)

Create a new database, and initialize it

Return type:Redirection to the client
erpblok.client.database.post_drop_database(request)

Drop the database

erpblok.client.database.post_list_database(request)

Return the html of the select node with the list of the database

Common functions

erpblok.client.common.list_databases()

return the name of the databases found in the BDD

the result can be filtering by the Configuration entry db_filter

..warning:

For the moment only the ``prostgresql`` dialect is available
Return type:list of the database’s names
erpblok.client.common.create_database(database)

Create a new database, initialize it and return an AnyBlok registry

Param:database’s name
Return type:AnyBlok registry instance
erpblok.client.common.drop_database(database)

Close the registry instance of the database and drop the database

Param:database’s name
erpblok.client.common.login_user(request, database, login, password, user_id)

Log the user

The informations of the user are saved in the request if the user is found by is login and is password.

Parameters:
  • database – the database where the user want to be connected
  • login – user login
  • password – user password
Type:

boolean, True if the user is founed else False

erpblok.client.common.logout(request)

Remove the user information of the login

erpblok.client.common.format_static(blok, static_url)

Replace the attribute #BLOK by the real name of the blok

Parameters:
  • blok – the blok’s name
  • static_url – the url to format
Return type:

str, formated url

erpblok.client.common.get_static(static_type)

Get in the Blok definition the static data from the client

Parameters:static – entry to read: css, js, ...
Return type:list of str
erpblok.client.common.get_templates_from(attr)

Template definition module

exception erpblok.client.template.TemplateException

Bases: Exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class erpblok.client.template.Template(*args, **kwargs)

Bases: object

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()
tmpl.get_all_template()
clean()

Erase all the known templates

compile()

compile all the templates

compile_template(name)

compile a specific template

Parameters:name – id str of the template
decode(element)

Decode some element need for the web template

Parameters:element – string representation of the element
Return type:str
encode(element)

Encode the templating commande

Parameters:element – string representation of the element
Return type:str
get_all_template()

Return all the template in string format

get_template(name, tostring=True)

return a specific template

Parameters:name – name of the template
Return type:str
get_xpath(element)

Find and return the xpath found in the template

Parameters:element – html.Element
Return type:list of dict
get_xpath_attributes(elements)

Find and return the attibute

load_file(openedfile)

Load a file

File format

<templates>
    <template id="...">
        ...
    </template>
</templates>
Parameters:openedfile – file descriptor
Exception:TemplateException
load_template(element)

Load one specific template

Parameters:element – html.Element
Exception:TemplateException
xpath(name, expression, mult)

Apply the xpath

xpath_attributes(name, expression, mult, attributes)

Apply a xpath attributes:

<template id="..." extend="other template">
    <xpath expresion="..." action="attributes">
        <attribute key="value"/>
        <attribute foo="bar"/>
    </xpath>
</template>
Parameters:
  • name – name of the template
  • expresion – xpath regex to find the good node
  • mult – If true, xpath can apply on all the element found
Attributes:

attributes to apply

xpath_insert(name, expression, mult, elements)

Apply a xpath insert:

<template id="..." extend="other template">
    <xpath expresion="..." action="insert">
        ...
    </xpath>
</template>
Parameters:
  • name – name of the template
  • expresion – xpath regex to find the good node
  • mult – If true, xpath can apply on all the element found
Elements:

children of the xpath to insert

xpath_insertAfter(name, expression, mult, elements)

Apply a xpath insert:

<template id="..." extend="other template">
    <xpath expresion="..." action="insertAfter">
        ...
    </xpath>
</template>
Parameters:
  • name – name of the template
  • expresion – xpath regex to find the good node
  • mult – If true, xpath can apply on all the element found
Elements:

children of the xpath to insert

xpath_insertBefore(name, expression, mult, elements)

Apply a xpath insert:

<template id="..." extend="other template">
    <xpath expresion="..." action="insertBefore">
        ...
    </xpath>
</template>
Parameters:
  • name – name of the template
  • expresion – xpath regex to find the good node
  • mult – If true, xpath can apply on all the element found
Elements:

children of the xpath to insert

xpath_remove(name, expression, mult)

Apply a xpath remove:

<template id="..." extend="other template">
    <xpath expresion="..." action="remove"/>
</template>
Parameters:
  • name – name of the template
  • expresion – xpath regex to find the good node
  • mult – If true, xpath can apply on all the element found
xpath_replace(name, expression, mult, elements)

Apply a xpath replace:

<template id="..." extend="other template">
    <xpath expresion="..." action="replace">
        ...
    </xpath>
</template>
Parameters:
  • name – name of the template
  • expresion – xpath regex to find the good node
  • mult – If true, xpath can apply on all the element found
Elements:

children of the xpath to replace