Antano » Antano Server API » Message
Antano® will be released very soon. This is an announcement text

Contents

Search

Message

class entities.Message(_params, _service, _address)

Bases: entities.Entity

Message class will pack and unpack all messages for given MessageFormat This can be MsgPack as well as JSON and later on also XML

Parameters:{Object} -- Inherits from Object class (object) –

Methods Summary

check_base() Checks base for mismatches
extract_entity(_message, _service, _address, …) extract an entity out of the message
get_entity_prefix() get current entity prefix
get_entity_table() gets current table
get_from_db() Get the current val from db
get_sql_string(_value) Mini helper for getting sql converted string
get_sql_variables() Little helper for getting sql conform variables
get_vars(_prefix) Gets all variables for an entity
handle_found(_found) Handles all client messages for found on this process
handle_not_found(_not_found) Handles all not found clients on this process by passing it to another process
pack_message(message_dict, _format_id) packs a message with a given dict and a format id
pass_through(_message, _service) passes through a message to an entity
post_process() PostProcessing like sending an created message via entity
prepare_message_data() In order to get well prepared data on sending message
process_message(_message, _service, …) Processes the message and creates a new entity of a specific type like Client, Message etc
rollback() simple function for rollback current db transitions
save() save current entity in db
save_base_entity([_update]) saves the base entity
save_sub_entity(_table, _inserts, _values, …) saves any sub entity with given params
select_from(_table, _columns[, _condition]) Simple select from helper db
send_message() Finally send the message to the client
unpack_message(message_bytes, _format_id) unpacks message from different format types like msgpack and json returns a codeable dict
update_sub_entity(_table, _updates, _condition) Updates each sub entity like custom_fields etc

Methods Documentation

check_base()

Checks base for mismatches

Raises:
  • error – mismatch, not found
  • Exception – String
Returns:

bool – changed or not

static extract_entity(_message, _service, _address, _sock_stream)

extract an entity out of the message

Parameters:
  • {Dict<String,obj>} -- current message (_message) –
  • {Service obj} -- current _service (_service) –
  • {Sring} -- current _ip host address (_address) –
Returns:

_entity{Entity obj} – specific entity

static get_entity_prefix()

get current entity prefix

Returns:String – current prefix
static get_entity_table()

gets current table

Returns:String – entity table contant
get_from_db()

Get the current val from db

static get_sql_string(_value)

Mini helper for getting sql converted string

Parameters:{mixed} -- a value (_value) –
Returns:String – sql conform string
get_sql_variables()

Little helper for getting sql conform variables

Returns:String – result of sql variabls
get_vars(_prefix)

Gets all variables for an entity

Returns:Array<String> – all vars
handle_found(_found)

Handles all client messages for found on this process

Parameters:{List<int>} -- list of client ids (_found) –
handle_not_found(_not_found)

Handles all not found clients on this process by passing it to another process

Parameters:{List<int>} -- ids of not found (_not_found) –
Raises:Exception – ClientException
static pack_message(message_dict, _format_id)

packs a message with a given dict and a format id

Parameters:
  • {Dict<String, Obj>} -- assoc MessageDict (message_dict) –
  • {Int} -- MessageFormatID (_format_id) –
Returns:

bytes[] – packs message in bytes array

static pass_through(_message, _service)

passes through a message to an entity

Parameters:
  • {Dict<String, obj>} -- common message dict (_message) –
  • {Service obj} -- current service (_service) –
post_process()

PostProcessing like sending an created message via entity

prepare_message_data()

In order to get well prepared data on sending message

Returns:Dict<String, obj – prepared message dict
static process_message(_message, _service, _address, _sock_stream)

Processes the message and creates a new entity of a specific type like Client, Message etc

Parameters:
  • {bytes[]} -- current message data (_message) –
  • {Service obj} -- current _service (_service) –
  • {Sring} -- current _ip host address (_address) –
Returns:

(entity{Entity obj},response{Dict<String,obj>}) – tuple of entity and response

rollback()

simple function for rollback current db transitions

save()

save current entity in db

save_base_entity(_update=False)

saves the base entity

Keyword Arguments:
 {bool} -- [wether update or insert] (default (_update) – {False})
save_sub_entity(_table, _inserts, _values, _returning, _multi=False)

saves any sub entity with given params

Parameters:
  • {String} -- table name (_table) –
  • {String} -- comma separated insert columns (_inserts) –
  • {String} -- comma separated values (_values) –
  • {String} -- field to return (_returning) –
Keyword Arguments:
 

{bool} -- wether multi or single values (default (_multi) – {False})

Returns:

Array – fetch on returning id/s

select_from(_table, _columns, _condition=None)

Simple select from helper db

Parameters:
  • {String} -- From Table select (_table) –
  • {String} -- Columns to select (_columns) –
Keyword Arguments:
 

{String} -- optinal condition to add (default (_condition) – {None})

Returns:

Array db – current select fetch from db

send_message()

Finally send the message to the client

static unpack_message(message_bytes, _format_id)

unpacks message from different format types like msgpack and json returns a codeable dict

Parameters:
  • {bytes[]} -- bytes array message (message_bytes) –
  • {Int} -- message format_id (_format_id) –
Returns:

Dict<Stirng,obj> – generated dict assoc

update_sub_entity(_table, _updates, _condition)

Updates each sub entity like custom_fields etc

Parameters:
  • {String} -- table string (_table) –
  • {String} -- Update-conform string for sql (_updates) –
  • {String} -- condition clause (_condition) –
Last update: 10/08/2020 3:43 a.m. (CET)