[Formed-commits] r384 - trunk/formed/formed/plugins/export
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 6 15:15:52 CEST 2010
Author: torsten
Date: 2010-08-06 15:15:51 +0200 (Fri, 06 Aug 2010)
New Revision: 384
Modified:
trunk/formed/formed/plugins/export/new_sql.py
Log:
Added anonymisation for Choicelists. Set value to -1
Modified: trunk/formed/formed/plugins/export/new_sql.py
===================================================================
--- trunk/formed/formed/plugins/export/new_sql.py 2010-08-04 13:54:10 UTC (rev 383)
+++ trunk/formed/formed/plugins/export/new_sql.py 2010-08-06 13:15:51 UTC (rev 384)
@@ -117,7 +117,7 @@
# no set needed
continue
if c.func == "suppress_value" or c.func == "suppress_value2":
- anonym.append('%s = NULL' % c.name)
+ anonym.append('%s = %s' % (c.name, c.anon_value))
else:
args = [x.strip() for x in c.func.split(':')]
if len(args) > 1:
@@ -168,11 +168,12 @@
pfeil(ANON_FUNCTION_FOOTER)
class Column:
- def __init__(self, name, datatype, accessible=True, func=None):
+ def __init__(self, name, datatype, accessible=True, func=None, anon_value='NULL'):
self.name = name
self.datatype = datatype
self.accessible = accessible
self.func = func
+ self.anon_value = anon_value
def definition(self):
return "%s %s" % (self.name, self.datatype)
@@ -269,6 +270,7 @@
table.appendColumn(Column("id", "SERIAL PRIMARY KEY NOT NULL", False))
table.appendColumn(Column("uuid_id", "CHAR(36)", False))
table.appendColumn(Column("bearbeiter_id", "int NOT NULL", False))
+ table.appendColumn(Column("fkz", "VARCHAR(60)", False))
table.appendConstraint("UNIQUE (uuid_id)")
# table.appendConstraint(
@@ -466,7 +468,7 @@
table = self.tableStack[-1]
- table.appendColumn(Column(name, 'INTEGER DEFAULT -1', func=choice.getFunction()))
+ table.appendColumn(Column(name, 'INTEGER DEFAULT -1', func=choice.getFunction(), anon_value=-1))
table.appendConstraint(
"FOREIGN KEY (%s) REFERENCES %s (id)" % (name, into))
@@ -868,8 +870,11 @@
anonym.append(c.name)
else:
if c.func == "suppress_value" or c.func == "suppress_value2":
- datatype = c.datatype.split()[0] # a bit hackish
- anonym.append('NULL::%s AS %s' % (datatype, c.name))
+ if c.anon_value == 'NULL':
+ datatype = c.datatype.split()[0] # a bit hackish
+ anonym.append('NULL::%s AS %s' % (datatype, c.name))
+ else:
+ anonym.append('%s AS %s' % (c.anon_value, c.name))
else:
args = [x.strip() for x in c.func.split(':')]
if len(args) > 1:
More information about the Formed-commits
mailing list