From: philipp Date: Mon, 3 Oct 2011 20:51:00 +0000 (+0000) Subject: The change of the wrreportcache table caused necessary changes in this module. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/2974e804f9035d062b48b2cb42bef2bb87809f02?hp=3f93a335b449243b879c5e38bfecce98ddb3dbe7 The change of the wrreportcache table caused necessary changes in this module. git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/wrpylib@942 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- diff --git a/setup.py b/setup.py index 6adb616..ba56f63 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name='wrpylib', - version='0.0.15', + version='0.0.16', description='Winterrodeln Python Library', author='Philipp Spitzer', author_email='philipp.spitzer@winterrodeln.org', diff --git a/wrpylib/wrmwcache.py b/wrpylib/wrmwcache.py index 431e005..c197f94 100644 --- a/wrpylib/wrmwcache.py +++ b/wrpylib/wrmwcache.py @@ -3,7 +3,6 @@ # $Id$ # $HeadURL$ """Contains functions that maintain/update the cache tables.""" -from xml.etree import ElementTree from sqlalchemy import schema from sqlalchemy.sql import select import formencode @@ -111,33 +110,19 @@ def update_wrreportcache(connection, page_id=None): wrreportcache = wrmwdb.wrreportcache_table(metadata) transaction = connection.begin() - # Delte the datasets we are going to update + # Delete the datasets we are going to update sql_del = wrreportcache.delete() if not page_id is None: sql_del = sql_del.where(wrreportcache.c.page_id == page_id) connection.execute(sql_del) def insert_row(connection, rowlist): if len(rowlist) == 0: return - # Build XML - reports_xml = ElementTree.Element('reports') - for row in rowlist: - report_xml = ElementTree.SubElement(reports_xml, 'report') - report_xml.set('report_id', unicode(row.report_id)) - report_xml.set('date_report', unicode(row.report_date_report)) - report_xml.set('condition', unicode(row.report_condition)) - report_xml.set('author_name', unicode(row.report_author_name)) - report_xml.set('author_username', unicode(row.report_author_username)) - report_xml.text = unicode(row.report_description) - reports_xml.set('page_id', unicode(row.page_id)) - reports_xml.set('page_title', row.page_title) - reports_xml = unicode(ElementTree.tostring(reports_xml, 'utf8'), 'utf8') # there is not ElementTree.tounicode()) - # Insert the report(s) + # Insert the report row = dict(rowlist[0]) - row['reports_xml'] = reports_xml connection.execute(wrreportcache.insert(values=row)) # Select the rows to update - sql = 'select page_id, page_title, wrreport.id as report_id, date_report as report_date_report, `condition` as report_condition, description as report_description, author_name as report_author_name, if(author_userid is null, null, author_username) as report_author_username from wrreport where {0}`condition` is not null and date_invalid > now() and delete_date is null order by page_id, date_report desc, date_entry desc'.format('' if page_id is None else 'page_id={0} and '.format(page_id)) + sql = 'select page_id, page_title, wrreport.id as report_id, date_report, `condition`, description, author_name, if(author_userid is null, null, author_username) as author_username from wrreport where {0}`condition` is not null and date_invalid > now() and delete_date is null order by page_id, date_report desc, date_entry desc'.format('' if page_id is None else 'page_id={0} and '.format(page_id)) cursor = connection.execute(sql) page_id = None rowlist = [] diff --git a/wrpylib/wrmwdb.py b/wrpylib/wrmwdb.py index 761a8db..82bad4a 100644 --- a/wrpylib/wrmwdb.py +++ b/wrpylib/wrmwdb.py @@ -122,12 +122,11 @@ def wrreportcache_table(metadata): Column("page_id", types.Integer, primary_key=True), Column("page_title", types.Unicode(255), nullable=False), Column("report_id", types.Integer), - Column("report_date_report", types.Date), - Column("report_condition", types.Integer), - Column("report_description", types.Unicode), - Column("report_author_name", types.Unicode(30)), - Column("report_author_username", types.Unicode(30)), - Column("reports_xml", types.Unicode), + Column("date_report", types.Date), + Column("condition", types.Integer), + Column("description", types.Unicode), + Column("author_name", types.Unicode(30)), + Column("author_username", types.Unicode(30)) )