Fix exceptions when referencing invalid fields XXX_index

This commit is contained in:
Charles Haley 2010-10-21 21:09:47 +01:00
parent b4f9c302a5
commit 77284f7528

View File

@ -501,13 +501,15 @@ class Metadata(object):
if key.startswith('#') and key.endswith('_index'): if key.startswith('#') and key.endswith('_index'):
tkey = key[:-6] # strip the _index tkey = key[:-6] # strip the _index
cmeta = self.get_user_metadata(tkey, make_copy=False) cmeta = self.get_user_metadata(tkey, make_copy=False)
if cmeta['datatype'] == 'series': if cmeta and cmeta['datatype'] == 'series':
if self.get(tkey): if self.get(tkey):
res = self.get_extra(tkey) res = self.get_extra(tkey)
return (unicode(cmeta['name']+'_index'), return (unicode(cmeta['name']+'_index'),
self.format_series_index(res), res, cmeta) self.format_series_index(res), res, cmeta)
else: else:
return (unicode(cmeta['name']+'_index'), '', '', cmeta) return (unicode(cmeta['name']+'_index'), '', '', cmeta)
else:
return (key, key, None, None)
if key in self.custom_field_keys(): if key in self.custom_field_keys():
res = self.get(key, None) res = self.get(key, None)