I'm working with a nested json I'm converted into NDB models that are structured. However, the last line of my attempt to contructed the model randomly converts the actual value. I might just be doing something wrong, but I asked on stackoverflow and haven't seen a response. I'm calling a bug at this point due to my testing.
settings = json.loads(request.settings)
keywords = settings['productKeywords']
print type(settings) *shows at dict*
print keywords
print int(settings['sensorConfig'][1]['upperRange']), type(int(settings['sensorConfig'][1]['upperRange'])) *shows as 400 and Int*
convert = settings['sensorConfig'][1]['upperRange']
print convert, type(convert) *Shows as 400 type unicode*
converted = int(convert)
print converted, type(converted) *Shows as 400 type Int*
test = DirectionModel(namespace='cookingDirections',
deviceId=request.deviceId,
deviceName=request.deviceName,
settings=Setting(action=settings['action'], name=settings['name'],
title=settings['title'], productType=settings['productType'],
productBrand=settings['productBrand'],
productKeywords=settings['productKeywords'], level=settings['level'],
mode=settings['mode'],
keywords=keywords.split(','),
algorithm=Algorithm(name=settings['algorithm']['name'],
version=settings['algorithm']['version'],
setpoint=int(settings['algorithm']['setpoint']),
setpointUnits=settings['algorithm']['setpointUnits']),
htpGen=settings['htpGen'],
firmwareVersion=settings['firmwareVersion'],
sensorConfig=[
SensorConfig(
type=settings['sensorConfig'][0]['type'],
label=settings['sensorConfig'][0]['label'],
description=settings['sensorConfig'][0]['description'],
lowerRange=int(settings['sensorConfig'][0]['lowerRange']),
upperRange=int(settings['sensorConfig'][0]['upperRange'])),
SensorConfig(
type=settings['sensorConfig'][1]['type'],
label=settings['sensorConfig'][1]['label'],
description=settings['sensorConfig'][1]['description'],
lowerRange=int(settings['sensorConfig'][1]['lowerRange']),
upperRange=converted, *ERROR HERE*
)]))
So, last line where upperRange=converted No matter how i pass in the value. App engine throws back an error BadValue got u'5' expect Int. Even tho above shows the value is actually 400 and is INT.
IF I just pass in settings['sensorConfig'][1]['upperRange'] with out conversion. I get an error that I expect which is Type Error Unicode "400". So basically if I'm not converting the value type...it see it correctly. If I change the IntergerProperty to StringProperty I see u'5' again. If I hard code a value instead of passing in a variable I still see it try passing in u'5'. If I'm doing something wrong I'm at a lost on what.
I'm working with a nested json I'm converted into NDB models that are structured. However, the last line of my attempt to contructed the model randomly converts the actual value. I might just be doing something wrong, but I asked on stackoverflow and haven't seen a response. I'm calling a bug at this point due to my testing.
data being passed in..
Models:
So, last line where upperRange=converted No matter how i pass in the value. App engine throws back an error BadValue got u'5' expect Int. Even tho above shows the value is actually 400 and is INT.
IF I just pass in settings['sensorConfig'][1]['upperRange'] with out conversion. I get an error that I expect which is Type Error Unicode "400". So basically if I'm not converting the value type...it see it correctly. If I change the IntergerProperty to StringProperty I see u'5' again. If I hard code a value instead of passing in a variable I still see it try passing in u'5'. If I'm doing something wrong I'm at a lost on what.