MVC web framework in Python with Gevent, Jinja2, Werkzeug, SqlAlchemy, SASS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

MVC web framework in Python with Gevent, Jinja2, Werkzeug, SQLAlchemy


Break your app to views, controllers and models. uses Django-like templates from Jinja2.
You can add your static path in settings and all css and javascript files will be minified.
Also html templates will be minified.
In css files you can use SCSS syntax.
Controller is class inherited from class Controller and may have methods get, post, put, delete.
These methods get Request object param and return Response object.
Request and Response objects inherited from Werkzeug.
There is ORM with PostgreSQL, MySQL and SQLite based on SQLAlchemy and Elixir.
Models consist of fields(class variables inherited from Field class).
There is event dispatcher named Eventer. You can subscribe to event
or publish event.
You can also create rest interfaces to your models with RestController.

from kiss.core.application import Application
from settings import options
app = Application(options)

from kiss.core.application import Application
from controllers.controller1 import Controller1
from controllers.controller2 import Controller2
from import ApplicationStarted
from import BeforeControllerAction
from kiss.models import SqliteDatabase
from kiss.core.exceptions import InternalServerError
from import PageController
from import RestController
from models.models import Blog
options = {
	"application": {
		"address": "",
		"port": 8080
	"urls": {
		"": Controller1,
		"users": {
			"(?P<user>\w+)": Controller2
		"2": {
			"3": Controller1(),
			"4": Controller2
		"3": PageController("static_view.html", {"foo": "bar"}),
		RestController(Blog).url: RestController(Blog).controller
	"views": {
		"templates_path": "views.templates",
		"static_path": "views.static"
	"events": {
		ApplicationStarted: Controller2.application_after_load,
		BeforeControllerAction: Controller2.before_controller_action,
		InternalServerError.code: Controller2.internal_server_error
	"models": {
		"engine": SqliteDatabase,
		#"host": "localhost",
		"database": path.join(current_dir, "kiss_py_project.sqldb")#,#,
		#"user": 'postgres',
		#"password": "postgres"


from kiss.models import Model, CharField, TextField, DateTimeField, BooleanField, ForeignKeyField
class Blog(Model):
	creator = CharField()
	name = CharField()
class Entry(Model):
	blog = ForeignKeyField(Blog)
	title = CharField()
	body = TextField()
	pub_date = DateTimeField()
	published = BooleanField(default=True)


from kiss.views.templates import TemplateResponse
from import Eventer
from models.models import Blog, Entry
import datetime	
class Controller2(object):
	def get(self, request):
		#publish some event
		eventer = Eventer()
		eventer.publish("some event", self)
		if not "foo" in request.session:
			request.session["foo"] = 0
		request.session["foo"] += 1
		#blog = Blog()
		blog = Blog.get(id=1) = "super blog"
		blog.creator = "Stas"
		#entry = Entry()
		entry = Entry.get(id=2) = blog
		entry.title = "super post"
		entry.body = "lkoeirsldfkwierj"
		entry.pub_date =
		return TemplateResponse("view.html", {
			"foo": request.session["foo"], 
			"users": [{"url": "", "username": "brin"}],
			"blog": blog
	#on load handler via eventer
	def application_after_load(self, application):
		print "app loaded"


		<title>{% block title %}{% endblock %}</title>
		<script src="/scripts/j.js"></script>
		{% for user in users %}
		  <li><a href="{{ user.url }}">{{ user.username }}</a></li>
		{% endfor %}


This software is licensed under the BSD License. See the license file in the top distribution directory for the full license text.