added pyramid subpackage to scaffold
This commit is contained in:
parent
ba092f90e4
commit
2617211f38
9 changed files with 82 additions and 77 deletions
|
@ -4,56 +4,4 @@
|
||||||
``{{package}}`` -- {{project}} application
|
``{{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__
|
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()
|
|
||||||
|
|
57
edbob/scaffolds/edbob/+package+/pyramid/__init__.py
Normal file
57
edbob/scaffolds/edbob/+package+/pyramid/__init__.py
Normal 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()
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""
|
"""
|
||||||
``{{package}}.subscribers`` -- Pyramid Event Subscribers
|
``{{package}}.pyramid.subscribers`` -- Pyramid Event Subscribers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import {{package}}
|
import {{package}}
|
|
@ -1,8 +1,8 @@
|
||||||
<%inherit file="/edbob/base.mako" />
|
<%inherit file="/edbob/base.mako" />
|
||||||
<%def name="global_title()">{{project}}</%def>
|
<%def name="global_title()">{{project}}</%def>
|
||||||
<%def name="home_link()"><h1 class="right">${h.link_to("{{project}}", url('home'))}</h1></%def>
|
<%def name="home_link()"><h1 class="right">${h.link_to("{{project}}", url('home'))}</h1></%def>
|
||||||
<%def name="footer()">
|
<%def name="footer()">
|
||||||
{{project}} v${ {{package}}.__version__} powered by
|
{{project}} v${ {{package}}.__version__} powered by
|
||||||
${h.link_to("edbob", 'http://edbob.org/', target='_blank')} v${edbob.__version__}
|
${h.link_to("edbob", 'http://edbob.org/', target='_blank')} v${edbob.__version__}
|
||||||
</%def>
|
</%def>
|
||||||
${parent.body()}
|
${parent.body()}
|
|
@ -1,13 +1,13 @@
|
||||||
<%inherit file="/base.mako" />
|
<%inherit file="/base.mako" />
|
||||||
|
|
||||||
<%def name="title()">Home</%def>
|
<%def name="title()">Home</%def>
|
||||||
|
|
||||||
<h1>Welcome to {{project}}</h1>
|
<h1>Welcome to {{project}}</h1>
|
||||||
|
|
||||||
<p>You must choose, but choose wisely:</p>
|
<p>You must choose, but choose wisely:</p>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<ul style="line-height: 200%;">
|
<ul style="line-height: 200%;">
|
||||||
<li>some...</li>
|
<li>some...</li>
|
||||||
<li>...links</li>
|
<li>...links</li>
|
||||||
</ul>
|
</ul>
|
|
@ -1,2 +1,2 @@
|
||||||
<%inherit file="/edbob/index.mako" />
|
<%inherit file="/edbob/index.mako" />
|
||||||
${parent.body()}
|
${parent.body()}
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""
|
"""
|
||||||
``{{package}}.views`` -- Views
|
``{{package}}.pyramid.views`` -- Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
Loading…
Add table
Add a link
Reference in a new issue