From 943aaa2bcbc60d146fc4d78be872c3e4240570cd Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Fri, 1 May 2015 20:40:23 +0200 Subject: [PATCH] exclude some fields from conversion --- backend.py | 10 +++++++++- eventman_server.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend.py b/backend.py index f6b4351..ccc63c6 100644 --- a/backend.py +++ b/backend.py @@ -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] diff --git a/eventman_server.py b/eventman_server.py index fa9f335..ea1ecce 100755 --- a/eventman_server.py +++ b/eventman_server.py @@ -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,