Skip to content

urbn/tornado-boilerplate

 
 

Repository files navigation

tornado-boilerplate -- a standard layout for Tornado apps

Description

tornado-boilerplate is an attempt to set up an convention for Tornado app layouts, to assist in writing utilities to deploy such applications. A bit of convention can go a long way.

This app layout is the one assumed by buedafab.

Instructions

  • Clone this repository
  • cd into the repo directory
  • At the command line type:
python ./app.py

Related Projects

buedafab django-boilerplate python-webapp-etc comrade

Acknowledgements

The folks at Mozilla working on the next version of AMO were the primary inspiration for this layout.

Directory Structure

tornado-boilerplate/
    handlers/
        welcome.py
        base.py     
    logconfig/
    media/             
    templates/  
    environment.py  
    app.py
    settings.py

handlers

All of your Tornado RequestHandlers go in this directory.

Everything in this directory is added to the PYTHONPATH when the environment.py file is imported.

logconfig

An extended version of the log_settings module from Mozilla's zamboni.

This package includes an initialize_logging method meant to be called from the project's settings.py that sets Python's logging system. The default for server deployments is to log to syslog, and the default for solo development is simply to log to the console.

All of your loggers should be children of your app's root logger (defined in settings.py). This works well at the top of every file that needs logging:

import logging
logger = logging.getLogger('five.' + __name__)

media

Sub directories for media (css, images etc) can be placed in here.

templates

Project-wide templates (i.e. those not belonging to any specific app in the handlers/ folder). The boilerplate includes a welcome.html template.

environment.py

Modifies the PYTHONPATH to allow importing from the apps/, lib/ and vendor/ directories. This module is imported at the top of settings.py to make sure it runs for both local development (using Django's built-in server) and in production (run through mod-wsgi, gunicorn, etc.).

app.py

The main Tornado application, and also a runnable file that starts the Tornado server.

settings.py

A place to collect application settings ala Django. There's undoubtedly a better way to do this, considering all of the flak Django is taking lately for this global configuration. For now, it works.

Contributing

If you have improvements or bug fixes:

  • Fork the repository on GitHub
  • File an issue for the bug fix/feature request in GitHub
  • Create a topic branch
  • Push your modifications to that branch
  • Send a pull request

Authors

About

A standard layout for Tornado apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%