Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nek4life committed Sep 4, 2011
0 parents commit 69bd2c0
Show file tree
Hide file tree
Showing 35 changed files with 10,099 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.idea/
*.iml
*.project
*.egg-info/
*.swp
*.pyc
*.pyo
*.DS_Store
Empty file added bunsen/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions bunsen/paster_templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from paste.deploy.converters import asbool
from paste.script.templates import var
from paste.util.template import paste_script_template_renderer
from pyramid.paster import PyramidTemplate

class BunsenTemplate(PyramidTemplate):
_template_dir = "pyramid_template"
summary = "A Pyramid project setup with URL Dispatch, Jinja2, SQLAlchemy, WTForms and more."
template_renderer = staticmethod(paste_script_template_renderer)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pyramid_beaker
import pyramid_jinja2
import sqlahelper

from pyramid.config import Configurator
from sqlalchemy import engine_from_config

from {{package}}.models import initialize_sql

def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)

# Configure Database Engine
engine = engine_from_config(settings, 'sqlalchemy.')
sqlahelper.add_engine(engine)

# Configure Beaker Sessions and Caching
session_factory = pyramid_beaker.session_factory_from_settings(settings)
config.set_session_factory(session_factory)
pyramid_beaker.set_cache_regions_from_settings(settings)

# Configure Jinja2 Templates
config.include("pyramid_jinja2")
config.add_renderer('.html', pyramid_jinja2.renderer_factory)

# Add Static Views
config.add_static_view('static', '{{package}}:static')

# Include Application Views such as custom Exception Views and Root-Relative
# static asset views
config.include('{{package}}.views.appconfig')

# Include Routes
config.include("{{package}}.routes")

# Using config.scan() will search for decorators that supply further
# configuration such as the @view_config and @subscriber decorators
config.scan("{{package}}.views")
config.scan("{{package}}.subscribers")

# Initialize Database Tables
initialize_sql()
return config.make_wsgi_app()

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import logging
import transaction
import sqlahelper

log = logging.getLogger(__name__)

Session = sqlahelper.get_session()
Base = sqlahelper.get_base()

def initialize_sql():
Base.metadata.create_all()
transaction.commit()
6 changes: 6 additions & 0 deletions bunsen/paster_templates/pyramid_template/+package+/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
""" A tidy module for specifying all of you routes configuration.
"""
def includeme(config):
""" Add routes to the global config object.
"""
config.add_route('home', '/')
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>


<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->

<!-- Most restrictive policy: -->
<site-control permitted-cross-domain-policies="none"/>



<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
<!--
If you host a crossdomain.xml file with allow-access-from domain="*"
and don’t understand all of the points described here, you probably
have a nasty security vulnerability. ~ simon willison
-->

</cross-domain-policy>
Loading

0 comments on commit 69bd2c0

Please sign in to comment.