5 min read Author: klaas

Just do your thing!

A python web framework, build on the Ruby on Rails principles.

Generators for models, controllers, scaffolding views and database migrations. Validation, convention over configuration and much more. Focus on your thing instead of the boilerplate.

PythonOnWheels is actually more some added glue between some great existing python libraries than a full blown framework itself. Added glue means to integrate the libraries seamlessly and give you a consistent and fluent workflow.

Hello World

class HelloHandler(BaseHandler):
@route('/hello', dispatch=["get"])
def hello(self):
self.write("Hello world!")

This will route a HTTP(S)/GET request to  the URL: /hello and call the HelloHandler.hello() method.


pip install -U pythononwheels

Everything you need on board. Batteries included.

Oh no, why one more Framework?

The focus is to make your life easier for the boring tasks. 

The idea of PythonOnWheels is to include and offer the features and tools that most of the people implementing smaller to medium sized projects probably want. Therefore it includes a little more than the microFrameworks and a little less then the big enterprise frameworks out there. 

Establish a  super fluent workflow .. (using the generative ideas from ruby on rails)

PythonOnWheels integrates the superb tools, modules and libraries out there in an easy rails like workflow. The goal is to reduce your effort for configuration, boilerplate setup or coding boring and repetetive things. 

Focus on your app and your idea. Not on the application infrastructure!

To get an impression of the workflow check the 10 Minutes intro video creating a small todo app using a NoSQL DB, scaffolding bootstrap 4 views and creating a REST API.

All the helpers below are there but PythonOnWheels also gets out of the way if you want it. You can always use the underlying modules raw.

Probably the most simple SQL relations out there!

Based on sqlalchemy.

With PythonOnWheels you simply add a class decorator like 

class Post(Base):
# All your Post model code below here ..

to your SQL Post-model and every Post can have comments. It will be automatically mapped to the DB (SQLite, Postgres, MySQL, MariaDb, Oracle, MSSQL ...) and to all related comment Models. DB Migrations are created automatically in the background.

supported relation types are:

  • has_many()
  • has_many_and_belongs_to()
  • many_to_many()
  • one_to_one()
  • tree()

All pow model definitions are based on cerberus schemas.

This means you have validation on board for every model and you can easily switch from SQL to NoSQL since the schemas basics are all the same.

This is how a model schema looks like.

schema = { 
# string sqltypes can be TEXT or UNICODE or nothing
'author': {'type': 'string', 'maxlength' : 35 },
'title' : {'type': 'string', "required" : True },
'text' : {'type': 'string' },
'votes' : {'type': 'integer' },
'status': {'type': 'string', "allowed" : ["backlog", "wip", "done"] },

Probably the most simple REST routing out there. One decorator. Done!

You simply add a class decorator like 


to your handler and you get all the typical REST routes mapped to the according CRUD methods of your handler class.

By the way: this is what generate_handler generates for you when you use the --rest parameter:

class RestTest(BaseHandler):
# every pow handler automatically gets these RESTful routes
# when you add the : app.add_rest_routes() decorator.
# 1 GET /todo #=> list
# 2 GET /todo/<uuid:identifier> #=> show
# 3 GET /todo/new #=> new
# 4 GET /todo/<uuid:identifier>/edit #=> edit
# 5 GET /todo/page/<uuid:identifier> #=> page
# 6 GET /todo/search #=> search
# 7 PUT /todo/<uuid:identifier> #=> update
# 8 PUT /todo #=> update (You have to send the id as json payload)
# 9 POST /todo #=> create
# 10 DELETE /todo/<uuid:identifier> #=> destroy
# ...

Routing: RegEx and Flask like routes included.

You can set routes by simply adding a class decorator to the handler class or decorate methods directly.

@route("/", dispatch=["get"])

PythonOnWheels will then call the index method of your handler if the route and the HTTP method matches.

Example for Flask like routing

class HelloHandler(BaseHandler):
@route(r'/hello/<int:identifier>', dispatch=["get"])
def hello(self, identifier=None):
self.write("Hello world! " + str(identifier))

For Regex routes use

@app.add_route("/test/([0-9]+)*", dispatch={"get" : "test"}) 

to add a direct route: matching the regular expression : /test/([0-9+]) and then calling the given method of your handler class. The regex group ([0-9+]) will be handed as the first parameter to test(self, index)

And finally, a super easy workflow.

Quick to start and all the basics on board

  • generate_app (generates the whole app foundation for you)
  • generate_model (You probably want to store some data)
  • generate_handlers (all the logic goes here)
  • start the server (python server.py) 
  • done!

Model Validation on board with cerberus schemas. 

All Model Schemas are Cerberus schemas automatically.

    model.validate() => executes cerberus validator

So that's easy. 

The vision

If you want start to develop your web-application and focus on the App, instead of the infrastructure, you are in the right place. PythonOnWheels feels right if you do not recognize that you use it.


Check the getting started or go to the documentation