[Formed-commits] r336 - in trunk: . formed/formed/plugins/export

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jun 18 09:00:02 CEST 2009


Author: torsten
Date: 2009-06-18 09:00:01 +0200 (Thu, 18 Jun 2009)
New Revision: 336

Modified:
   trunk/ChangeLog
   trunk/formed/formed/plugins/export/new_sql.py
Log:
Commented out generation of page_views.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-06-17 10:45:48 UTC (rev 335)
+++ trunk/ChangeLog	2009-06-18 07:00:01 UTC (rev 336)
@@ -1,3 +1,8 @@
+2009-06-18	Torsten Irländer <torsten.irlaender at intevation.de>
+
+	* formed/formed/plugins/export/new_sql.py: Commented out generation of
+	page_views, as they do not work with rgroups.
+
 2009-06-17	Torsten Irländer <torsten.irlaender at intevation.de>
 
 	* formed/formed/plugins/export/new_sql.py: Fixed anonymize function

Modified: trunk/formed/formed/plugins/export/new_sql.py
===================================================================
--- trunk/formed/formed/plugins/export/new_sql.py	2009-06-17 10:45:48 UTC (rev 335)
+++ trunk/formed/formed/plugins/export/new_sql.py	2009-06-18 07:00:01 UTC (rev 336)
@@ -33,7 +33,7 @@
             WHERE nm2.benutzer_id = getuserid()
         )
     )
