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)
|
||||
|
||||
def get_display_text(self):
|
||||
return str(self.model)
|
||||
return unicode(self.model)
|
||||
|
||||
def render(self, **kwargs):
|
||||
kwargs.setdefault('class_', self.class_name)
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
import os.path
|
||||
|
||||
import pyramid_beaker
|
||||
from pyramid.config import Configurator
|
||||
from pyramid.authentication import SessionAuthenticationPolicy
|
||||
|
||||
import edbob
|
||||
from edbob.pyramid.auth import EdbobAuthorizationPolicy
|
||||
|
||||
from {{package}}._version import __version__
|
||||
|
||||
|
@ -33,24 +34,26 @@ def main(global_config, **settings):
|
|||
'edbob.pyramid:templates',
|
||||
]
|
||||
|
||||
# Configure Pyramid
|
||||
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.scan()
|
||||
config.include('{{package}}.views')
|
||||
|
||||
# Configure Beaker
|
||||
session_factory = pyramid_beaker.session_factory_from_settings(settings)
|
||||
config.set_session_factory(session_factory)
|
||||
pyramid_beaker.set_cache_regions_from_settings(settings)
|
||||
|
||||
# Configure edbob
|
||||
# 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']))
|
||||
|
||||
# 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()
|
||||
|
|
|
@ -52,7 +52,7 @@ class InitCommand(commands.Subcommand):
|
|||
print ' %s' % engine.url
|
||||
return
|
||||
|
||||
# Activate any extensions you like here...
|
||||
# Activate extensions.
|
||||
activate_extension('auth')
|
||||
# activate_extension('shrubbery')
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Disallow: /
|
|
@ -17,5 +17,5 @@ def before_render(event):
|
|||
|
||||
|
||||
def includeme(config):
|
||||
config.add_subscriber('{{package}}.subscribers:before_render',
|
||||
'pyramid.events.BeforeRender')
|
||||
config.include('edbob.pyramid.subscribers')
|
||||
config.add_subscriber(before_render, 'pyramid.events.BeforeRender')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<%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__}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<%inherit file="/base.mako" />
|
||||
|
||||
<%def name="title()">Home</%def>
|
||||
|
||||
<h1>Welcome to {{project}}</h1>
|
||||
|
||||
<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() {
|
||||
if (confirm("Do you really wish to delete this object?")) {
|
||||
var grid = $(this).parents('div.grid:first');
|
||||
var url = grid.attr('delurl');
|
||||
location.href = url.replace(/%7Buuid%7D/, get_uuid(this));
|
||||
var grid = $(this).parents('div.grid:first');
|
||||
var url = grid.attr('delurl');
|
||||
if (url) {
|
||||
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;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue