exclude some fields from conversion

This commit is contained in:
Davide Alberani 2015-05-01 20:40:23 +02:00
parent 90b1a33a3d
commit 943aaa2bcb
2 changed files with 10 additions and 2 deletions

View file

@ -36,6 +36,11 @@ class EventManDB(object):
'increment': '$inc'
}
_force_conversion = {
'seq_hex': str,
'persons.seq_hex': str
}
def __init__(self, url=None, dbName='eventman'):
"""Initialize the instance, connecting to the database.
@ -100,7 +105,10 @@ class EventManDB(object):
if isinstance(seq, dict):
d = {}
for key, item in seq.iteritems():
d[key] = self.convert(item)
if key in self._force_conversion:
d[key] = self._force_conversion[key](item)
else:
d[key] = self.convert(item)
return d
if isinstance(seq, (list, tuple)):
return [self.convert(x) for x in seq]

View file

@ -383,7 +383,7 @@ class EventsHandler(CollectionHandler):
doc.get('persons') or [])
env = self._dict2env(new_person_data)
if person_id is None:
person_id = new_person_data.get('person_id')
person_id = str(new_person_data.get('person_id'))
env.update({'PERSON_ID': person_id, 'EVENT_ID': id_, 'EVENT_TITLE': doc.get('title', '')})
stdin_data = {'old': old_person_data,
'new': new_person_data,