The change of the wrreportcache table caused necessary changes in this module.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Mon, 3 Oct 2011 20:51:00 +0000 (20:51 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Mon, 3 Oct 2011 20:51:00 +0000 (20:51 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/wrpylib@942 7aebc617-e5e2-0310-91dc-80fb5f6d2477

setup.py
wrpylib/wrmwcache.py
wrpylib/wrmwdb.py

index 6adb616b9d733dd1809b2a34bb58e4df6dabc94d..ba56f6371a0fd64c2cb1282cf6b3a43f0567d075 100644 (file)
--- 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',
index 431e005ac497f02adbb668d221636252347cdbbc..c197f94fee738b35a6b7d4bd6ed99ad2fbd83e71 100644 (file)
@@ -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 = []
index 761a8db3c500ea76f08c2ccd42278a672818ccd8..82bad4a4c59175dd42e64baddd56edb51c9b55ae 100644 (file)
@@ -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))
     )