version 1.17, 2007/12/11 19:35:34
|
version 1.20, 2008/01/09 14:23:26
|
Line 19 except:
|
Line 19 except:
|
|
|
fm_ns = 'http://www.filemaker.com/fmpxmlresult' |
fm_ns = 'http://www.filemaker.com/fmpxmlresult' |
|
|
version_string = "V0.5 ROC 11.12.2007" |
version_string = "V0.5.1 ROC 9.1.2008" |
|
|
|
def unicodify(str, withNone=False): |
|
"""decode str (utf-8 or latin-1 representation) into unicode object""" |
|
if withNone and str is None: |
|
return None |
|
if not str: |
|
return u"" |
|
if type(str) is StringType: |
|
try: |
|
return str.decode('utf-8') |
|
except: |
|
return str.decode('latin-1') |
|
else: |
|
return str |
|
|
|
def utf8ify(str, withNone=False): |
|
"""encode unicode object or string into byte string in utf-8 representation""" |
|
if withNone and str is None: |
|
return None |
|
if not str: |
|
return "" |
|
if type(str) is StringType: |
|
return str |
|
else: |
|
return str.encode('utf-8') |
|
|
def getTextFromNode(nodename): |
def getTextFromNode(nodename): |
"""get the cdata content of a node""" |
"""get the cdata content of a node""" |
Line 45 def SimpleSearch(curs,query, args=None,
|
Line 70 def SimpleSearch(curs,query, args=None,
|
#logger.debug("executing: "+query) |
#logger.debug("executing: "+query) |
if ascii: |
if ascii: |
# encode all in UTF-8 |
# encode all in UTF-8 |
query = query.encode("UTF-8") |
query = utf8ify(query) |
if args is not None: |
if args is not None: |
encargs = [] |
encargs = [] |
for a in args: |
for a in args: |
if a is not None and isinstance(a, str): |
encargs.append(utf8ify(a, withNone=True)) |
a = a.encode("UTF-8") |
|
encargs.append(a) |
|
|
|
args = encargs |
args = encargs |
|
|
Line 412 class xml_handler:
|
Line 435 class xml_handler:
|
args = [] |
args = [] |
for fn in self.xml_update_list: |
for fn in self.xml_update_list: |
# do not update id_field |
# do not update id_field |
if self.id_field and fn == self.xml_id: |
if update and fn == self.xml_id: |
continue |
continue |
|
|
f = self.xml_field_map[fn] |
f = self.xml_field_map[fn] |
Line 438 class xml_handler:
|
Line 461 class xml_handler:
|
else: |
else: |
# create new row |
# create new row |
self.logger.debug("insert: %s"%args) |
self.logger.debug("insert: %s"%args) |
sys.exit(1) |
|
SimpleSearch(self.db, self.addQuery, args, ascii=self.ascii_db) |
SimpleSearch(self.db, self.addQuery, args, ascii=self.ascii_db) |
|
|
#self.logger.info(" row:"+"%d (%s)"%(self.rowcnt,id_val)) |
#self.logger.info(" row:"+"%d (%s)"%(self.rowcnt,id_val)) |