Cloud.iO Glue
Introduction
This package is an extension to the
package providing features not present in the
implementation.
It supports the developer with the Model2CloudConnector class and the
'cloudio_attribute' decorator.
The fast and simple solution to connect an object to the cloud is to inherit
the class from CloudioNode and automatically all attributes get
synchronized to the cloud. The drawback here is that the developer does not
have the choice to prohibit the synchronisation of some attributes.
There is where the Model2CloudConnector class comes in. Inheriting from this
class allows specifying which attribute should be synchronized to the cloud
using the attribute mapping feature.
Download and Install
The library is available on python's package distribution system PyPi.
From the console you can download and install it using the following command:
pip install cloudio-glue-python
Model2CloudConnector Class
The Model2CloudConnector class allows to synchronise some attributes of a class.
Which attributes to synchronise is done with an attribute mapping.
To use the Model2CloudConnector class you need to inherit from it and then
specify which of the attributes to synchronize using the set_attribute_mapping()
method.
Attribute Mapping
Here is an example on how to bring attributes (or properties) x and y of the
ComputerMouse class to the cloud:
from cloudio.glue import Model2CloudConnector
class ComputerMouse(Model2CloudConnector):
def __init__(self):
super(ComputerMouse, self).__init__()
self._x = 0
self._y = 0
# Define the attributes which are going to be mapped to cloud.iO
self.set_attribute_mapping({'x': {'topic': 'position.x', 'attributeType': float,
'constraints': ('read',)}, # ('read', 'write')
'y': {'topic': 'position.y', 'attributeType': float,
'constraints': ('read',)},
})
@property
def x(self): return self._x
@x.setter
def x(self, value): self._x = value
@property
def y(self): return self._y
@y.setter
def y(self, value): self._y = value
Attribute Access Policy
For each attribute the access policy can be specified. Following values can be given
-
read
-
write
or both.
The read access policy allows to read the attribute from the cloud. Giving the
write access policy allows to change the attribute via the cloud.
cloudio_attribute Decorator
An attribute can be automatically synchronized to the cloud by assigning
the cloudio_attribute decorator to the property.
To assign for example the decorator to the x property change the code above as follows. Remove
the @property decorator and replace it with the @cloudio_attribute decorator.
The example below shows the @cloudio_attribute decorator applied to the x and y property:
from cloudio.glue import Model2CloudConnector
from cloudio.glue import cloudio_attribute
class ComputerMouse(Model2CloudConnector):
def __init__(self):
super(ComputerMouse, self).__init__()
self._x = 0
self._y = 0
# Define the attributes which are going to be mapped to cloud.iO
self.set_attribute_mapping({'x': {'topic': 'position.x', 'attributeType': float,
'constraints': ('read',)}, # ('read', 'write')
'y': {'topic': 'position.y', 'attributeType': float,
'constraints': ('read',)},
})
@cloudio_attribute
def x(self): return self._x
@x.setter
def x(self, value): self._x = value
@cloudio_attribute
def y(self): return self._y
@y.setter
def y(self, value): self._y = value
Now every time the x or y property gets changed, the value is automatically updated to the cloud.
Metadata
Release files for cloudio-glue-python 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cloudio-glue-python-1.0.3.tar.gz | 13.6 kB | Without provenance | Details for cloudio-glue-python-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloudio_glue_python-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for cloudio_glue_python-1.0.3-py3-none-any.whl |
Total release size: 24.5 kB
Release files / cloudio-glue-python-1.0.3.tar.gz
| Download URL | cloudio-glue-python-1.0.3.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3c4257242b59005b70e599dde4d73f5907666b9b243babd411269c3ea587aa9
|
|
BLAKE2b-256 checksum How to use checksums |
b896229425677e2ded021adf0b048a00ea2bfd55fa7402b703440b15d95035b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.2
|
Release files / cloudio_glue_python-1.0.3-py3-none-any.whl
| Download URL | cloudio_glue_python-1.0.3-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8644f539ee7f16260bc7aa10833d418ae8d19d90793d5cff3d4871a88e9828b
|
|
BLAKE2b-256 checksum How to use checksums |
a12b339717f0cf39b66a25cc2743f229bbb6adbb04ef65e81a1576d9ae210740
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.2
|
Security for cloudio-glue-python 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.