sqlalchemy.url = mysql://philipp@localhost:3306/winterrodeln_wiki?charset=utf8
# necessary for mySQL databases
sqlalchemy.pool_recycle = 3600
+# sqlalchemy.echo_pool = 1
+# sqlalchemy.echo=true
# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
c.date_two_weeks = now + datetime.timedelta(14)
c.date_one_week_more = date_invalid + datetime.timedelta(7)
c.date_end_of_saison = datetime.datetime(now.year, 7, 1)
-
+
+
def view(self, id):
"Displays a report"
q = model.meta.Session.query(model.WrReport)
self._add_dates_to_c(c.wrreport.date_invalid)
return render('bericht_view.html')
+
@restrict('POST')
@validate(schema=ChangeDateInvalidForm(), form='view')
def change_date_invalid(self, id=None):
session.save()
return redirect_to(controller='bericht', action='view', id=id)
+
def new(self, id):
"Displays a form to create a new page"
return u"Nicht implementiert."
+
def create(self):
"Saves the information submitted from new() and redirects to view()"
return u"Nicht implementiert."
+
def edit(self, id):
"Displays a form for editing the page id"
return u"Nicht implementiert."
+
def save(self, id):
"Saves the page id and redirects to view()"
return u"Nicht implementiert."
+
def list(self):
"Lists all reports"
q = model.meta.Session.query(model.WrReport)
q = q.order_by(sa.sql.expression.desc(model.WrReport.id))
c.paginator = paginate.Page(q, page=int(request.params.get('page', 1)), items_per_page = 25)
return render('bericht_list.html')
-
+
+
def delete(self, id):
"Deletes a page"
return u"Nicht implementiert."
--- /dev/null
+#!/usr/bin/python2.5
+# -*- coding: iso-8859-15 -*-
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+import webhelpers.paginate as paginate
+
+from wradmin.lib.base import BaseController, render
+import wradmin.model as model
+import sqlalchemy as sa
+import re
+from wradmin.lib.mediawiki import to_unsigned, to_date, to_geo, to_title, to_tristate, to_email, to_url, to_phone, conv, unicode_e
+
+log = logging.getLogger(__name__)
+
+class GasthausController(BaseController):
+
+ def list(self):
+ "Lists all inns"
+ q = model.meta.Session.query(model.WrInnCache)
+ q = q.order_by(model.WrInnCache.page_title)
+ c.paginator = paginate.Page(q, page=int(request.params.get('page', 1)), items_per_page = 25)
+ return render('gasthaus_list.html')
+
+
+ def view(self, id):
+ "Displays an inn"
+ q = model.meta.Session.query(model.WrInnCache)
+ c.inn = q.get(id)
+ if c.inn is None: abort(404)
+ return render('gasthaus_view.html')
+
+
+ def _wikipage_to_wrinncache(self, inn_wiki):
+ "Converts an inn wiki page to an inn wrinncache database record."
+ inn = model.WrInnCache()
+ inn.page_id = inn_wiki.page_id
+ inn.page_title = to_title(inn_wiki.page_title)
+
+ # Match Gasthausbox
+ wikitext = inn_wiki.old_text
+ regexp = re.compile(u"\{\{(Gasthausbox[^\}]*)\}\}", re.DOTALL)
+ match = regexp.search(wikitext)
+ if not match:
+ raise Exception(u"No 'Gasthausbox' found")
+ box = match.group(1)
+
+ # Process Gashausbox
+ for property in box.split('|'):
+ property = property.strip()
+ if property == u'Gasthausbox': continue
+ key_value = property.split('=')
+ if len(key_value) != 2:
+ raise Exception(u"Property '%s' has unexpected format" % key_value)
+ key = key_value[0].strip()
+ value = key_value[1].strip()
+ if key == u'Gasthausnummer': pass
+ elif key == u'E-Mail': inn.email = conv(to_email, value, u'E-Mail')
+ elif key == u'Homepage': inn.homepage = conv(to_url, value, u'Homepage')
+ elif key == u'Höhe':
+ if value: inn.height = conv(to_unsigned, value, u'Höhe')
+ elif key == u'Bild': inn.image = value
+ elif key == u'Position': (inn.position_latitude, inn.position_longitude) = conv(to_geo, value, u'Position') # '47.583333 N 15.75 E'
+ elif key == u'Telefon (Festnetz)': inn.phone = conv(to_phone, value, u'Telefon (Festnetz)')
+ elif key == u'Telefon (Mobil)': inn.mobile_phone = conv(to_phone, value, u'Telefon (Mobil)')
+ elif key == u'Rauchfrei': (inn.nonsmoker_area, inn.smoker_area) = conv(to_tristate, value, u'Rauchfrei')
+ elif key == u'Aufnahmedatum': inn.creation_date = conv(to_date, value, u'Aufnahmedatum') # '2006-03-15'
+ else: raise Exception(u"Unbekannte Eigenschaft der Rodelbahnbox: '%s' (mit Wert '%s')" % (key, value))
+ inn.under_construction = None
+ return inn
+
+
+ def update(self):
+ "Updates the wrinncache table from the wiki"
+ from wradmin.model import page_table as page, wrinncache_table as wrinncache, categorylinks_table as categorylinks, revision_table as revision, text_table as text
+ from sqlalchemy.sql import select
+ c = model.meta.Session.connection()
+
+ # Query all inns
+ q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to==u'Gasthaus'))
+ inn_pages = c.execute(q)
+
+ # Delete all existing entries in wrinncache
+ c.execute(wrinncache.delete())
+
+ # Refill wrinncache table
+ error_msg = ''
+ for inn in inn_pages:
+ try:
+ inn = self._wikipage_to_wrinncache(inn)
+ inn.under_construction = c.execute(select([categorylinks], (categorylinks.c.cl_from==inn.page_id) & (categorylinks.c.cl_to == u'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
+ model.meta.Session.add(inn)
+ except Exception, e: error_msg = u"Fehler bei Gasthaus '%s': " % inn.page_title + unicode_e(e)
+ model.meta.Session.commit()
+
+ # Redirect to result page
+ 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')
"""
from pylons.controllers import WSGIController
from pylons.templating import render_genshi as render
+from wradmin.model import meta
class BaseController(WSGIController):
# WSGIController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
- return WSGIController.__call__(self, environ, start_response)
+ try:
+ return WSGIController.__call__(self, environ, start_response)
+ finally:
+ meta.Session.remove()
+
def wiki(page_title=None):
"TODO: Improve, escape, ..."
if page_title is None: page_title = 'Hauptseite'
- return 'http://www.winterrodeln.org/wiki/' + page_title
+ return u'http://www.winterrodeln.org/wiki/' + page_title
def forum(forum=None):
"forum ... id"
- return 'http://winterrodeln-forum.org/'
+ return u'http://winterrodeln-forum.org/'
def google_maps(latitude, longitude):
"Builds an URL like http://maps.google.at/maps?q=47.200607,11.260007"
- return "http://maps.google.at/maps?q=%.6f,%.6f" % (latitude, longitude)
+ return u"http://maps.google.at/maps?q=%.6f,%.6f" % (latitude, longitude)
+
+
+def bool(value):
+ if value is None: return None
+ if value: return u'Ja'
+ return u'Nein'
+
+
+def tristate(yes, no):
+ if yes is None or no is None: return None
+ if yes == no: return u'Teilweise'
+ if yes: return u'Ja'
+ if no: return u'Nein'
from authkit.users import UsersReadOnly, md5
from wradmin.lib.wrdatabase import get_wiki_connection
+import re
import logging
log = logging.getLogger(__name__)
+
+# Converter functions
+# -------------------
+
+def to_bool(value):
+ if not value: return None
+ if value == u'Ja': return True
+ if value == u'Nein': return False
+ raise Exception(u"'%s' is not a valid boolean value, use one of 'Ja' or 'Nein'" % value)
+
+
+def to_unsigned(value):
+ v = int(value)
+ if v < 0: raise Exception('The value %v has to be positive.')
+ return v
+
+
+def to_date(value):
+ return None #!!!! TODO
+
+
+def to_geo(value):
+ """Formats to coordinates '47.076207 N 11.453553 E' to the (latitude, longitude) tuplet."""
+ if not value: return (None, None)
+ r = re.match(u'(\d+\.\d+) N (\d+\.\d+) E', value)
+ if r is None: raise Exception(u"Coordinates '%s' have not a format like '47.076207 N 11.453553 E'" % value)
+ return (float(r.groups()[0]), float(r.groups()[1]))
+
+
+def to_title(value):
+ """Line 2237 of includes/Title.php says: $this->mTextform = str_replace( '_', ' ', $dbkey );
+ No not check for None because a missing title is an error"""
+ return value.replace(u'_', u' ')
+
+
+def to_tristate(value):
+ """Does the following conversion:
+ None -> (None, None)
+ u'Ja' -> (True, False)
+ u'Teilweise' -> (True, True)
+ u'Nein' -> (False, True)"""
+ if value is None: return (None, None)
+ elif value == u'Ja': return (True, False)
+ elif value == u'Nein': return (False, True)
+ elif value == u'Teilweise': return (True, True)
+ raise Exception(u"The value has to be one of 'Ja', 'Nein' or 'Teilweise', not '%s'" % value)
+
+
+def to_email(value):
+ return value #!!!! TODO
+
+
+def to_url(value):
+ return value #!!!! TODO
+
+
+def to_phone(value):
+ return value #!!!! TODO
+
+
+def conv(fnct, value, fieldname):
+ "Like one of the to_xxx functions (e.g. to_bool), but adds the field name to the error message"
+ try: return fnct(value)
+ except Exception, e: raise Exception(u"Conversion error in field '%s': %s" % (fieldname, unicode_e(e)))
+
+
+def unicode_e(exception):
+ """Does "unicode(exception)" as it should be. This is a workaround for bug http://bugs.python.org/issue2517
+ that is not fixed in python 2.5.2.
+ Details of bug: "unicode(Exception(u'\xe4'))" raises an UnicodeEncodeError exception."""
+ if exception.message: return unicode(exception.message)
+ return unicode(exception)
+
+
+# User management
+# ---------------
+
class MediaWikiUsers(UsersReadOnly):
def __init__(self, data=None, encrypt=None):
UsersReadOnly.__init__(self, data, encrypt)
# Converter functions
# -------------------
-def to_bool(value):
- if not value: return None
- if value == u'Ja': return True
- if value == u'Nein': return False
- raise Exception(u"'%s' is not a valid boolean value, use one of 'Ja' or 'Nein'" % value)
-
-
-def to_geo(value):
- """Formats to coordinates '47.076207 N 11.453553 E' to the (latitude, longitude) tuplet."""
- if not value: return (None, None)
- r = re.match(u'(\d+\.\d+) N (\d+\.\d+) E', value)
- if r is None: raise Exception(u"Coordinates '%s' have not a format like '47.076207 N 11.453553 E'" % value)
- return (float(r.groups()[0]), float(r.groups()[1]))
-
-def to_title(value):
- """Line 2237 of includes/Title.php says: $this->mTextform = str_replace( '_', ' ', $dbkey );
- No not check for None because a missing title is an error"""
- return value.replace(u'_', u' ')
-
-def unicode_e(exception):
- """Does "unicode(exception)" as it should be. This is a workaround for bug http://bugs.python.org/issue2517
- that is not fixed in python 2.5.2.
- Details of bug: "unicode(Exception(u'\xe4'))" raises an UnicodeEncodeError exception."""
- if exception.message: return unicode(exception.message)
- return unicode(exception)
+from wradmin.lib.mediawiki import to_bool, to_geo, to_title, unicode_e
# Sledding run
# ------------
def update_rodelbahnbox():
- """Collects information from the Rodelbahnbox wiki structures.
- It stores them in the database in case of success and returns a list of tuples (page_id, page_title) of successfully processed pages.
- It raises an exception in case of errors and does not change the database."""
-
- def to_bool_f(value, fieldname):
- "Like 'to_bool' but adds the field name to the exception description"
- try: return to_bool(value)
- except Exception, e:
- raise Exception(u"Error converting to bool in field '%s': %s" % (fieldname, unicode_e(e)))
-
- def to_geo_f(value, fieldname):
- "Like 'to_geo' but adds the field name to the exception description"
- try: return to_geo(value)
- except Exception, e:
- raise Exception(u"Error converting to geo-coordinates in field '%s': %s" % (fieldname, unicode_e(e)))
-
- def process_row(row):
- "It converts a database row to a dictionary and performs checks."
- (page_id, rev_id, old_id, page_title, old_text, under_construction) = row
- page_title = unicode(page_title, 'UTF-8')
- old_text = unicode(old_text, 'UTF-8')
- # Initialize property dict
- property_keys = [
- u'page_id',
- u'page_title',
- u'length',
- u'walktime',
- u'height_top',
- u'height_bottom',
- u'walkup_separate',
- u'lift',
- u'night_light',
- u'sledge_rental',
- u'public_transport',
- u'image',
- u'position_latitude',
- u'position_longitude',
- u'information',
- u'show_in_overview',
- u'creation_date']
- properties = dict()
- for property in property_keys:
- properties[property] = None
- # Match Rodelbahnbox
- match = regexp.search(old_text)
- if not match:
- raise Exception(u"No 'Rodelbahnbox' found")
- box = match.group(1)
- # Process Rodelbahnbox
- for property in box.split('|'):
- property = property.strip()
- if property == u'Rodelbahnbox': continue
- key_value = property.split('=')
- if len(key_value) != 2:
- raise Exception(u"Property '%s' has unexpected format" % key_value)
- key = key_value[0].strip()
- value = key_value[1].strip()
- if key == u'Rodelbahnnummer': pass
- elif key == u'Länge' and value: properties[u'length'] = int(value)
- elif key == u'Gehzeit' and value: properties[u'walktime'] = int(value)
- elif key == u'Höhe oben' and value: properties[u'height_top'] = int(value)
- elif key == u'Höhe unten' and value: properties[u'height_bottom'] = int(value)
- elif key == u'Aufstieg getrennt': properties[u'walkup_separate'] = to_bool_f(value, u'Aufstieg getrennt')
- elif key == u'Lift': properties['lift'] = to_bool_f(value, u'Lift')
- elif key == u'Beleuchtung': properties[u'night_light'] = to_bool_f(value, u'Beleuchtung')
- elif key == u'Rodelverleih': properties[u'sledge_rental'] = to_bool_f(value, u'Rodelverleih')
- elif key == u'Öffentliche Anreise': properties[u'public_transport'] = to_bool_f(value, u'Öffentliche Anreise')
- elif key == u'Bild': properties[u'image'] = value
- elif key == u'Position': (properties[u'position_latitude'], properties[u'position_longitude']) = to_geo_f(value, u'Position') # '47.583333 N 15.75 E'
- elif key == u'Auskunft': properties[u'information'] = value
- elif key == u'In Übersichtskarte': properties[u'show_in_overview'] = to_bool_f(value, u'In Übersichtskarte')
- elif key == u'Aufnahmedatum': properties[u'creation_date'] = value # '2006-03-15'
- properties[u'page_id'] = page_id
- properties[u'page_title'] = to_title(page_title)
- properties[u'under_construction'] = under_construction
- del properties[u'creation_date'] # this is not saved in the database yet
- return properties
-
-
- # Load database modul
- import MySQLdb
- import re
+ """Collects information from the Rodelbahnbox wiki structures.
+ It stores them in the database in case of success and returns a list of tuples (page_id, page_title) of successfully processed pages.
+ It raises an exception in case of errors and does not change the database."""
+
+ def to_bool_f(value, fieldname):
+ "Like 'to_bool' but adds the field name to the exception description"
+ try: return to_bool(value)
+ except Exception, e:
+ raise Exception(u"Error converting to bool in field '%s': %s" % (fieldname, unicode_e(e)))
+
+ def to_geo_f(value, fieldname):
+ "Like 'to_geo' but adds the field name to the exception description"
+ try: return to_geo(value)
+ except Exception, e:
+ raise Exception(u"Error converting to geo-coordinates in field '%s': %s" % (fieldname, unicode_e(e)))
+
+ def process_row(row):
+ "It converts a database row to a dictionary and performs checks."
+ (page_id, rev_id, old_id, page_title, old_text, under_construction) = row
+ page_title = unicode(page_title, 'UTF-8')
+ old_text = unicode(old_text, 'UTF-8')
+ # Initialize property dict
+ property_keys = [
+ u'page_id',
+ u'page_title',
+ u'length',
+ u'walktime',
+ u'height_top',
+ u'height_bottom',
+ u'walkup_separate',
+ u'lift',
+ u'night_light',
+ u'sledge_rental',
+ u'public_transport',
+ u'image',
+ u'position_latitude',
+ u'position_longitude',
+ u'information',
+ u'show_in_overview',
+ u'creation_date']
+ properties = dict()
+ for property in property_keys:
+ properties[property] = None
+ # Match Rodelbahnbox
+ match = regexp.search(old_text)
+ if not match:
+ raise Exception(u"No 'Rodelbahnbox' found")
+ box = match.group(1)
+ # Process Rodelbahnbox
+ for property in box.split('|'):
+ property = property.strip()
+ if property == u'Rodelbahnbox': continue
+ key_value = property.split('=')
+ if len(key_value) != 2:
+ raise Exception(u"Property '%s' has unexpected format" % key_value)
+ key = key_value[0].strip()
+ value = key_value[1].strip()
+ if key == u'Rodelbahnnummer': pass
+ elif key == u'Länge' and value: properties[u'length'] = int(value)
+ elif key == u'Gehzeit' and value: properties[u'walktime'] = int(value)
+ elif key == u'Höhe oben' and value: properties[u'height_top'] = int(value)
+ elif key == u'Höhe unten' and value: properties[u'height_bottom'] = int(value)
+ elif key == u'Aufstieg getrennt': properties[u'walkup_separate'] = to_bool_f(value, u'Aufstieg getrennt')
+ elif key == u'Lift': properties['lift'] = to_bool_f(value, u'Lift')
+ elif key == u'Beleuchtung': properties[u'night_light'] = to_bool_f(value, u'Beleuchtung')
+ elif key == u'Rodelverleih': properties[u'sledge_rental'] = to_bool_f(value, u'Rodelverleih')
+ elif key == u'Öffentliche Anreise': properties[u'public_transport'] = to_bool_f(value, u'Öffentliche Anreise')
+ elif key == u'Bild': properties[u'image'] = value
+ elif key == u'Position': (properties[u'position_latitude'], properties[u'position_longitude']) = to_geo_f(value, u'Position') # '47.583333 N 15.75 E'
+ elif key == u'Auskunft': properties[u'information'] = value
+ elif key == u'In Übersichtskarte': properties[u'show_in_overview'] = to_bool_f(value, u'In Übersichtskarte')
+ elif key == u'Aufnahmedatum': properties[u'creation_date'] = value # '2006-03-15'
+ properties[u'page_id'] = page_id
+ properties[u'page_title'] = to_title(page_title)
+ properties[u'under_construction'] = under_construction
+ del properties[u'creation_date'] # this is not saved in the database yet
+ return properties
+
+
+ # Load database modul
+ import MySQLdb
+ import re
- conn = get_wiki_connection()
- cuo = conn.cursor() # cursor for output (out of the database)
- cui = conn.cursor() # cursor for input (into the database)
-
- sql = u"select page_id, rev_id, old_id, page_title, old_text, 'In_Arbeit' in (select cl_to from categorylinks where cl_from=page_id) as under_construction from page, revision, text, categorylinks where page_latest=rev_id and old_id=rev_text_id and cl_from=page_id and cl_to='Rodelbahn' order by page_title"
- cuo.execute(sql)
-
- regexp = re.compile(u"\{\{(Rodelbahnbox[^\}]*)\}\}", re.DOTALL)
- try:
- sledding_list = [];
- for row in cuo:
- try:
- page_id = row[0]
- page_title = unicode(row[3], 'UTF-8')
- properties = process_row(row)
- except Exception, e:
- raise Exception(unicode_e(e) + u". Seite '%s' (page_id %d)." % (page_title, page_id))
- sledding_list.append(properties)
-
- sql = u'delete from wrsleddingcache'
- cui.execute(sql)
-
- if len(sledding_list) > 0:
- columns = sledding_list[0].keys()
- sql = u'insert into wrsleddingcache (' + ', '.join(columns) + ') values '
- sql = sql + '(' + ', '.join(['%s' for c in columns]) + ')'
- for sledding in sledding_list:
- cui.execute(sql, sledding.values())
+ conn = get_wiki_connection()
+ cuo = conn.cursor() # cursor for output (out of the database)
+ cui = conn.cursor() # cursor for input (into the database)
+
+ sql = u"select page_id, rev_id, old_id, page_title, old_text, 'In_Arbeit' in (select cl_to from categorylinks where cl_from=page_id) as under_construction from page, revision, text, categorylinks where page_latest=rev_id and old_id=rev_text_id and cl_from=page_id and cl_to='Rodelbahn' order by page_title"
+ cuo.execute(sql)
+
+ regexp = re.compile(u"\{\{(Rodelbahnbox[^\}]*)\}\}", re.DOTALL)
+ try:
+ sledding_list = [];
+ for row in cuo:
+ try:
+ page_id = row[0]
+ page_title = unicode(row[3], 'UTF-8')
+ properties = process_row(row)
+ except Exception, e:
+ raise Exception(unicode_e(e) + u". Seite '%s' (page_id %d)." % (page_title, page_id))
+ sledding_list.append(properties)
+
+ sql = u'delete from wrsleddingcache'
+ cui.execute(sql)
+
+ if len(sledding_list) > 0:
+ columns = sledding_list[0].keys()
+ sql = u'insert into wrsleddingcache (' + ', '.join(columns) + ') values '
+ sql = sql + '(' + ', '.join(['%s' for c in columns]) + ')'
+ for sledding in sledding_list:
+ cui.execute(sql, sledding.values())
- conn.commit()
- conn.close()
- except:
- conn.rollback()
- conn.close()
- raise
- return sledding_list
\ No newline at end of file
+ conn.commit()
+ conn.close()
+ except:
+ conn.rollback()
+ conn.close()
+ raise
+ return sledding_list
\ No newline at end of file
from pylons import config
def get_wiki_connection():
- "Returns a connection object to the wiki database."
- host = config['wikidbserver']
- database = config['wikidbname']
- username = config['wikidbuser']
- password = config['wikidbpassword']
- return MySQLdb.connect(host=host, db=database, user=username, passwd=password, use_unicode=True, charset='utf8')
+ "Returns a connection object to the wiki database."
+ host = config['wikidbserver']
+ database = config['wikidbname']
+ username = config['wikidbuser']
+ password = config['wikidbpassword']
+ return MySQLdb.connect(host=host, db=database, user=username, passwd=password, use_unicode=True, charset='utf8')
def query_sledding_routes():
- conn = get_wiki_connection()
- cu = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
- sql = "select page_id, rev_id, old_id, cast(page_title as char) as page_title, 'In_Arbeit' in (select cl_to from categorylinks where cl_from=page_id) as under_construction, page_id in (select tl_from from templatelinks where tl_title='Forumlink' and tl_namespace='10') as forum_link_present from page, revision, text, categorylinks where page_latest=rev_id and old_id=rev_text_id and cl_from=page_id and cl_to='Rodelbahn' order by page_title"
- cu.execute(sql)
- sledding_routes = cu.fetchall()
- return sledding_routes
+ conn = get_wiki_connection()
+ cu = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
+ sql = "select page_id, rev_id, old_id, cast(page_title as char) as page_title, 'In_Arbeit' in (select cl_to from categorylinks where cl_from=page_id) as under_construction, page_id in (select tl_from from templatelinks where tl_title='Forumlink' and tl_namespace='10') as forum_link_present from page, revision, text, categorylinks where page_latest=rev_id and old_id=rev_text_id and cl_from=page_id and cl_to='Rodelbahn' order by page_title"
+ cu.execute(sql)
+ sledding_routes = cu.fetchall()
+ return sledding_routes
sa.Column("position_latitude", types.Float),
sa.Column("position_longitude", types.Float),
sa.Column("information", types.Unicode(255)),
+ sa.Column("forum_id", types.Integer),
sa.Column("under_construction", types.Boolean),
sa.Column("show_in_overview", types.Boolean),
)
+wrinncache_table = sa.Table("wrinncache", meta.metadata,
+ sa.Column("page_id", types.Integer, primary_key=True),
+ sa.Column("page_title", types.Unicode(255)),
+ sa.Column("height", types.Integer),
+ sa.Column("phone", types.Unicode(30)),
+ sa.Column("mobile_phone", types.Unicode(30)),
+ sa.Column("email", types.Unicode(255)),
+ sa.Column("homepage", types.Unicode(255)),
+ sa.Column("smoker_area", types.Boolean),
+ sa.Column("nonsmoker_area", types.Boolean),
+ sa.Column("image", types.Unicode(255)),
+ sa.Column("position_latitude", types.Float),
+ sa.Column("position_longitude", types.Float),
+ sa.Column("under_construction", types.Boolean),
+ )
+
+
+page_table = sa.Table("page", meta.metadata,
+ sa.Column("page_id", types.Integer, primary_key=True),
+ sa.Column("page_namespace", types.Integer, nullable=False),
+ sa.Column("page_title", types.Unicode(255), nullable=False),
+ sa.Column("page_restrictions", types.Unicode, nullable=False),
+ sa.Column("page_counter", types.Integer, nullable=False),
+ sa.Column("page_is_redirect", types.Integer, nullable=False),
+ sa.Column("page_is_new", types.Integer, nullable=False),
+ sa.Column("page_random", types.Float, nullable=False),
+ sa.Column("page_touched", types.Unicode(14), nullable=False),
+ sa.Column("page_latest", types.Integer, nullable=False),
+ sa.Column("page_len", types.Integer, nullable=False),
+ )
+
+
+revision_table = sa.Table("revision", meta.metadata,
+ sa.Column("rev_id", types.Integer, nullable=False, primary_key=True),
+ sa.Column("rev_page", types.Integer, nullable=False, primary_key=True),
+ sa.Column("rev_text_id", types.Integer, nullable=False),
+ sa.Column("rev_comment", types.Unicode),
+ sa.Column("rev_user", types.Integer, nullable=False),
+ sa.Column("rev_user_text", types.Unicode(255), nullable=False),
+ sa.Column("rev_timestamp", types.Unicode(14), nullable=False),
+ sa.Column("rev_minor_edit", types.Integer, nullable=False),
+ sa.Column("rev_deleted", types.Integer, nullable=False),
+ sa.Column("rev_len", types.Integer, nullable=False),
+ sa.Column("rev_parent_id", types.Integer, nullable=False),
+ )
+
+
+text_table = sa.Table("text", meta.metadata,
+ sa.Column("old_id", types.Integer, primary_key=True),
+ sa.Column("old_text", types.Unicode),
+ sa.Column("old_flags", types.Unicode),
+ )
+
+
+categorylinks_table = sa.Table("categorylinks", meta.metadata,
+ sa.Column("cl_from", types.Integer, nullable=False, primary_key=True),
+ sa.Column("cl_to", types.Unicode(255), nullable=False, primary_key=True),
+ sa.Column("cl_sortkey", types.Unicode, nullable=False),
+ sa.Column("cl_timestamp", types.DateTime, nullable=False),
+ )
+
+
class WrReport(object):
pass
pass
+class WrInnCache(object):
+ pass
+
+
orm.mapper(WrReport, wrreport_table)
# We could add a relation but we don't need it yet:
# orm.mapper(WrSleddingCache, wrsleddingcache_table, properties = {'reports': orm.relation(WrReport, backref='sledding')})
orm.mapper(WrSleddingCache, wrsleddingcache_table)
-
+orm.mapper(WrInnCache, wrinncache_table)
engine = None
# SQLAlchemy session manager. Updated by model.init_model()
-Session = scoped_session(sessionmaker())
+Session = scoped_session(sessionmaker(autoflush=True, autocommit=False))
# Global metadata. If you have multiple databases with overlapping table
# names, you'll need a metadata for each database
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="master.html" />
+
+<head>
+ <title>Gasthäuser</title>
+</head>
+
+<body>
+<h2>Gasthäuser</h2>
+
+<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>${c.paginator.pager('$link_first $link_previous $first_item bis $last_item von $item_count $link_next $link_last', controller='gasthaus', action='list')}</p>
+
+<table>
+ <tr>
+ <th>ID</th>
+ <th>Name</th>
+ <th>Höhe</th>
+ <th>Festnetz</th>
+ <th>Mobiltelefon</th>
+ <th>E-Mail</th>
+ <th>Homepage</th>
+ <th>Rauchfrei</th>
+ <th>Bild</th>
+ <th>Latitude</th>
+ <th>Longitude</th>
+ <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>${s.page_title}</td>
+ <td>${s.height}</td>
+ <td>${s.phone}</td>
+ <td>${s.mobile_phone}</td>
+ <td>${s.email}</td>
+ <td>${s.homepage}</td>
+ <td>${h.tristate(s.nonsmoker_area, s.smoker_area)}</td>
+ <td><small>${s.image}</small></td>
+ <td>${s.position_latitude}</td>
+ <td>${s.position_longitude}</td>
+ <td>${h.bool(s.under_construction)}</td>
+ </tr>
+</table>
+
+<p>${c.paginator.pager('~2~', controller='gasthaus', action='list')}</p>
+
+</body>
+</html>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="master.html" />
+
+<head>
+ <title>Gasthaus</title>
+</head>
+
+<body>
+<h2>Gasthaus #${c.inn.page_id}: ${c.inn.page_title}</h2>
+
+<h3>Inhalt der Gasthausbox</h3>
+<table>
+ <tr>
+ <th>ID</th>
+ <td>${c.inn.page_id}</td>
+ </tr>
+ <tr>
+ <th>Name</th>
+ <td>${c.inn.page_title}</td>
+ </tr>
+ <tr>
+ <th>Höhe</th>
+ <td>${c.inn.height}</td>
+ </tr>
+ <tr>
+ <th>Festnetz</th>
+ <td>${c.inn.phone}</td>
+ </tr>
+ <tr>
+ <th>Mobiltelefon</th>
+ <td>${c.inn.mobile_phone}</td>
+ </tr>
+ <tr>
+ <th>E-Mail</th>
+ <td>${c.inn.email}</td>
+ </tr>
+ <tr>
+ <th>Homepage</th>
+ <td>${c.inn.homepage}</td>
+ </tr>
+ <tr>
+ <th>Rauchfrei</th>
+ <td>${h.tristate(c.inn.nonsmoker_area, c.inn.smoker_area)}</td>
+ </tr>
+ <tr>
+ <th>Bild</th>
+ <td>${c.inn.image}</td>
+ </tr>
+ <tr>
+ <th>Latitude</th>
+ <td>${c.inn.position_latitude}</td>
+ </tr>
+ <tr>
+ <th>Longitude</th>
+ <td>${c.inn.position_longitude}</td>
+ </tr>
+ <tr>
+ <th>In Arbeit</th>
+ <td>${c.inn.under_construction}</td>
+ </tr>
+</table>
+
+<ul>
+ <li><a href="${h.wiki(c.inn.page_title)}">Zeige bei <tt>www.winterrodeln.org</tt></a></li>
+ <py:if test="c.inn.position_latitude and c.inn.position_longitude">
+ <li><a href="${h.google_maps(c.inn.position_latitude, c.inn.position_longitude)}">Zeige bei Google Maps</a></li>
+ </py:if>
+</ul>
+
+
+</body>
+</html>
<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='wrcontroller', action='rodelbahnbox')}">Rodelbahn-Infoboxen</a> überprüfen und Koordinaten aktualisieren</li>
+ <li><a href="${h.url_for(controller='gasthaus', action='list')}">Gasthäuser</a></li>
</ul>
<ul>
<li><a href="${h.url_for(controller='wrcontroller', action='rodelbahnbox')}">Rodelbahnboxen</a></li>
<li><a href="${h.url_for(controller='bericht', action='list')}">Berichte</a></li>
<li><a href="${h.url_for(controller='wrcontroller', action='forumlink')}">Forum-Links</a></li>
+ <li><a href="${h.url_for(controller='gasthaus', action='list')}">Gasthäuser</a></li>
</ul>
<div py:if="session.has_key('flash')" class="${session.pop('flashclass', 'flash')}">${session.pop('flash')}<?python session.save() ?></div>
<td>${s.walktime}</td>
<td>${s.height_top}</td>
<td>${s.height_bottom}</td>
- <td>${s.walkup_separate}</td>
- <td>${s.lift}</td>
- <td>${s.night_light}</td>
- <td>${s.sledge_rental}</td>
- <td>${s.public_transport}</td>
+ <td>${h.bool(s.walkup_separate)}</td>
+ <td>${h.bool(s.lift)}</td>
+ <td>${h.bool(s.night_light)}</td>
+ <td>${h.bool(s.sledge_rental)}</td>
+ <td>${h.bool(s.public_transport)}</td>
<td><small>${s.image}</small></td>
<td>${s.position_latitude}</td>
<td>${s.position_longitude}</td>
<td>${s.information}</td>
- <td>${s.under_construction}</td>
- <td>${s.show_in_overview}</td>
+ <td>${h.bool(s.under_construction)}</td>
+ <td>${h.bool(s.show_in_overview)}</td>
</tr>
</table>