random tweaks from milo development
This commit is contained in:
parent
ba94a015a6
commit
76ed40950a
10 changed files with 85 additions and 22 deletions
|
@ -82,7 +82,7 @@ class FieldSet(formalchemy.FieldSet):
|
||||||
self.url_cancel = url_cancel or url(self.route_name)
|
self.url_cancel = url_cancel or url(self.route_name)
|
||||||
|
|
||||||
def get_display_text(self):
|
def get_display_text(self):
|
||||||
return str(self.model)
|
return unicode(self.model)
|
||||||
|
|
||||||
def render(self, **kwargs):
|
def render(self, **kwargs):
|
||||||
kwargs.setdefault('class_', self.class_name)
|
kwargs.setdefault('class_', self.class_name)
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import pyramid_beaker
|
|
||||||
from pyramid.config import Configurator
|
from pyramid.config import Configurator
|
||||||
|
from pyramid.authentication import SessionAuthenticationPolicy
|
||||||
|
|
||||||
import edbob
|
import edbob
|
||||||
|
from edbob.pyramid.auth import EdbobAuthorizationPolicy
|
||||||
|
|
||||||
from {{package}}._version import __version__
|
from {{package}}._version import __version__
|
||||||
|
|
||||||
|
@ -33,24 +34,26 @@ def main(global_config, **settings):
|
||||||
'edbob.pyramid:templates',
|
'edbob.pyramid:templates',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Configure Pyramid
|
|
||||||
config = Configurator(settings=settings)
|
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')
|
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}}.subscribers')
|
||||||
config.scan()
|
config.include('{{package}}.views')
|
||||||
|
|
||||||
# Configure Beaker
|
# Configure edbob. Note that this is done last, primarily to allow logging
|
||||||
session_factory = pyramid_beaker.session_factory_from_settings(settings)
|
# to leverage edbob's config inheritance.
|
||||||
config.set_session_factory(session_factory)
|
|
||||||
pyramid_beaker.set_cache_regions_from_settings(settings)
|
|
||||||
|
|
||||||
# Configure edbob
|
|
||||||
edbob.basic_logging()
|
edbob.basic_logging()
|
||||||
edbob.init('{{package}}', os.path.abspath(settings['edbob.config']))
|
edbob.init('{{package}}', os.path.abspath(settings['edbob.config']))
|
||||||
|
|
||||||
# Add static views
|
|
||||||
# config.add_static_view('css', 'static/css', cache_max_age=3600)
|
|
||||||
# config.add_static_view('img', 'static/img', cache_max_age=3600)
|
|
||||||
# config.add_static_view('js', 'static/js', cache_max_age=3600)
|
|
||||||
|
|
||||||
return config.make_wsgi_app()
|
return config.make_wsgi_app()
|
||||||
|
|
|
@ -52,7 +52,7 @@ class InitCommand(commands.Subcommand):
|
||||||
print ' %s' % engine.url
|
print ' %s' % engine.url
|
||||||
return
|
return
|
||||||
|
|
||||||
# Activate any extensions you like here...
|
# Activate extensions.
|
||||||
activate_extension('auth')
|
activate_extension('auth')
|
||||||
# activate_extension('shrubbery')
|
# activate_extension('shrubbery')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
|
@ -17,5 +17,5 @@ def before_render(event):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
config.add_subscriber('{{package}}.subscribers:before_render',
|
config.include('edbob.pyramid.subscribers')
|
||||||
'pyramid.events.BeforeRender')
|
config.add_subscriber(before_render, 'pyramid.events.BeforeRender')
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<%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="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__}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<%inherit file="/base.mako" />
|
<%inherit file="/base.mako" />
|
||||||
|
|
||||||
|
<%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>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<%inherit file="/edbob/index.mako" />
|
||||||
|
${parent.body()}
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
``{{package}}.views`` -- Views
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
from pyramid.response import Response
|
||||||
|
|
||||||
|
|
||||||
|
_here = os.path.join(os.path.dirname(__file__), os.pardir)
|
||||||
|
|
||||||
|
|
||||||
|
_favicon = open(os.path.join(_here, 'static', 'favicon.ico'), 'rb').read()
|
||||||
|
_favicon_response = Response(content_type='image/x-icon', body=_favicon)
|
||||||
|
|
||||||
|
def favicon_ico(context, request):
|
||||||
|
return _favicon_response
|
||||||
|
|
||||||
|
|
||||||
|
def home(context, request):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
_robots = open(os.path.join(_here, 'static', 'robots.txt')).read()
|
||||||
|
_robots_response = Response(content_type='text/plain', body=_robots)
|
||||||
|
|
||||||
|
def robots_txt(context, request):
|
||||||
|
return _robots_response
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
|
||||||
|
config.add_route('home', '/')
|
||||||
|
config.add_view(home, route_name='home', renderer='/home.mako')
|
||||||
|
|
||||||
|
config.add_route('favicon.ico', '/favicon.ico')
|
||||||
|
config.add_view(favicon_ico, route_name='favicon.ico')
|
||||||
|
|
||||||
|
config.add_route('robots.txt', '/robots.txt')
|
||||||
|
config.add_view(robots_txt, route_name='robots.txt')
|
||||||
|
|
||||||
|
config.include('edbob.pyramid.views.auth')
|
||||||
|
config.include('edbob.pyramid.views.people')
|
||||||
|
config.include('edbob.pyramid.views.roles')
|
||||||
|
config.include('edbob.pyramid.views.users')
|
|
@ -288,10 +288,15 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('div.grid td.delete').live('click', function() {
|
$('div.grid td.delete').live('click', function() {
|
||||||
if (confirm("Do you really wish to delete this object?")) {
|
var grid = $(this).parents('div.grid:first');
|
||||||
var grid = $(this).parents('div.grid:first');
|
var url = grid.attr('delurl');
|
||||||
var url = grid.attr('delurl');
|
if (url) {
|
||||||
location.href = url.replace(/%7Buuid%7D/, get_uuid(this));
|
if (confirm("Do you really wish to delete this object?")) {
|
||||||
|
location.href = url.replace(/%7Buuid%7D/, get_uuid(this));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert("Hm, I don't know how to delete that..\n\n"
|
||||||
|
+ "(Add a 'delurl' parameter to the AlchemyGrid instance.)");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue