def _get_args(self, args):
pw_args = []
for field_name, op, value in args:
field = self.view.fields[field_name]
if isinstance(field, peewee.ForeignKeyField):
tfield = field.to_field
else:
tfield = field
conv_func = None
# ?????? peewee ????? int/float ???????????
if isinstance(tfield, peewee.BlobField):
conv_func = to_bin
elif isinstance(tfield, peewee.BooleanField):
conv_func = bool_parse
if conv_func:
try:
if op == 'in':
value = list(map(conv_func, value))
else:
value = conv_func(value)
except binascii.Error:
self.err = RETCODE.INVALID_HTTP_PARAMS, 'Invalid query value for blob: Odd-length string'
return
except ValueError as e:
self.err = RETCODE.INVALID_HTTP_PARAMS, ' '.join(map(str, e.args))
pw_args.append(getattr(field, _peewee_method_map[op])(value))
return pw_args
评论列表
文章目录