Skip to main content

Flying Ion's observable, routable, data serialisation and transport code.

Project description

VortexPY

Flying Ion's observable, routable, data serialisation and transport code.

See README_PERMISSIONS.md for the two-level permission system (endpoint guards + access control context) introduced in v5.0.

Why PY at the end? To be consistent with VortexJS, which is the Browser side package. See https://gitlab.com/flyingion/vortexjs

Requirements:

  • Python 3.5
  • Twisted 16+
  • SQLAlchemy 1, 1.1

The "vortex" is designed to transport "Payloads" from a web browser (VortexJS) to a twisted web server (VortexPY). There is also a python client for python client to python server communication.

Vortex, The Observable Part

Vortex was designed to allow the Python server to send updates to the browser with out the browser having to create HTTP request polls.

This is achieved by the browser/client sending one or more payloads to the server as a HTTP POST, the server then uses this connection to send payloads back to the client.

This HTTP POST connection remains active, Until the client needs to send more Payloads to the server. To do this, the client simply starts a new HTTP POST request to the server, the server will then close the old request and begin sending Payloads down the respose path of the new request.

Python classes = Vortex

Transport

Transport occurs over a HTTP(S) layer.

Experimental classes are present to transport data to/from subprocess pipes, this worked, except the subprocess didn't die and the idea was abandoned (It was a Celery worker).

Because of this effort, it's much easier to add other transport mechanisms.

Python classes = VortexResource (Receive), VortexConnection (Send)

Payloads

A "Payload" is a class that stores some routing information, a result and a list of "Tuples".

The routing information is a dict / json object which looks like this {key:"anything.type.of.data.list"} (See Routable for more info)

The tuples attribute stores the data, typically this is a list of Tuple (see Tuples) objects, however, it can be any data structure that JSON can serialise, plus Date()/datetime.

The Payload class is responsible for serialising and compressing it's data down to a "Vortex Msg", ready for transport. Compression is done with zlib, this imrpovement sees data reduced to 10% of the original size.

There is custom code that handles converting the structure to JSON objects for json.dumps so support can be (carefully) added for other data types such as bytes.

Python classes = Payload

Tuples

Not to be confused with the built in Python tuple syntax (1, 2, 3), Tuples are registered classes with registered attributes.

Vortex Tuples are important in the design as classes that inherit the vortex Tuple class will reconstructed as the proper classes at the other end in python. They will have onlt the fields registerd as TupleFields populated when they are reconstructed.

This is especially useful when using the SQLAlchemy ORM, as the Tuple code recognises column definitions as TupleFields.

You can just assign session.query(MyTable).all() to payload.tuples, and the vortex will know how to serialise.

From here you can send it do the browser, where the browser may edit some attributes of the tuples, then send it back to the python server to update the database. (More on this in Handlers)

Python classes = Tuple, TupleField

Routable

When a vortex receives a payload, it is sent to the PayloadIO

The PayloadIO, then passes it on to each PayloadEndpoint that has registered with it.

Payload routing ends with PayloadEndpoints, These endpoints are constructed with another filter dict/json like object, and a callback.

When PayloadIO tells a PaylaodEndpoint that a new Payload has arrived, the PayloadEndpoint checks the Payload.filt against it's own filt.

If the PayloadEndpoints filt is a subset of the Payload.filt, the PayloadEndpoint then calls it's callable and passes it the Payload.

PayloadEndpoints register them selves with PayloadIO on construction. PayloadIO keeps a list of weak refs to the PayloadEndpoints.

Payloads contain a "filt" attribute, which is a json like dict/object.

Python classes = PayloadEndpoint, PayloadIO

Handlers

Handlers are the provided classes that handle data from the PayloadEndpoints.

  • ModelHandler : Simply specify the payload filter and implement the "buildModel" method.
  • OrmCrudHandler : This handler used to Create, Update, Retrieve and Delete SQLAlchemy data. It can handle an array of tuples, of different types, and has various hooks allowing the data to be customised before being stored or retreived.
  • AsyncModelHandler : Experimental handler that will likely be deleted.

#Change Log

0.3.0

Implemented PY side WebSockets

License

Copyright (c) 2016-2026 Flying Ion Pty Ltd. Released under the MIT License.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vortexpy-4.0.27.tar.gz (108.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vortexpy-4.0.27-py3-none-any.whl (159.8 kB view details)

Uploaded Python 3

File details

Details for the file vortexpy-4.0.27.tar.gz.

File metadata

  • Download URL: vortexpy-4.0.27.tar.gz
  • Upload date:
  • Size: 108.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for vortexpy-4.0.27.tar.gz
Algorithm Hash digest
SHA256 a41226f7c5e3605d420b4f060b2fcbba30aa1d272dd529119387c874eb4cfdb8
MD5 1a11ca465877e0ecce88c5c0ae0f9d57
BLAKE2b-256 4948121e0d2294ec49323f5fa21d1b02f0f23af4eb88418e6af14e8716268ecd

See more details on using hashes here.

File details

Details for the file vortexpy-4.0.27-py3-none-any.whl.

File metadata

  • Download URL: vortexpy-4.0.27-py3-none-any.whl
  • Upload date:
  • Size: 159.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for vortexpy-4.0.27-py3-none-any.whl
Algorithm Hash digest
SHA256 eb2127d96f8c64466de42f97f034964caecdc9f47f6f8a7c99d046460f3129e7
MD5 354ffd962e9bdcab39db245b60cef773
BLAKE2b-256 93ce91bfc40ab0938a2aba26b218e9dd2c35f4ac7ecbbf7211f2fad608d94d7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page