Hi all,
I'm getting this error from Cheetah when using the C namemapper, where the
Python version works fine:
<class 'NameMapper.NotFound'>: cannot find 'shipment_id' while searching for
'shipment.shipment_id'
args = ("cannot find 'shipment_id' while searching for
'shipment.shipment_id'",)
message = "cannot find 'shipment_id' while searching for
'shipment.shipment_id'"
The "shipment" object is a DictRow, which is a psycopg2 thing that inherits
from list to allow both list-style and dict-style access to the contents of
a row returned from a query (below). I'm trying to access the shipment_id
field in the returned row, and the call works fine with the Python
namemapper. What is the C namemapper doing differently that breaks this
behaviour? Can I fix it? I'm using the latest CVS version.
thanks!
class DictRow(list):
"""A row object that allow by-colun-name access to data."""
def __init__(self, cursor):
self._index = cursor.index
self[:] = [None] * len(cursor.description)
def __getitem__(self, x):
if type(x) != int:
x = self._index[x]
return list.__getitem__(self, x)
def items(self):
res = []
for n, v in self._index.items():
res.append((n, list.__getitem__(self, v)))
return res
def keys(self):
return self._index.keys()
def values(self):
return tuple(self[:])
def has_key(self, x):
return self._index.has_key(x)
def get(self, x, default=None):
try:
return self[x]
except:
return default
def iteritems(self):
for n, v in self._index.items():
yield n, list.__getitem__(self, v)
|