python-framework

Flask wrapper


Keywords
flask, sqlalchemy, open, api, jwt, serializer, scheduler
License
MIT
Install
pip install python-framework==0.4.49

Documentation

python_framework - current on v0.1.8-2 - stable for python3.8

Basically, its a Flask wrapper

It alters Flask behaviours in order to make APIs better organized.

I did it because it's cool and makes Flask better :D

Features

  • NOT A SINGLE SERIALIZER IS NEEDED!
  • OpenApiDocumentation
  • JwtSecutiry
  • Suport for services, validators, helpers, converters, mappers, and repository
  • SqlAlchemyProxy without the need to "open connection" due to circular import issues. You call them and it works like a horse

Requirements

  • Add python_framework==0.1.0.-05 in your requirements.txt file (or python_framework==0.1.0.-post05. In some environments, life is tuff)
  • It comes with a lot of stuff. Check on setup.py. If you need a different version of some of them, you can add it bellow python_framework==0.1.0.-05

Something like this:

python_framework==0.1.0.post05
sqlalchemy==9.9.9
etc==7.0.3
so_on_so_forth==1.0.2

Package pattern

  • This package pattern makes possible automatic controller registration, controller-service-repository-etc interconnections and so on. Just follow it and/or make improvement suggestions ("could be this way", "could be that way", etc)

Package pattern

Globals.yml configuration file

globals module still requires some implementation in order to make OS variables income here. For while, it does not

Globals.yml example

app.py and MyApi.py - just copy paste and be happy

app.py

FeatureManager.py

app.py and MyApi.py

Documentation example

https://api.data-explore.com/feature-dataset-manager-api/swagger

  • No configurations needed. Just code you controllers and it will be there at GET: whathever-your-host-is/basic-deploy-url/swagger endpoint

Controller examples

Login controller

Login controller example

Feature controller

Feature controller example

Service examples

User service

User service

Feature service

Feature service

Repository examples - yes, its that simple :D

User repository

User repository

Feature repository

Feature repository

Model examples

User model

User model

Feature model

Feature model

Model association - its just to make things easier

Model association

Mapper examples

User mapper

User mapper

Feature mapper

Feature mapper

Usage examples

Notes - stable for python3.8

- v0.1.0-05

- v0.1.8-2

  • Of course it's open source
  • If you don't follow package pattern, it wont happen
  • I just hate OS environments lose all over the project. That's why I made Globals.py, so we can centralize it in there. Unfortunately, globals module isn't perfect yet. That's my next goal
  • Repository connections are much alike SqlAlchemy native syntax. So, any specific implementation can be written in SqlAlchemy native syntax. Any issue, contact me, so I can fix it.
  • Same for migrations. Use any SqlAlchemy migrations engine you like. For python_framework, a liquibase migration like is being implemented, but won't be release before 2021, july
  • The auto-serialization stuff is just magic. But it comes with a price: Models and Dtos must have all their attributes initialized with None value. I'll fix it by 2021, february
  • Yes, api code/file imports are simplified. You can move a service from one package to another without impact on API behaviour. Just make sure it's somewhere inside the service package.
  • Unit tests require instance injection in runtime. I'm implementing a module to handle it, so as its Mocks. It will be released by 2021, february
  • python_framework comes with a LogError table by default (an auditory like stuff for api errors or bad behaviours). Contact me if you don't want it, so I'll release a feature to enable it only when it's actually desired
  • Any issues with deploy, contact me so I can fix it
  • I may release further versions. Don't use them before a proper release here
  • Of course this wrapper may have bugs. Whenever you find one, issue it here. So I can fix it and make it better :D