def _deserialize(self, value, attr, data): try: return bson.ObjectId(value) except: raise ma.ValidationError('invalid ObjectId `%s`' % value)