Skip to main content

This package contains Django's CBVs adapted to use with Tornado framework.

Project description

Django’s CBVs adapted to be used with Tornado along with SQLAlchemy and WTForms. It’s highly recomended to read the docs here first:


0.2: new handler - DeleteHandler
0.2.5: fixed missing context in ProcessFormHandler


The only requirement is SQLAlchemy’s session stored in application’s db attribute.

from sqlalchemy.orm import scoped_session, sessionmaker

class Application(tornado.web.Application):
    def __init__(self):
        self.db = scoped_session(sessionmaker(bind=engine))

Basic usage

from torgen.base import TemplateHandler
from torgen.list import ListHandler
from torgen.detail import DetailHandler
from torgen.edit import FormHandler, DeleteHandler
from my_alchemy_models import Post
from my_wtforms import LoginForm

class HomeHandler(TemplateHandler):
    template_name = 'home.html'

class BlogHandler(ListHandler):
    template_name = 'blog.html'
    paginate_by = 10
    context_object_name = 'post_list'
    model = Post

class PostHandler(DetailHandler):
    template_name = 'post.html'
    model = Post
    context_object_name = 'post'

class LoginHandler(FormHandler):
    template_name = 'login.html'
    form_class = LoginForm
    success_url = '/'

    def form_valid(self, form):
        return super(LoginHandler, self).form_valid(form)

class DeletePostHandler(DeleteHandler):
    template_name = 'confirm_delete.html'
    model = Post
    success_url = '/blog/'


Using pip:

$ pip install torgen

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for torgen, version 0.2.5
Filename, size File type Python version Upload date Hashes
Filename, size torgen-0.2.5.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page