Repaired function update_wrinncache.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 29 Jan 2017 22:18:53 +0000 (22:18 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 29 Jan 2017 22:18:53 +0000 (22:18 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2624 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrpylib/wrmwcache.py

index 5b13719b670bf1af439264a3112bd374b8c82203..8d76743df892f0eaf505f246999f5d8547ad1a1c 100644 (file)
@@ -73,6 +73,8 @@ def update_wrinncache(connection):
     categorylinks = mwdb.categorylinks_table(metadata)
     revision = mwdb.revision_table(metadata)
     text = mwdb.text_table(metadata)
+    class Inn:
+        pass
 
     transaction = connection.begin()
 
@@ -86,13 +88,14 @@ def update_wrinncache(connection):
         
     # Refill wrinncache table
     for inn_page in inn_pages:
-        try: 
-            start, end, inn = wrmwmarkup.gasthausbox_to_inn(inn_page.old_text)
+        try:
+            gasthausbox = wrvalidators.gasthausbox_from_str(inn_page.old_text)
+            inn = wrmwmarkup.inn_from_gasthausbox(gasthausbox, Inn())
             inn.page_id = inn_page.page_id
             inn.page_title = inn_page.page_title
             inn.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==inn_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
             connection.execute(wrinncache.insert(inn.__dict__))
-        except (RuntimeError, formencode.Invalid) as e:
+        except ValueError as e:
             transaction.rollback()
             error_msg = "Error as inn '{0}': {1}".format(inn_page.page_title, str(e))
             raise UpdateCacheError(error_msg, inn_page.page_title, e)