Mercurial > hg > ltpdarepo
changeset 164:86c23f07c5ae
Optimize check for xml data.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Fri, 04 Nov 2011 12:43:54 +0100 |
parents | b666c4b27e33 |
children | 4481820ee0f5 |
files | src/ltpdarepo/views/browse.py |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ltpdarepo/views/browse.py Fri Nov 04 12:18:10 2011 +0100 +++ b/src/ltpdarepo/views/browse.py Fri Nov 04 12:43:54 2011 +0100 @@ -446,16 +446,18 @@ # check for mat representation curs = g.db.cursor() - curs.execute("""SELECT obj_id FROM `%s`.bobjs WHERE obj_id=%%s""" % database, objid) + curs.execute("""SELECT obj_id + FROM `%s`.bobjs WHERE obj_id=%%s""" % database, objid) row = curs.fetchone() if row is not None: obj['mat'] = True # check for xml representation curs = g.db.cursor() - curs.execute("""SELECT xml, uuid FROM `%s`.objs WHERE id=%%s""" % database, objid) - xml, uuid = curs.fetchone() - if xml and xml.startswith('<?xml'): + curs.execute("""SELECT uuid, xml LIKE '<?xml %' + FROM `%s`.objs WHERE id=%%s""" % database, objid) + uuid, xml = curs.fetchone() + if xml: obj['xml'] = True # add uuid