Mercurial > hg > ChinaGisRestApi
comparison RestDbInterface.py @ 71:6f7f8dee6cd2
working on maps
nicer HTML (with xhtml DTD)
better unicode handling for psycopg
| author | casties |
|---|---|
| date | Tue, 23 Nov 2010 17:23:10 +0100 |
| parents | 9ec7e32e8ad3 |
| children | 3779ad0ba9c7 |
comparison
equal
deleted
inserted
replaced
| 70:9ec7e32e8ad3 | 71:6f7f8dee6cd2 |
|---|---|
| 19 psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) | 19 psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) |
| 20 | 20 |
| 21 from zope.interface import implements | 21 from zope.interface import implements |
| 22 from zope.publisher.interfaces import IPublishTraverse | 22 from zope.publisher.interfaces import IPublishTraverse |
| 23 from ZPublisher.BaseRequest import DefaultPublishTraverse | 23 from ZPublisher.BaseRequest import DefaultPublishTraverse |
| 24 #from zope.publisher.interfaces import NotFound | |
| 25 #from zope.app import zapi | |
| 26 #from zope.component import queryMultiAdapter | |
| 27 import Shared.DC.ZRDB.DA | |
| 28 from Products.ZSQLMethods.SQL import SQLConnectionIDs | |
| 29 | 24 |
| 30 | 25 |
| 31 def unicodify(s,alternate='latin-1'): | 26 def unicodify(s,alternate='latin-1'): |
| 32 """decode str (utf-8 or latin-1 representation) into unicode object""" | 27 """decode str (utf-8 or latin-1 representation) into unicode object""" |
| 33 if not s: | 28 if not s: |
| 195 fields = cur.description | 190 fields = cur.description |
| 196 if hasResult: | 191 if hasResult: |
| 197 # get all data in an array | 192 # get all data in an array |
| 198 data = cur.fetchall() | 193 data = cur.fetchall() |
| 199 cur.close() | 194 cur.close() |
| 200 logging.debug("fields: %s"%repr(fields)) | 195 #logging.debug("fields: %s"%repr(fields)) |
| 201 logging.debug("rows: %s"%repr(data)) | 196 #logging.debug("rows: %s"%repr(data)) |
| 202 return {"fields":fields, "rows":data} | 197 return {"fields":fields, "rows":data} |
| 203 else: | 198 else: |
| 204 cur.close() | 199 cur.close() |
| 205 return None | 200 return None |
| 206 | 201 |
