added pyramid subpackage to scaffold

This commit is contained in:
Lance Edgar 2012-06-10 23:07:09 -05:00
parent ba092f90e4
commit 2617211f38
9 changed files with 82 additions and 77 deletions

View file

@ -4,56 +4,4 @@
``{{package}}`` -- {{project}} application
"""
import os.path
from pyramid.config import Configurator
from pyramid.authentication import SessionAuthenticationPolicy
import edbob
from edbob.pyramid.auth import EdbobAuthorizationPolicy
from {{package}}._version import __version__
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# Here you can insert any code to modify the ``settings`` dict.
# You can:
# * Add additional keys to serve as constants or "global variables" in the
# application.
# * Set default values for settings that may have been omitted.
# * Override settings that you don't want the user to change.
# * Raise an exception if a setting is missing or invalid.
# * Convert values from strings to their intended type.
settings['mako.directories'] = [
'{{package}}:templates',
'edbob.pyramid:templates',
]
config = Configurator(settings=settings)
# Configure session
config.include('pyramid_beaker')
# Configure auth
config.set_authentication_policy(SessionAuthenticationPolicy())
config.set_authorization_policy(EdbobAuthorizationPolicy())
# Include "core" stuff provided by edbob.
config.include('edbob.pyramid')
# Additional config is defined elsewhere within {{project}}. This includes
# incorporating the various views etc. exposed by other packages.
config.include('{{package}}.subscribers')
config.include('{{package}}.views')
# Configure edbob. Note that this is done last, primarily to allow logging
# to leverage edbob's config inheritance.
edbob.basic_logging()
edbob.init('{{package}}', os.path.abspath(settings['edbob.config']))
return config.make_wsgi_app()

View file

@ -0,0 +1,57 @@
#!/usr/bin/env python
"""
``{{package}}.pyramid`` -- Pyramid Application
"""
import os.path
from pyramid.config import Configurator
from pyramid.authentication import SessionAuthenticationPolicy
import edbob
from edbob.pyramid.auth import EdbobAuthorizationPolicy
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# Here you can insert any code to modify the ``settings`` dict.
# You can:
# * Add additional keys to serve as constants or "global variables" in the
# application.
# * Set default values for settings that may have been omitted.
# * Override settings that you don't want the user to change.
# * Raise an exception if a setting is missing or invalid.
# * Convert values from strings to their intended type.
settings['mako.directories'] = [
'{{package}}.pyramid:templates',
'edbob.pyramid:templates',
]
config = Configurator(settings=settings)
# Configure session
config.include('pyramid_beaker')
# Configure auth
config.set_authentication_policy(SessionAuthenticationPolicy())
config.set_authorization_policy(EdbobAuthorizationPolicy())
# Include "core" stuff provided by edbob.
config.include('edbob.pyramid')
# Additional config is defined elsewhere within {{project}}. This includes
# incorporating the various views etc. exposed by other packages.
config.include('{{package}}.pyramid.subscribers')
config.include('{{package}}.pyramid.views')
# Configure edbob. Note that this is done last, primarily to allow logging
# to leverage edbob's config inheritance.
edbob.basic_logging()
edbob.init('{{package}}', os.path.abspath(settings['edbob.config']))
return config.make_wsgi_app()

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
``{{package}}.subscribers`` -- Pyramid Event Subscribers
``{{package}}.pyramid.subscribers`` -- Pyramid Event Subscribers
"""
import {{package}}

View file

@ -1,8 +1,8 @@
<%inherit file="/edbob/base.mako" />
<%def name="global_title()">{{project}}</%def>
<%def name="home_link()"><h1 class="right">${h.link_to("{{project}}", url('home'))}</h1></%def>
<%def name="footer()">
{{project}} v${ {{package}}.__version__} powered by
${h.link_to("edbob", 'http://edbob.org/', target='_blank')} v${edbob.__version__}
</%def>
${parent.body()}
<%inherit file="/edbob/base.mako" />
<%def name="global_title()">{{project}}</%def>
<%def name="home_link()"><h1 class="right">${h.link_to("{{project}}", url('home'))}</h1></%def>
<%def name="footer()">
{{project}} v${ {{package}}.__version__} powered by
${h.link_to("edbob", 'http://edbob.org/', target='_blank')} v${edbob.__version__}
</%def>
${parent.body()}

View file

@ -1,13 +1,13 @@
<%inherit file="/base.mako" />
<%def name="title()">Home</%def>
<h1>Welcome to {{project}}</h1>
<p>You must choose, but choose wisely:</p>
<br />
<ul style="line-height: 200%;">
<li>some...</li>
<li>...links</li>
</ul>
<%inherit file="/base.mako" />
<%def name="title()">Home</%def>
<h1>Welcome to {{project}}</h1>
<p>You must choose, but choose wisely:</p>
<br />
<ul style="line-height: 200%;">
<li>some...</li>
<li>...links</li>
</ul>

View file

@ -1,2 +1,2 @@
<%inherit file="/edbob/index.mako" />
${parent.body()}
<%inherit file="/edbob/index.mako" />
${parent.body()}

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
``{{package}}.views`` -- Views
``{{package}}.pyramid.views`` -- Views
"""
import os