author_email='philipp.spitzer@winterrodeln.org',
url='http://www.winterrodeln.org/',
install_requires=[
- "Pylons>=0.9.7",
+ "Pylons>=0.10",
+ "SQLAlchemy>=0.5",
"Genshi>=0.4",
"MySQL-python>=1.2",
"AuthKit>=0.4.3,<=0.4.99",
- "SQLAlchemy>=0.5",
"lxml>=2.2",
# "matplotlib>=0.9",
"Babel>=0.9"
formatter = generic
[formatter_generic]
-format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
+format = %(asctime)s %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s
import os
from genshi.template import TemplateLoader
-from pylons import config
+from pylons.configuration import PylonsConfig
from sqlalchemy import engine_from_config
import wradmin.lib.app_globals as app_globals
"""Configure the Pylons environment via the ``pylons.config``
object
"""
+ config = PylonsConfig()
+
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
paths = dict(root=root,
# Initialize config with the basic options
config.init_app(global_conf, app_conf, package='wradmin', paths=paths)
- config['routes.map'] = make_map()
- config['pylons.app_globals'] = app_globals.Globals()
+ config['routes.map'] = make_map(config)
+ config['pylons.app_globals'] = app_globals.Globals(config)
config['pylons.h'] = wradmin.lib.helpers
+
+ # Setup cache object as early as possible
+ import pylons
+ pylons.cache._push_object(config['pylons.app_globals'].cache)
+
# Create the Genshi TemplateLoader
config['pylons.app_globals'].genshi_loader = TemplateLoader(
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
- config['pylons.strict_c'] = True
\ No newline at end of file
+
+ return config
"""Pylons middleware initialization"""
-from beaker.middleware import CacheMiddleware, SessionMiddleware
+from beaker.middleware import SessionMiddleware
from paste.cascade import Cascade
from paste.registry import RegistryManager
from paste.urlparser import StaticURLParser
from paste.deploy.converters import asbool
-from pylons import config
from pylons.middleware import ErrorHandler, StatusCodeRedirect
from pylons.wsgiapp import PylonsApp
from routes.middleware import RoutesMiddleware
"""
# Configure the Pylons environment
- load_environment(global_conf, app_conf)
+ config = load_environment(global_conf, app_conf)
# The Pylons WSGI app
- app = PylonsApp()
+ app = PylonsApp(config=config)
- # Routing/Session/Cache Middleware
+ # Routing/Session Middleware
app = RoutesMiddleware(app, config['routes.map'])
app = SessionMiddleware(app, config)
- app = CacheMiddleware(app, config)
# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
# Serve static files
static_app = StaticURLParser(config['pylons.paths']['static_files'])
app = Cascade([static_app, app])
-
+ app.config = config
return app
may take precedent over the more generic routes. For more information
refer to the routes manual at http://routes.groovie.org/docs/
"""
-from pylons import config
from routes import Mapper
-def make_map():
+def make_map(config):
"""Create, configure and return the routes Mapper"""
map = Mapper(directory=config['pylons.paths']['controllers'],
- always_scan=config['debug'], explicit=True)
+ always_scan=config['debug'])
map.minimization = False
+ map.explicit = False
# The ErrorController route (handles 404/500 error pages); it should
# likely stay at the top, ensuring it can always be resolved
# -*- coding: iso-8859-15 -*-
import logging
-from pylons import request, response, session, tmpl_context as c
-from pylons.controllers.util import abort, redirect_to
+from pylons import request, response, session, url, tmpl_context as c
+from pylons.controllers.util import abort, redirect
import webhelpers.paginate as paginate
from wradmin.lib.base import BaseController, render
model.meta.Session.commit()
session['flash'] = u'Datum wurde erfolgreich geändert'
session.save()
- return redirect_to(controller='bericht', action='view', id=id)
+ return redirect(url(controller='bericht', action='view', id=id))
def new(self, id):
import logging
-from pylons import request, response, session, tmpl_context as c
-from pylons.controllers.util import abort, redirect_to
+from pylons import request, response, session, url, tmpl_context as c
+from pylons.controllers.util import abort, redirect
import formencode
from wradmin.lib.base import BaseController, render
if input is None or len(input.strip()) == 0:
c.result = None
- return redirect_to(controller='coordtool', action='index')
+ return redirect(url(controller='coordtool', action='index'))
geo = wradmin.model.validators.MultiGeo()
try: c.result = geo.to_python(input)
except formencode.Invalid, e:
session['flash'] = unicode(e)
session.save()
- return redirect_to(controller='coordtool', action='index')
+ return redirect(url(controller='coordtool', action='index'))
if swap_latlon:
c.result = [(latitude, longitude, elevation) for (longitude, latitude, elevation) in c.result]
c.geo_gpx = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_GPX)
c.geo_geocaching = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_GEOCACHING)
- return render('coordtool.html')
\ No newline at end of file
+ return render('coordtool.html')
# -*- coding: iso-8859-15 -*-
import logging
-from pylons import request, response, session, tmpl_context as c
-from pylons.controllers.util import abort, redirect_to
+from pylons import request, response, session, url, tmpl_context as c
+from pylons.controllers.util import abort, redirect
import webhelpers.paginate as paginate
from wradmin.lib.base import BaseController, render
if error_msg == '': session['flash'] = u'Die Gasthausliste wurde erfolgreich aktualisiert.'
else: session['flash'] = error_msg
session.save()
- return redirect_to(controller='gasthaus', action='list')
+ return redirect(url(controller='gasthaus', action='list'))
#!/usr/bin/python2.5
# -*- coding: iso-8859-15 -*-
-from pylons import request, response, session, tmpl_context as c
-from pylons.controllers.util import abort, redirect_to
+from pylons import request, response, session, url, tmpl_context as c
+from pylons.controllers.util import abort, redirect
from wradmin.lib.base import BaseController, render
import wradmin.model as model
# -*- coding: iso-8859-15 -*-
import logging
-from pylons import request, response, session, tmpl_context as c
-from pylons.controllers.util import abort, redirect_to
+from pylons import request, response, session, url, tmpl_context as c
+from pylons.controllers.util import abort, redirect
import webhelpers.paginate as paginate
from wradmin.lib.base import BaseController, render
if error_msg == '': session['flash'] = u'Die Rodelbahnliste wurde erfolgreich aktualisiert.'
else: session['flash'] = error_msg
session.save()
- return redirect_to(controller='rodelbahn', action='list')
+ return redirect(url(controller='rodelbahn', action='list'))
import logging
-from pylons import request, response, session, tmpl_context as c
-from pylons.controllers.util import abort, redirect_to
+from pylons import request, response, session, url, tmpl_context as c
+from pylons.controllers.util import abort, redirect
from pylons.decorators.rest import restrict
from wradmin.lib.base import BaseController, render
"""The application's Globals object"""
+from beaker.cache import CacheManager
+from beaker.util import parse_cache_config_options
+
class Globals(object):
"""Globals acts as a container for objects available throughout the
"""
- def __init__(self):
+ def __init__(self, config):
"""One instance of Globals is created during application
initialization and is available during requests via the
'app_globals' variable
"""
+ self.cache = CacheManager(**parse_cache_config_options(config))
"""
from pylons.controllers import WSGIController
from pylons.templating import render_genshi as render
-from wradmin.model import meta
+
+from wradmin.model.meta import Session
class BaseController(WSGIController):
try:
return WSGIController.__call__(self, environ, start_response)
finally:
- meta.Session.remove()
-
+ Session.remove()
# Import helpers as desired, or define your own, ie:
#from webhelpers.html.tags import checkbox, password
-from routes import url_for
+from pylons import url
import wradmin.model.validators
from webhelpers.html.tags import file, form, end_form, submit
<th>Gelöscht</th>
</tr>
<tr py:for="r in c.paginator">
- <td><a href="${h.url_for(controller='bericht', action='view', id=r.id)}">${r.id}</a></td>
+ <td><a href="${h.url(controller='bericht', action='view', id=r.id)}">${r.id}</a></td>
<td>${r.page_title}</td>
<td>${r.date_entry}</td>
<td>${r.date_invalid}</td>
</tr>
<tr>
<th>Seiten-ID (Rodelbahn-ID)</th>
- <td><a href="${h.url_for(controller='rodelbahn', action='view', id=c.wrreport.page_id)}">${c.wrreport.page_id}</a></td>
+ <td><a href="${h.url(controller='rodelbahn', action='view', id=c.wrreport.page_id)}">${c.wrreport.page_id}</a></td>
</tr>
<tr>
<th>Datum für Bericht</th>
</table>
<h3>Anzeigedauer des Rodelbahnberichts ändern</h3>
-<form action="${h.url_for(controller='bericht', action='change_date_invalid', id=c.wrreport.id)}" method="post">
+<form action="${h.url(controller='bericht', action='change_date_invalid', id=c.wrreport.id)}" method="post">
<table>
<tr>
<th>Enddatum</th>
<py:for each="line in c.result">${c.geo_geocaching.from_python([line])}<br/></py:for>
</p>
-<form action="${h.url_for(controller='coordtool', action='convert')}" method="post">
+<form action="${h.url(controller='coordtool', action='convert')}" method="post">
<table>
<tr><th></th><th>Beispiel</th></tr>
<tr><td><textarea name="input" cols="80" rows="10"/></td>
<p>Die folgende Lise wurde automatisiert von den Gasthausboxen gesammelt. Da dies nicht automatisch passiert, kann es sein, dass die Liste "veraltete" Information enthält.</p>
-<p><a href="${h.url_for(controller='gasthaus', action='update')}" class="button">Gasthausboxen auslesen und DB aktualisieren</a></p>
+<p><a href="${h.url(controller='gasthaus', action='update')}" class="button">Gasthausboxen auslesen und DB aktualisieren</a></p>
<p>${c.paginator.pager('$link_first $link_previous $first_item bis $last_item von $item_count $link_next $link_last', controller='gasthaus', action='list')}</p>
<th>In Arbeit</th>
</tr>
<tr py:for="s in c.paginator">
- <td><a href="${h.url_for(controller='gasthaus', action='view', id=s.page_id)}">${s.page_id}</a></td>
+ <td><a href="${h.url(controller='gasthaus', action='view', id=s.page_id)}">${s.page_id}</a></td>
<td>${s.page_title}</td>
<td>${s.position_elevation}</td>
<td>${s.phone_list}</td>
<p>Willkommen auf den Administrationsseiten von Winterrodeln.</p>
<ul>
- <li><a href="${h.url_for(controller='rodelbahn', action='list')}">Rodelbahnen</a></li>
- <li><a href="${h.url_for(controller='bericht', action='list')}">Rodelbahnberichte</a></li>
- <li><a href="${h.url_for(controller='gasthaus', action='list')}">Gasthäuser</a></li>
- <li><a href="${h.url_for(controller='maptool', action='index')}">Maptool</a></li>
- <li><a href="${h.url_for(controller='coordtool', action='index')}">Koordinaten-Rechner</a></li>
- <!-- <li><a href="${h.url_for(controller='wrgpxtool', action='index')}">Winterrodeln-GPX Datei Werkzeuge</a></li> -->
+ <li><a href="${h.url(controller='rodelbahn', action='list')}">Rodelbahnen</a></li>
+ <li><a href="${h.url(controller='bericht', action='list')}">Rodelbahnberichte</a></li>
+ <li><a href="${h.url(controller='gasthaus', action='list')}">Gasthäuser</a></li>
+ <li><a href="${h.url(controller='maptool', action='index')}">Maptool</a></li>
+ <li><a href="${h.url(controller='coordtool', action='index')}">Koordinaten-Rechner</a></li>
+ <!-- <li><a href="${h.url(controller='wrgpxtool', action='index')}">Winterrodeln-GPX Datei Werkzeuge</a></li> -->
</ul>
<ul>
<head>
<title>Map-Tool</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAVDRl0qsoeYOspQi0txxVEhTO7xxs0m3ls_NApg8LzilP9E0D3hScAc_5O_qu8-pbIbSF5h8xfGEcjA" type="text/javascript"> </script>
- <script src="${h.url_for('/yui/yahoo-dom-event/yahoo-dom-event.js')}" type="text/javascript"> </script>
- <script src="${h.url_for('/yui/connection/connection-min.js')}" type="text/javascript"> </script>
- <script src="${h.url_for('/yui/json/json-min.js')}" type="text/javascript"> </script>
+ <script src="${h.url('/yui/yahoo-dom-event/yahoo-dom-event.js')}" type="text/javascript"> </script>
+ <script src="${h.url('/yui/connection/connection-min.js')}" type="text/javascript"> </script>
+ <script src="${h.url('/yui/json/json-min.js')}" type="text/javascript"> </script>
<script type="text/javascript">
// <![CDATA[
function initSledding(wrMap) {
// Icon
var wrSleddingIcon = new GIcon(G_DEFAULT_ICON);
- wrSleddingIcon.image = "${h.url_for('/gmap_rodelbahn_c.png')}";
- wrSleddingIcon.shadow = "${h.url_for('/gmap_rodelbahn_c_s.png')}";
+ wrSleddingIcon.image = "${h.url('/gmap_rodelbahn_c.png')}";
+ wrSleddingIcon.shadow = "${h.url('/gmap_rodelbahn_c_s.png')}";
wrSleddingIcon.iconSize = new GSize(17, 17);
wrSleddingIcon.shadowSize = new GSize(23, 23);
wrSleddingIcon.iconAnchor = new GPoint(9, 9);
},
failure: function(o) {alert("Konnte die Rodelbahnen-Daten nicht vom Server laden");}
}
- var url = "${h.url_for(controller='maptool', action='ajax_sledding')}";
+ var url = "${h.url(controller='maptool', action='ajax_sledding')}";
YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
}
function initInns(wrMap) {
// Icon
var wrInnIcon = new GIcon(G_DEFAULT_ICON);
- wrInnIcon.image = "${h.url_for('/gmapGasthaus.png')}";
+ wrInnIcon.image = "${h.url('/gmapGasthaus.png')}";
// Add one inn
function addInnMarker(latitude, longitude, name) {
},
failure: function(o) {alert("Konnte die Hütten-Daten nicht vom Server laden");}
}
- var url = "${h.url_for(controller='maptool', action='ajax_inns')}";
+ var url = "${h.url(controller='maptool', action='ajax_inns')}";
YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
}
<head py:match="head" py:attrs="select('@*')">
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<meta name="robots" content="noindex, nofollow" />
- <link rel="stylesheet" type="text/css" media="screen" href="${h.url_for('/style.css')}" />
- <link rel="shortcut icon" href="${h.url_for('/favicon.png')}" />
+ <link rel="stylesheet" type="text/css" media="screen" href="${h.url('/style.css')}" />
+ <link rel="shortcut icon" href="${h.url('/favicon.png')}" />
<meta py:replace="select('*|text()')" />
</head>
<body py:match="body" py:attrs="select('@*')">
-<h1 id="header"><img src="${h.url_for('/titlebanner.png')}" alt="Winterrodeln Administration"/></h1>
+<h1 id="header"><img src="${h.url('/titlebanner.png')}" alt="Winterrodeln Administration"/></h1>
<ul id="mainmenu">
- <li><a href="${h.url_for(controller='rodelbahn', action='index')}">Übersicht</a></li>
- <li><a href="${h.url_for(controller='rodelbahn', action='list')}">Rodelbahnen</a></li>
- <li><a href="${h.url_for(controller='bericht', action='list')}">Rodelbahnberichte</a></li>
- <li><a href="${h.url_for(controller='gasthaus', action='list')}">Gasthäuser</a></li>
- <li><a href="${h.url_for(controller='maptool', action='index')}">Map-Tool</a></li>
+ <li><a href="${h.url(controller='rodelbahn', action='index')}">Übersicht</a></li>
+ <li><a href="${h.url(controller='rodelbahn', action='list')}">Rodelbahnen</a></li>
+ <li><a href="${h.url(controller='bericht', action='list')}">Rodelbahnberichte</a></li>
+ <li><a href="${h.url(controller='gasthaus', action='list')}">Gasthäuser</a></li>
+ <li><a href="${h.url(controller='maptool', action='index')}">Map-Tool</a></li>
</ul>
<div py:if="session.has_key('flash')" class="${session.pop('flashclass', 'flash')}">${session.pop('flash')}<?python session.save() ?></div>
${select('*|text()')}
</div>
-<div id="footer"><img src="${h.url_for('/philipp_spitzer.png')}" alt="Philipp Spitzer"/></div>
+<div id="footer"><img src="${h.url('/philipp_spitzer.png')}" alt="Philipp Spitzer"/></div>
</body>
</html>
<p>Die folgende Lise wurde automatisiert von den Rodelbahnboxen gesammelt. Da dies nicht automatisch passiert, kann es sein, dass die Liste "veraltete" Information enthält.</p>
-<a href="${h.url_for(controller='rodelbahn', action='update')}" class="button">Rodelbahnboxen auslesen und DB aktualisieren</a>
+<a href="${h.url(controller='rodelbahn', action='update')}" class="button">Rodelbahnboxen auslesen und DB aktualisieren</a>
<p>${c.paginator.pager('$link_first $link_previous $first_item bis $last_item von $item_count $link_next $link_last', controller='rodelbahn', action='list')}</p>
<th>In Übersicht</th>
</tr>
<tr py:for="s in c.paginator">
- <td><a href="${h.url_for(controller='rodelbahn', action='view', id=s.page_id)}">${s.page_id}</a></td>
+ <td><a href="${h.url(controller='rodelbahn', action='view', id=s.page_id)}">${s.page_id}</a></td>
<td>${s.page_title}</td>
<td>${s.length}</td>
<td>${s.walkup_time}</td>
<th>Gelöscht</th>
</tr>
<tr py:for="r in c.paginator">
- <td><a href="${h.url_for(controller='bericht', action='view', id=r.id)}">${r.id}</a></td>
+ <td><a href="${h.url(controller='bericht', action='view', id=r.id)}">${r.id}</a></td>
<td>${r.date_entry}</td>
<td>${r.date_invalid}</td>
<td>${r.date_report}</td>
<py:if test="not c.validated">
<p>WRGPX steht für "Winterrodeln GPX". Hier können Sie eine .gpx Datei auf ihre Gültigkeit untersuchen.</p>
-${h.form(h.url_for(controller='wrgpxtool', action='upload'), multipart=True)}
+${h.form(h.url(controller='wrgpxtool', action='upload'), multipart=True)}
GPX-Datei zum Untersuchen: ${h.file('gpxfile')}<br/>
${h.submit('submit', 'Raufladen')}
${h.end_form()}
<py:if test="c.validation_ok">
<p>Sie entspricht außerdem den zusätzlichen Anforderungen von Winterrodeln an GPX Dateien (WRGPX).</p>
-<img src="${h.url_for(controller='wrgpxtool', action='height_profile')}"/>
+<img src="${h.url(controller='wrgpxtool', action='height_profile')}"/>
<py:if test="len(c.validation_hints) > 0">
<p>Trotzdem könnte die Datei noch verbessert werden:</p>
<p><em>${str(c.validation_exception)}</em></p>
</py:if>
-<p><a href="${h.url_for(controller='wrgpxtool', action='index')}">Andere/geänderte GPX-Datei untersuchen</a></p>
+<p><a href="${h.url(controller='wrgpxtool', action='index')}">Andere/geänderte GPX-Datei untersuchen</a></p>
</py:if>
from paste.deploy import loadapp
from paste.script.appinstall import SetupCommand
-from pylons import config, url
+from pylons import url
from routes.util import URLGenerator
from webtest import TestApp
__all__ = ['environ', 'url', 'TestController']
# Invoke websetup with the current config file
-SetupCommand('setup-app').run([config['__file__']])
+SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
environ = {}
class TestController(TestCase):
def __init__(self, *args, **kwargs):
- if pylons.test.pylonsapp:
- wsgiapp = pylons.test.pylonsapp
- else:
- wsgiapp = loadapp('config:%s' % config['__file__'])
+ wsgiapp = pylons.test.pylonsapp
+ config = wsgiapp.config
self.app = TestApp(wsgiapp)
url._push_object(URLGenerator(config['routes.map'], environ))
TestCase.__init__(self, *args, **kwargs)
+
"""Setup the wradmin application"""
import logging
+import pylons.test
from wradmin.config.environment import load_environment
from wradmin.model import meta
def setup_app(command, conf, vars):
"""Place any commands to setup wradmin here"""
- load_environment(conf.global_conf, conf.local_conf)
+ if not pylons.test.pylonsapp:
+ load_environment(conf.global_conf, conf.local_conf)
## Create the tables if they don't already exist
- # meta.metadata.create_all(bind=meta.engine)
\ No newline at end of file
+ # meta.metadata.create_all(bind=meta.engine)