References

Module stricto. export all classes

class stricto.GenericType(**kwargs)

Bases: object

Generic Type This is the main Object for Int, Float, String, …

Parameters:

**kwargs

  • constraint= func – a function to check if the value is admissible

  • constraints= [func] – a list of function to check if the value is admissible

  • default= Any – default value

  • description= str – a description of this field (like a comment)

  • exists= bool|func – answer if this field exists or not

  • in= [Any] – a list of available values

  • require= bool – if this field cannot be None

  • onChange= func – A function to trig when the value change

  • set= func – a compute value

  • transform= func – a function to modify the value BEFORE affectation

  • views= [str] – list of views Access-list

am_i_root() bool

Check if this object is the root object

Parameters:

self – Description

Returns:

Description

Return type:

bool

can_modify() bool

check right “modify”

can_read() bool

check right “read”

check(value: Any) None

check if the value complain to model. Throw an Error if Not

Parameters:
  • self – Description

  • value (Any) – the value to check

Raises:
check_type(value: Any) None

Check if the type is correct. must be overwritten

copy() Self

wrapper for copy.copy

Parameters:

self – Description

Returns:

a new GenericType with is the copy of this object

Return type:

Self

disable_permissions() None

set permissions to off

enable_permissions() None

set permissions to on

exists(value: Any) bool

Return True if the object Exist, othewise False. exist can be a function to make this field dependant from the value of another

Parameters:
  • self – Description

  • value (str) – don’t remember

Returns:

if this object exists

Return type:

bool

exists_or_can_read() bool

check first if the object exists. Then check if can be read. return True otherwise False

Parameters:

self – Description

Returns:

if the object exost and can be read

Return type:

bool

get_current_meta(parent: dict = None) dict

Return a schema with all rights correctly set depending on fonctions

Parameters:
  • self – Description

  • parent (dict) – Not used

Returns:

return: the schema as a json object (dict)

Raises:

SSyntaxError – this function must be called at root only

Return type:

dict

get_root() Self

Return the root object

Parameters:

self – Description

Returns:

The root object

Return type:

GenericType

get_schema() dict

Return a schema for this object

Parameters:

self – Description

Returns:

the schema as a json object (dict)

Return type:

dict

Return a schema for this object

get_value() Any

return the value in this object

Parameters:

self – Description

Returns:

The value

Return type:

Any

get_view(view_name: str, final: bool = True) Any

Return all elements belonging to view_name The result is a subset of this object

Parameters:
  • self – Description

  • view_name (str) – the named view

  • final (not used) – Description

Returns:

Description

Return type:

Any

Examples:
  • +view1 - Want all fields with “view1”

  • view1 - Want all fields except thoses with “!view1”

is_allowed_to(right_name: str) bool

check the right “right_name”

Parameters:
  • self – Description

  • right_name (str) – the name of the right to check

Returns:

True if have right, or False

Return type:

bool

match(other)

Check if equality

multi_select(selector_as_list_of_string: list[str]) list[Self] | None

selectors: a list of selector

Parameters:
  • self – Description

  • selector_as_list_of_string (list[str]) – selectors

Returns:

a list of objects

Return type:

list[Self] | None

Example:
  • [ "$.name", "$.address.town" ]

parent: Self

parent is a reference to the parent GenericType

patch(op: str, selector: str, value=None) None

patch is modifying a value. see https://datatracker.ietf.org/doc/html/rfc6902

Parameters:
  • self – Description

  • op (str) – Descthe operator

  • selector (str) – the path to find and modify

  • value – Description

Raises:
path_name() str