-    OR pg_has_role('admin_ka','MEMBER');
+    OR pg_has_role('admin','MEMBER');
 """
 
 FORBID_DELETE_RULE = \
@@ -670,117 +670,123 @@
             pfeil('\n--\n-- GRANTS ON TABLES\n--\n')
             pfeil(tableGrants)
 
-            pfeil('\n--\n-- VIEWS\n--\n')
-            page_tables = [x[0].name for x in arr]
-            marked = set()
-            for tup in arr:
-                raw_table, joins, linear = tup
-                table = raw_table.name
-                for page in linear:
-                    table_name = "%s_tbl" % sqlName(page.getName())
-                    if table_name in page_tables:
-                        marked.add(table_name)
-                    else:
-                        pfeil("CREATE OR REPLACE VIEW %s_view AS SELECT\n" \
-                            % sqlName(page.getName()))
+            # Generation of pageviews seems to bee obsolete and is not
+            # compatible with the new repeatgroup approach as the views
+            # references fields in the mastertable which are now outsource to a
+            # particular rggroup-table in database.
+            # => Commenting out
 
-                        ws = [
-                            w.getName() 
-                            for w in page.allWidgets() if w.getName()]
+            #pfeil('\n--\n-- VIEWS\n--\n')
+            #page_tables = [x[0].name for x in arr]
+            #marked = set()
+            #for tup in arr:
+            #    raw_table, joins, linear = tup
+            #    table = raw_table.name
+            #    for page in linear:
+            #        table_name = "%s_tbl" % sqlName(page.getName())
+            #        if table_name in page_tables:
+            #            marked.add(table_name)
+            #        else:
+            #            pfeil("CREATE OR REPLACE VIEW %s_view AS SELECT\n" \
+            #                % sqlName(page.getName()))
 
-                        widgets = [
-                            "    %s.id AS id" % table ]
-                        widgets.extend([
-                            "    %s.%s AS %s" % (table, n, n)
-                            for n in ws]);
-                        pfeil(",\n".join(widgets))
-                        pfeil("\nFROM %s\n" % table)
+            #            ws = [
+            #                w.getName() 
+            #                for w in page.allWidgets() if w.getName()]
 
-                        njoins = joins
-                        oldTable = table
+            #            widgets = [
+            #                "    %s.id AS id" % table ]
+            #            widgets.extend([
+            #                "    %s.%s AS %s" % (table, n, n)
+            #                for n in ws]);
+            #            pfeil(",\n".join(widgets))
+            #            pfeil("\nFROM %s\n" % table)
 
-                        while njoins:
-                            try:
-                                idx = page_tables.index(njoins[0])
-                            except ValueError:
-                                break
-                            ntup = arr[idx]
-                            njoins = ntup[1]
-                            nname = ntup[0].name
+            #            njoins = joins
+            #            oldTable = table
 
-                            pfeil("    INNER JOIN %s\n" % nname)
-                            pfeil("    ON         %s.%s_id = %s.id\n" % (
-                                oldTable, removeTbl(nname), nname))
-                            oldTable = nname
-                        pfeil(VIEW_WHERE_CLAUSE)
-                        pfeil("\n")
+            #            while njoins:
+            #                try:
+            #                    idx = page_tables.index(njoins[0])
+            #                except ValueError:
+            #                    break
+            #                ntup = arr[idx]
+            #                njoins = ntup[1]
+            #                nname = ntup[0].name
 
-                        pfeil(UPDATE_RULE % (sqlName(page.getName()), sqlName(page.getName()), table))
-                        pfeil(",\n".join(["    %s = NEW.%s" % (n, n) for n in ws]))
-                        pfeil("\n")
-                        pfeil("WHERE id = NEW.id;\n\n")
+            #                pfeil("    INNER JOIN %s\n" % nname)
+            #                pfeil("    ON         %s.%s_id = %s.id\n" % (
+            #                    oldTable, removeTbl(nname), nname))
+            #                oldTable = nname
+            #            pfeil(VIEW_WHERE_CLAUSE)
+            #            pfeil("\n")
 
-                        pn = sqlName(page.getName())
+            #            pfeil(UPDATE_RULE % (sqlName(page.getName()), sqlName(page.getName()), table))
+            #            pfeil(",\n".join(["    %s = NEW.%s" % (n, n) for n in ws]))
+            #            pfeil("\n")
+            #            pfeil("WHERE id = NEW.id;\n\n")
 
-                        vn = "%s_view" % sqlName(pn)
-                        pfeil(GRANT_SELECT % (vn, ':cm_group'))
-                        pfeil(GRANT_UPDATE % (vn, ':cm_group'))
-                        pfeil(GRANT_SELECT % (vn, ':admin_group'))
-                        pfeil("\n")
+            #            pn = sqlName(page.getName())
 
-                        pfeil(FORBID_DELETE_RULE % (pn, pn))
-                        pfeil("\n")
-                        pfeil(FORBID_INSERT_RULE % (pn, pn))
-                        pfeil("\n")
+            #            vn = "%s_view" % sqlName(pn)
+            #            pfeil(GRANT_SELECT % (vn, ':cm_group'))
+            #            pfeil(GRANT_UPDATE % (vn, ':cm_group'))
+            #            pfeil(GRANT_SELECT % (vn, ':admin_group'))
+            #            pfeil("\n")
 
-            for pt in page_tables:
-                if pt not in marked \
-                and not arr[page_tables.index(pt)][2]:
-                    pfeil("CREATE OR REPLACE VIEW %s_page_view AS SELECT\n" % sqlName(pt))
+            #            pfeil(FORBID_DELETE_RULE % (pn, pn))
+            #            pfeil("\n")
+            #            pfeil(FORBID_INSERT_RULE % (pn, pn))
+            #            pfeil("\n")
 
-                    group = None
-                    for tup2 in arr:
-                        if sqlName(tup2[0].root.getName())+"_tbl" == pt:
-                            group = tup2[0].root
-                            break
+            #for pt in page_tables:
+            #    if pt not in marked \
+            #    and not arr[page_tables.index(pt)][2]:
+            #        pfeil("CREATE OR REPLACE VIEW %s_page_view AS SELECT\n" % sqlName(pt))
 
-                    ws = [w.getName() for w in group.allWidgets() if w.getName()]
+            #        group = None
+            #        for tup2 in arr:
+            #            if sqlName(tup2[0].root.getName())+"_tbl" == pt:
+            #                group = tup2[0].root
+            #                break
 
-                    widgets = [
-                        "    %s.id AS id" % pt
-                    ]
-                    widgets.extend([
-                        "    %s.%s AS %s" % (pt, n, n)
-                        for n in ws])
-                    pfeil(",\n".join(widgets))
-                    pfeil("\nFROM %s\n" % pt)
-                    joins = arr[page_tables.index(pt)][1][:]
-                    oldTable = pt
-                    for join in joins:
-                        pfeil("    INNER JOIN %s\n" % join)
-                        pfeil("    ON         %s.%s_id = %s.id\n" % (
-                            oldTable, removeTbl(join), join))
-                        oldTable = join
-                    pfeil(VIEW_WHERE_CLAUSE)
-                    pfeil("\n")
-                    v = "%s_page" % pt
+            #        ws = [w.getName() for w in group.allWidgets() if w.getName()]
 
-                    pfeil(UPDATE_RULE % (v, v, pt))
-                    pfeil(",\n".join(["    %s = NEW.%s" % (n, n) for n in ws]))
-                    pfeil("\n")
-                    pfeil("WHERE id = NEW.id;\n\n")
+            #        widgets = [
+            #            "    %s.id AS id" % pt
+            #        ]
+            #        widgets.extend([
+            #            "    %s.%s AS %s" % (pt, n, n)
+            #            for n in ws])
+            #        pfeil(",\n".join(widgets))
+            #        pfeil("\nFROM %s\n" % pt)
+            #        joins = arr[page_tables.index(pt)][1][:]
+            #        oldTable = pt
+            #        for join in joins:
+            #            pfeil("    INNER JOIN %s\n" % join)
+            #            pfeil("    ON         %s.%s_id = %s.id\n" % (
+            #                oldTable, removeTbl(join), join))
+            #            oldTable = join
+            #        pfeil(VIEW_WHERE_CLAUSE)
+            #        pfeil("\n")
+            #        v = "%s_page" % pt
 
-                    vn = "%s_page_view" % sqlName(pt)
-                    pfeil(GRANT_SELECT % (vn, ':cm_group'))
-                    pfeil(GRANT_UPDATE % (vn, ':cm_group'))
-                    pfeil(GRANT_SELECT % (vn, ':admin_group'))
-                    pfeil("\n")
+            #        pfeil(UPDATE_RULE % (v, v, pt))
+            #        pfeil(",\n".join(["    %s = NEW.%s" % (n, n) for n in ws]))
+            #        pfeil("\n")
+            #        pfeil("WHERE id = NEW.id;\n\n")
 
-                    pfeil(FORBID_DELETE_RULE % (v, v))
-                    pfeil("\n")
-                    pfeil(FORBID_INSERT_RULE % (v, v))
-                    pfeil("\n")
+            #        vn = "%s_page_view" % sqlName(pt)
+            #        pfeil(GRANT_SELECT % (vn, ':cm_group'))
+            #        pfeil(GRANT_UPDATE % (vn, ':cm_group'))
+            #        pfeil(GRANT_SELECT % (vn, ':admin_group'))
+            #        pfeil("\n")
 
+            #        pfeil(FORBID_DELETE_RULE % (v, v))
+            #        pfeil("\n")
+            #        pfeil(FORBID_INSERT_RULE % (v, v))
+            #        pfeil("\n")
+
             # generate ro-views for master table and repeat groups
             pfeil("--\n--\n-- views for master table and repeat groups\n--\n")
             for tup in arr:



More information about the Formed-commits mailing list