-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69bd2c0
Showing
35 changed files
with
10,099 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
46 changes: 46 additions & 0 deletions
46
bunsen/paster_templates/pyramid_template/+package+/__init__.py_tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
12 changes: 12 additions & 0 deletions
12
bunsen/paster_templates/pyramid_template/+package+/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', '/') |
25 changes: 25 additions & 0 deletions
25
bunsen/paster_templates/pyramid_template/+package+/static/crossdomain.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.