Skip to main content

Build Status Coverage Status

ZSL - z' service layer

ZSL is a Python micro-framework utilizing dependency injection for creating service applications on top of Flask web framework and Gearman job server or Celery task queue.

Motivation

We developed ZSL to modernize our workflow with maintaining our clients' mostly web applications written in various older CMS solutions without the need to rewrite them significantly. With ZSL we can write our new components in Python, with one coherent shared codebase, accessible trough Gearman or JavaScript. Also the same code can be called through various endpoints - web or task queue nowadays.

Disclaimer

At current stage this should be taken as proof of concept. We don't recommend to run in any production except ours. It is too rigid, with minimum test coverage and lots of bad code practices. We open sourced it as way of motivation for us to make it better.

Installation

We recommend to install it trough PyPi and run it in a virtualenv or docker container.

$ pip install zsl

Getting started

For now it is a bit cumbersome to get it running. It has inherited settings trough ENV variables from Flask and has a rigid directory structure like django apps. On top of that, it needs a database and Redis.

The minimum application layout has to contain:

.
├── app                    # application sources
│   ├── __init__.py
│   └── tasks              # public tasks
│       ├── hello.py
│       └── __init__.py
├── settings               # settings
│   ├── app_settings.cfg
│   ├── default_settings.py
│   └── __init__.py
└── tests
$ export ZSL_SETTINGS=`pwd`/settings/app_settings.cfg
# settings/app_settings.cfg

TASKS = TaskConfiguration()\
        .create_namespace('task')\
            .add_packages(['app.tasks'])\
            .get_configuration()
RESOURCE_PACKAGE = ()
DATABASE_URI = 'postgresql://postgres:postgres@localhost/postgres'
DATABASE_ENGINE_PROPS = {}
SERVICE_INJECTION = ()
REDIS = {
    'host': 'localhost',
    'port': 6379,
    'db': 0
}
RELOAD = True
# hello.py

class HelloWorldTask:
    def perform(self, data):
        return "Hello World"
$ python -m zsl web
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
$ curl http://localhost:5000/task/hello/hello_world_task
Hello world!

Deploying

Deploy will happen upon pushing a new tag to Gitlab.

Creating new tag/version

Use bump2version to update version in config files. It will also create commit and new tag.

$ bumpversion --new-version ${VERSION} {major|minor|patch} --tag-name ${VERSION}

Version name uses semver. Starts with number.

Pipeline

Current pipeline tries to copy previous Travis runs. It runs tox target seperately and on a tag push will create deploy.

Tox Docker image

Gitlab pipeline runs inside a docker image which is defined in docker/Dockerfile.tox. Currently we manually configure, build and push it to gitlab container registry. So to update the container follow this steps.

When pushing for the first time run, you have to create an access token and login to atteq gitlab container registry. Go to https://gitlab.atteq.com/atteq/z-service-layer/zsl/-/settings/access_tokens and create a token to read/write to registry. Then run

docker login registry.gitlab.atteq.com:443

To build/push the image:

  1. Build image locally.

    docker build -t zsl/tox-env -f docker/Dockerfile.tox .

  2. Tag image.

    docker tag zsl/tox-env registry.gitlab.atteq.com:443/atteq/z-service-layer/zsl/tox-env:latest

  3. Push image.

    docker push registry.gitlab.atteq.com:443/atteq/z-service-layer/zsl/tox-env:latest

  4. Update image hash in .gitlab-ci.yml. (copy from build output or docker images --digests).

Metadata

Release files for zsl 1.7.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zsl 1.7.5
File Size Uploaded
zsl-1.7.5.tar.gz 122.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zsl 1.7.5
File Interpreter ABI Platform
zsl-1.7.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 248.9 kB

Release files / zsl-1.7.5.tar.gz

Download URL zsl-1.7.5.tar.gz
Size 122.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1f8efa7ccd3d4a543d921263508d3451cde1b9207ea8388ebc0ad6545709dab0
BLAKE2b-256 checksum
How to use checksums
4032d5bd6f89bb7e60ff76147ed9ba9bd88d0b65406da28405a3fc24b6d69a02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / zsl-1.7.5-py2.py3-none-any.whl

Download URL zsl-1.7.5-py2.py3-none-any.whl
Size 126.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
277550bd15f4667aacb699db3a88a7d5215d60ac4c07ccfdb1fbbb3e0004514f
BLAKE2b-256 checksum
How to use checksums
86974c079e330394cca3246516f4797e90e06b71088271503e0bd5fdd407431a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.7.5 This release

2 release files

1.7.3

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.30.0

2 release files

0.29.0

2 release files

0.27.0

2 release files

0.22.2

2 release files

0.22.1

1 release file

0.22.0

1 release file

0.21.1

1 release file

0.20.0

1 release file

0.19.7

1 release file

0.19.6

1 release file

0.19.5

1 release file

0.19.4

1 release file

0.19.3

1 release file

0.19.2

1 release file

0.19.1

1 release file

0.19.0

1 release file

0.18.5

1 release file

0.18.4

1 release file

0.18.3

1 release file

0.18.2

1 release file

0.18.1

1 release file

0.18.0

1 release file

0.17.8

1 release file

0.17.7

1 release file

0.17.6

1 release file

0.17.5

1 release file

0.17.4

1 release file

0.17.3

1 release file

0.17.2

1 release file

0.17.1

1 release file

0.17.0

1 release file

0.16.11

1 release file

0.16.10

1 release file

0.16.8

1 release file

0.16.7

1 release file

0.16.6

1 release file

0.16.5

1 release file

0.16.3

1 release file

0.16.2

1 release file

0.16.0

1 release file

0.15.9

1 release file

0.15.8

1 release file

0.15.7

1 release file

0.15.6

1 release file

0.15.5

1 release file

0.15.3

1 release file

0.15.2

1 release file

0.15.1

1 release file

0.13.1

1 release file

0.13.0

1 release file

0.9

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page