return a string with the name of the object according to RFC 9535 (https://datatracker.ietf.org/doc/rfc9535/)

Parameters:

self – Description

Returns:

the path string

Return type:

str

rollback() None

reset to the old value

Parameters:

self – Description

select(selector_as_string: str) Self | None

Get values with selector acording to rfc 9535 (https://datatracker.ietf.org/doc/rfc9535/)

Parameters:
  • self – Description

  • selector_as_string (str) – the rfc 9535

Returns:

The object matched.

Return type:

Self | None

Example:
  • $.address.street

  • $.surname[0]

set(value: Any) None

Fill with a value or raise an Error if not valid

Parameters:
  • self – Description

  • value (Any) – the valut to set in

Raises:

SAttributeError – try to modify an non existing object

set_value_without_checks(value: Any) None

Set the value without any check. Please use carrefully and prefer set()

Parameters:
  • self – Description

  • value (Any) – the value to set

Raises:
trigg(event_name: str, from_id: str, **kwargs) None

trig an event from_id is an id to avoid the event to call itself

Parameters:
  • self – Description

  • event_name (str) – the name of the event

  • from_id (str) – the id of the object who trigg the event

  • kwargs – Description

class stricto.Bool(**kwargs)

Bases: GenericType

Boolean type

Parameters:

**kwargs – See GenericType

class stricto.Dict(schema: dict, **kwargs)

Bases: GenericType

A Dict Type

add_to_model(key, model)

add new element to the model

check(value) None

check if the value complain to model. Throw an Error if Not

Parameters:
  • self – Description

  • value (Any) – the value to check

Raises:
check_type(value)

check if conplain to model or raise an

disable_permissions()

set permissions to off

enable_permissions()

set permissions to on

get(key: str, default=None)

return the value of a key

get_current_meta(parent: dict = None)

Return a schema for this object

get_old_value()

Return the previous version of values

get_selectors(index_or_slice, sel: Selector)

get with selector as lists selectors_as_list is a list of tuples like ( “a” , 0 ) -> a[0] ( “toto”, None ) -> toto

get_value()

return the value

get_view(view_name, final=True)

Return all elements belonging to view_name tue return is a subset of this Dict

keys()

return all keys

match(other: dict) bool

Check if equality with an object example : me : { a : 12, b : 13, c : 14 } match { b : 13 } -> True match { a : 11 } -> False match { a : 12, c : 14 } -> True

remove_model(key)

remove a key Model to the model

rollback()

reset to the old value

set_value_without_checks(value)

Set the value without any check. Please use carrefully and prefer set()

Parameters:
  • self – Description

  • value (Any) – the value to set

Raises:
trigg(event_name, from_id=None, **kwargs)

trigg an event

class stricto.Extend(type_for_extend, **kwargs)

Bases: GenericType

A Extent type for any types type

check_type(value)

Check if the type is correct. must be overwritten

class stricto.Float(**kwargs)

Bases: GenericType

Float type

Parameters:

**kwargs – See GenericType

Specifics Arguments:
  • min (float) – a minimal value

  • max (float) – a maximal value

check_type(value: Any) None

see GenericType.check_type()

class stricto.Int(**kwargs)

Bases: GenericType

A Int type

check_type(value)

Check if the type is correct. must be overwritten

class stricto.List(class_type: None, **kwargs)

Bases: ListAndTuple

A Dict Type

append(value)

Do a List.append(value) like list.append(value)

check(value) None

check if the value complain to model. Throw an Error if Not

Parameters:
  • self – Description

  • value (Any) – the value to check

Raises:
check_type(value)

check if conplain to model or return a error string

clear()

Do List.clear() as list.clear() (with checks)

duplicate_in_list()

Copy the list self._value to another list used to check() on this list before modification

extend(second_list)

Do a List.extend(second_list) like list.extend(second_list)

get_current_meta(parent: dict = None)

Return a schema for this object

get_selectors(index_or_slice: str, sel: Selector)

get with selector as lists

get_value()

@overwrite GenericType.get_value()

insert(key, value)

Do a list.insert()

match(other)

Check if equality with an object example : me : [ 12, 13, 14 ] match [ 12 ] -> False match [ 12, 13 ] -> False match [ 12, 13, 14 ] -> True

patch_internal(op: str, value)

patch is modifying a value. equivalent to set for a generic https://datatracker.ietf.org/doc/html/rfc6902

if op == remove , the value is the key index to remove

pop(key=-1)

Do a List.pop() like list.pop()

remove(value)

Do a List.remove(value) like list.remove(value)

reset_attribute_name()

the list is reordonned (added, supression, …) the attribute name must be reset

set_value_without_checks(value)

@overwrite GenericType.setWithoutcheck

sort(**kwarg)

Do a sort(List) like sort(list)

trigg(event_name, from_id=None, **kwargs)

trigg an event

class stricto.String(**kwargs)

Bases: GenericType

A generic type (class for int, string, etc)

check_type(value)

Check if the type is correct. must be overwritten

class stricto.Tuple(schema: tuple, **kwargs)

Bases: ListAndTuple

A Tuple Type

check(value) None

check if the value complain to model. Throw an Error if Not

Parameters:
  • self – Description

  • value (Any) – the value to check

Raises:
check_type(value)

check if conplain to model or raise an

get_current_meta(parent: dict = None)

Return a schema for this object

get_selectors(index_or_slice, sel: Selector)

get with selector in tuple

get_value()

get the value

match(other)

Check if equality with an object

set_value_without_checks(value)

Set the value without any check. Please use carrefully and prefer set()

Parameters:
  • self – Description

  • value (Any) – the value to set

Raises:
trigg(event_name, from_id=None, **kwargs)

trigg an event