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.
@app.make_routes()
class HelloHandler(BaseHandler):
@route(r'/hello', dispatch=["get"])
def hello(self):
self.write("Hello world!")
pip install -U pythononwheels
PythonOnWheels is a generative, Rapid Application Development, non intrusive web framework for python. You need no extra tools to start. Everything from DB to Webserver and template engine is included. But you are not forced to use them and can go raw or easily include the modules and tools of your choice tools whenever you want.
Based on sqlalchemy. With PythonOnWheels you simply add a class decorator like
@relation.has_many("comments")
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.
class Post(Base):
#
# Schema definition with the new (cerberus) schema style
# which offer you immediate validation
#
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"] },
}
# init
def __init__(self, **kwargs):
self.init_on_load(**kwargs)
# your methods down here
@app.add_rest_routes("basename")
to your handler and you get all the typical REST routes mapped to the according CRUD methods of your handler class.
@app.add_rest_routes("rest_test")
class RestTest(BaseHandler):
#
# every pow handler automatically gets these RESTful routes
# when you add the : app.add_rest_routes() decorator.
#
# 1 GET /resttest #=> list
# 2 GET /resttest/<uuid:identifier> #=> show
# 3 GET /resttest/new #=> new
# 4 GET /resttest/<uuid:identifier>/edit #=> edit
# 5 GET /resttest/page/<uuid:identifier> #=> page
# 6 GET /resttest/search #=> search
# 7 PUT /resttest/<uuid:identifier> #=> update
# 8 PUT /resttest #=> update (You have to send the id as json payload)
# 9 POST /resttest #=> create
# 10 DELETE /resttest/<uuid:identifier> #=> destroy
# ...
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.
@app.make_method_routes()
class HelloHandler(BaseHandler):
@route(r'/hello/<int:identifier>', dispatch=["get"])
def hello(self, identifier=None):
self.write("Hello world! " + str(identifier))
@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)
All Model Schemas are Cerberus schemas automatically. So thats easy.
model.validate() => executes cerberus validator
And finally: a super easy workflow. Quick to start, all the basics on board and easy to expand: generative approach (but not noisy)
If you want start to develop your web-application and focus on the App, instead of the frameworks, you are in the right place. PythonOnWheels feels right if you do not recognize that you use it.
See getting started or go to the documentation