ae.oaio_model
Our Asynchronously Interchangeable Objects Data Structures
Module Attributes
create, delete and update rights, see access_right field in Pubz and Userz |
|
delete and update rights |
|
only update rights |
|
read-only access |
|
no or not yet granted access right (not valid for Pubz.access_right) |
|
access rights (stored in the access_right db column of the Pubz table). |
|
object got deleted, not used in Logz.action field (records get deleted instead) |
|
object got downloaded/synced |
|
oaio got registered |
|
object got uploaded/updated |
|
see Logz.action field |
|
oaio values key of optional object name |
|
oaio values key of optional files root path |
|
oaio values key of paths list of optional files attached to an oaio |
|
name of folder to store infos of oai objects not yet synced with server |
|
name of folder to store file names attached to an oaio |
|
user name |
|
app id |
|
device id |
|
maximum accepted UTC time difference in seconds between client and server |
|
oldest complete stamp ("" is even older) |
|
stamp format string |
|
|
return the current UTC timestamp as string (to use as suffix for file and variable/attribute names). |
register/upload/download. |
|
oaio access rights ( |
|
app id |
|
cloud storage host id |
|
dict-like mapping keeping the oaio-specific http header field names and values |
|
device id |
|
type of oai object converted into a dictionary |
|
item type of the |
|
oai object id |
|
default root path (containing |
|
oaio stamp |
|
Userz.Uid/auth.User.username |
|
oaio client_values and server_values |
Functions
|
decode and return the request/session http header context fields containing user/device/app ids. |
|
encode the extra http header context fields with user/device/app ids as ASCII/latin1 byte literals. |
|
convert OaiObject dataclass instance into the corresponding mapping/dict object. |
|
generate object id (of type OaioIdType) from the specified arguments. |
|
determine the difference in seconds between the two specified stamps in the format %Y%m%d%H%M%S%f. |
Classes
|
oaio data types and structures |
- CREATE_ACCESS_RIGHT = 'C'
create, delete and update rights, see access_right field in Pubz and Userz
- DELETE_ACCESS_RIGHT = 'D'
delete and update rights
- UPDATE_ACCESS_RIGHT = 'U'
only update rights
- READ_ACCESS_RIGHT = 'r'
read-only access
- NO_ACCESS_RIGHT = 'x'
no or not yet granted access right (not valid for Pubz.access_right)
- ACCESS_RIGHTS = ('C', 'D', 'r', 'U')
access rights (stored in the access_right db column of the Pubz table). access right names and their translations are provided, using the text prefix ‘access_right’ followed by an underscore and the access right character, in the optional loc//Msg.txt files provided by the
ae.i18nportion
- DELETE_ACTION = 'delete'
object got deleted, not used in Logz.action field (records get deleted instead)
- DOWNLOAD_ACTION = 'download'
object got downloaded/synced
- REGISTER_ACTION = 'register'
oaio got registered
- UPLOAD_ACTION = 'upload'
object got uploaded/updated
- LOG_DB_ACTIONS = ('register', 'upload', 'download')
see Logz.action field
- NAME_VALUES_KEY = '_name'
oaio values key of optional object name
- ROOT_VALUES_KEY = '_root_path'
oaio values key of optional files root path
- FILES_VALUES_KEY = '_file_paths'
oaio values key of paths list of optional files attached to an oaio
- OBJECTS_DIR = 'objz'
name of folder to store infos of oai objects not yet synced with server
- FILES_DIR = 'filez'
name of folder to store file names attached to an oaio
- HTTP_HEADER_USR_ID = 'X-OAIO-user'
user name
- HTTP_HEADER_APP_ID = 'X-OAIO-app'
app id
- HTTP_HEADER_DVC_ID = 'X-OAIO-dvc'
device id
- MAX_STAMP_DIFF = 69.0
maximum accepted UTC time difference in seconds between client and server
- OLDEST_SYNC_STAMP = '20221231111111012345'
oldest complete stamp (”” is even older)
- STAMP_FORMAT = '%Y%m%d%H%M%S%f'
stamp format string
- ActionType
register/upload/download… action type
- OaioAccessRightType
oaio access rights (
oaio_server.oapi.models.Pubz.access_right)
- OaioAppIdType
app id
- OaioCshIdType
cloud storage host id
- OaioCtxType
dict-like mapping keeping the oaio-specific http header field names and values
- OaioDeviceIdType
device id
- OaioFilesType
item type of the
FILES_VALUES_KEYwithinOaiObject.client_values
- OaioIdType
oai object id
- OaioRootPathType
default root path (containing
PATH_PLACEHOLDERS)
- OaioStampType
oaio stamp
- OaioUserIdType
Userz.Uid/auth.User.username
- class OaiObject(oaio_id, client_stamp='', server_stamp='', client_values=<factory>, server_values=<factory>, csh_id=None, username='', device_id='', app_id='', csh_access_right='')[source]
Bases:
objectoaio data types and structures
- oaio_id: str
object id string (created by
object_id())
- __dataclass_fields__ = {'app_id': Field(name='app_id',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'client_stamp': Field(name='client_stamp',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'client_values': Field(name='client_values',type=dict[str, typing.Any],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'csh_access_right': Field(name='csh_access_right',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'csh_id': Field(name='csh_id',type=typing.Optional[str],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'device_id': Field(name='device_id',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'oaio_id': Field(name='oaio_id',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'server_stamp': Field(name='server_stamp',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'server_values': Field(name='server_values',type=dict[str, typing.Any],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'username': Field(name='username',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)
- __eq__(other)
Return self==value.
- __hash__ = None
- __init__(oaio_id, client_stamp='', server_stamp='', client_values=<factory>, server_values=<factory>, csh_id=None, username='', device_id='', app_id='', csh_access_right='')
- __match_args__ = ('oaio_id', 'client_stamp', 'server_stamp', 'client_values', 'server_values', 'csh_id', 'username', 'device_id', 'app_id', 'csh_access_right')
- __repr__()
Return repr(self).
- context_decode(header)[source]
decode and return the request/session http header context fields containing user/device/app ids.
- context_encode(user_name, device_id, app_id='')[source]
encode the extra http header context fields with user/device/app ids as ASCII/latin1 byte literals.
- Parameters:
- Return type:
- Returns:
mapping with http header context field names/values (each of them with Unicode chars will be encoded as UTF8-byte-value-literal using only ASCII/latin-1 characters).
- object_dict(oai_obj)[source]
convert OaiObject dataclass instance into the corresponding mapping/dict object.
- object_id(user_name, device_id, app_id, stamp, values)[source]
generate object id (of type OaioIdType) from the specified arguments.
- Parameters:
- Return type:
- Returns:
oai object id converted by
defuse()to be usable as filename on most OS.- Raises:
AssertionError if one of the following arguments is empty:
object_id.user_name,object_id.device_id,object_id.app_idorobject_id.stamp.