version 1.82, 2006/04/24 16:09:52
|
version 1.83, 2006/04/25 17:01:54
|
Line 80 class ZSQLExtendFolder(Folder,Persistent
|
Line 80 class ZSQLExtendFolder(Folder,Persistent
|
"""quote str for sql""" |
"""quote str for sql""" |
return sql_quote(str) |
return sql_quote(str) |
|
|
|
|
|
def normalizeField(self,table,fieldname, newFieldName=None,mode="alter", RESPONSE=None): |
|
"""normalize a field""" |
|
import unicodedata |
|
|
|
if not newFieldName: |
|
newFieldName=fieldname+"_normal" |
|
|
|
def normal(str): |
|
if str: |
|
return unicodedata.normalize('NFKD', str.decode('utf-8')).encode('ASCII', 'ignore') |
|
else: |
|
return "" |
|
if mode=="create": # create the field |
|
qstr="""alter table %s add %s %s""" |
|
self.ZSQLSimpleSearch(qstr%(table,newFieldName,'text')) |
|
|
|
qstr="select oid,%s from %s"%(fieldname,table) |
|
for result in self.ZSQLSimpleSearch(qstr): |
|
qstr="update %s set %s = %s where oid = %s" |
|
|
|
self.ZSQLSimpleSearch(qstr%(table,newFieldName,self.ZSQLQuote(normal(getattr(result,fieldname))),result.oid)) |
|
|
def importAccessModell(self,configFileName,RESPONSE=None): |
def importAccessModell(self,configFileName,RESPONSE=None): |
"""import tables from access |
"""import tables from access |
@param configFileName: xml-configfile |
@param configFileName: xml-configfile |