Connectors¤
connectors ¤
Provide the abstract classes for server and content, that need to be implemented for each protocol.
Filters and actions are applied by the Server by looping over each Content object and executing the user-defined functions.
The core of the framework knows only these abstract classes.
© 2022-2023 - Aurélien Pierre
Classes¤
Content ¤
Bases: ABC
The Content class manages the decoding and parsing of individual data objects (such as posts, emails, contacts, events, etc.), as well as the data representation to be used in filters. It provides proxy methods to the Server class that can be used to perform server-side actions on the current Content object.
| PARAMETER | DESCRIPTION |
|---|---|
raw_content |
data dump from server that should be decoded, parsed and split into properties.
TYPE:
|
server |
back-reference to the
TYPE:
|
Attributes¤
server
instance-attribute
¤
Back-reference to the Server object to which the current Content belongs. In filters, users only access the Content object, so the Content.server reference is their only entry-point to the server. Use that with care and preferably wrap relevant server-side operations as Content methods, with proper arguments mapping.
Server ¤
Bases: ABC, ServerType
The Server class manages the connection to a distant host with URL, port, login and password.
Then it loads a list of individual objects, like emails or contacts, as Content type.
Attributes¤
nlp
class-attribute
instance-attribute
¤
Reference the natural language processing module for reuse in filters without imports.
utils
class-attribute
instance-attribute
¤
Reference the utility module for reuse in filters without imports.
secretary
instance-attribute
¤
Back-reference to the main [secretary.Secretary][] handler
connection_inited
instance-attribute
¤
Set to True in server implementation when a connection to the server has been inited, that is the DNS/IP has been resolved, server has been contacted and responded, credentials have been sent, and valid login session is active.
std_out
instance-attribute
¤
Cast status/success messages under the form ["OK", "details/data"]
objects
instance-attribute
¤
The iterable list of connectors.Content object fetched at runtime, upon which filters will be run in sequence.
connection_timestamp
instance-attribute
¤
Timestamp of the last successful login, useful to keep connections alive.
Todo
implement it
Functions¤
calling_file ¤
Output the name of the calling filter from the stack. Allows to find the path of the folder containing filter, to perform actions like writing logs.
It needs to be called from filter script through object proxy method, pointing to the server method, otherwise the index 2 will be wrong.
init_connection
abstractmethod
¤
Init a connection with the server and login.
This should set self.connection_inited = True on success.
run_filters
abstractmethod
¤
Loop over self.objects to execute filter() and action() on each.