Hacker News new | ask | show | jobs
by aforwardslash 1056 days ago
Haven't used panther myself, but I've chosen to use other solutions instead of FastAPI because tends to be the usual python soup mess on multi-modular projects. Also, I dislike pydantic quite a lot (I know, it works well for many use cases, its not a bad library), and usually use a three tier (presentation-service-data), DI-driven approach to development, which is largely incompatible with most python framework approaches. So, I've been building pretty much all the required layers on top of some of the Flask functionality for http (mostly the router and the dispatcher).

Also, building a framework is also a nice way of understanding how the sausages are made :)

1 comments

> and usually use a three tier (presentation-service-data), DI-driven approach to development...

For web I love this approach and have moved more towards this myself.

Pydantic has it's place in my opinion, there are other packages that do a similar thing and for most use cases you can roll your own pretty effectively. For me that place is marshalling on the wire data to a typed custom data type with validation. Whether you are using JSON, or {binary format}.

You likely need to write the validation code yourself since you should be validating from the database as well.

So there we go, I am anti ORM as well.

Anything relates to the request should be handled at the "request layer" which in my case is flask(werkzeus) and maybe per request DB connection should be created at that layer.

Everything else should be in a business layer, that way which framework you use doesn't matter and can be trivially replaced with something else.

I forgot to add that most of my "custom" implementations are also open-source, to avoid repeating the same boilerplate over and over at different places. Its not "pythonic", and it is at varying degrees of maturity, and honestly, they are mostly for internal use in my projects (documentation is incomplete, interfaces may change, etc), but if you want have a look:

https://github.com/oddbit-project/rick_db - postgresql query builder & object mapper - it is built around the concept of pure data objects (no indirect references do open resources) that can represent application data between layers; It also features a forward-only migration manager;

https://github.com/oddbit-project/rick - plumbing, validation & assorted logic - provides service locators, registries, containers (including dependency injection); validators, forms & request validation (with support for laravel-style validation chains), and a bunch of other stuff;

https://github.com/oddbit-project/pokie - flask-based web meta-framework, focused on REST api design, that brings components from the other two projects into an modular applicational framework;