# VortexPY
Synerty's observable, routable, data serialisation and transport code.
Why PY at the end? To be consistent with VortexJS, which is the Browser side package.
See https://github.com/Synerty/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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
vortexpy-1.2.5.tar.gz (65个子文件)
vortexpy-1.2.5
PKG-INFO 450B
setup.cfg 79B
vortex
VortexServer.py 8KB
handler
TupleDataObservableHandler.py 8KB
TupleDataActionClient.py 2KB
TupleDataObservableProxyHandler.py 10KB
TupleDataObserverClient.py 5KB
__init__.py 0B
TupleDataObservableCache.py 5KB
TupleActionProcessorProxy.py 6KB
TupleActionProcessor.py 6KB
VortexFactory.py 12KB
SerialiseUtil.py 6KB
VortexPayloadProtocol.py 5KB
VortexServerHttpResource.py 6KB
test
VortexTest.py 548B
PayloadTest.py 3KB
PerformTestActionTuple.py 713B
TupleTest.py 4KB
__init__.py 307B
TestTuple.py 1KB
TupleDataForTest.py 600B
PayloadEndpointTest.py 4KB
TupleDataObservableTestHandler.py 2KB
VortexClientHttpTest.py 2KB
VortexJSTupleLoaderTestHandler.py 1KB
TuplePerfTest.py 2KB
PayloadResponseTest.py 1KB
TupleActionProcessorTestHandler.py 964B
Tuple.py 15KB
VortexServerWebsocket.py 5KB
VortexServerConnection.py 2KB
VortexConnectionABC.py 2KB
sqla_orm
__init__.py 0B
TupleProviderForDb.py 1KB
OrmCrudHandler.py 13KB
PayloadEndpoint.py 5KB
__init__.py 193B
TupleAction.py 2KB
DataWrapTuple.py 552B
PayloadIO.py 4KB
VortexServerTcp.py 3KB
rpc
test
__init__.py 0B
run_server_test.py 470B
RPCTest.py 415B
run_client_test.py 830B
RPC.py 12KB
__init__.py 0B
PayloadEnvelope.py 3KB
TupleSelector.py 2KB
VortexClientHttp.py 7KB
PayloadResponse.py 5KB
DeferUtil.py 4KB
Payload.py 3KB
Jsonable.py 7KB
PayloadFilterKeys.py 319B
VortexABC.py 1KB
VortexClientTcp.py 8KB
setup.py 1KB
vortexpy.egg-info
PKG-INFO 450B
requires.txt 79B
SOURCES.txt 2KB
top_level.txt 7B
dependency_links.txt 1B
README.md 4KB
共 65 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功