DynamoDb验证错误400错误请求

时间:2014-07-03 17:51:39

标签: python python-2.7 amazon-web-services

我一直在摸着这个。有没有人知道问题出在哪里:

代码:

x=None
y=None
split = key.split("/")
if ".svg" in loc:
    svgF=open(loc,"r").read()
    svg = etree.fromstring(svgF)
    x = svg.xpath("//@width")[0]
    x=x[:x.__len__()-4]
    y = svg.xpath("//@height")[0]
    y=y[:y.__len__()-4]
elif ".swf" not in loc:
    i=Image.open(loc)
    dim = i.size
    x=dim[0]
    y=dim[1]
data={}
data["x"]=x
data["y"]=y
data["primary color"]="none"
data["secondary color"]= "none"
data["tertiary color"]="none"
data["time"]=str(getTimeAsInt)
data["parent"]=split[1]+split[2]

newI = imageTable.new_item(split[1]+split[2]+split[11],"image", data)
#try:
newI.save()
return(split[1]+split[2]+split[11])
#except:
#    pass
split[1]+split[2]+split[11]

错误:

  

文件“/Users/tai/Documents/workspace/testSelenium/testS/database.py”,第188行,在recursiveInnerFile中       dynamoStorage.saveImage(LOC,密钥)     在saveImage中输入文件“/Users/tai/Documents/workspace/testSelenium/testS/dynamoStorage.py”,第161行       newI.save()     文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/dynamodb/item.py”,第141行,保存       return_values)     在update_item中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/dynamodb/layer2.py”,第592行       object_hook = self.dynamizer.decode)     在update_item中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/dynamodb/layer1.py”,第425行       object_hook = object_hook)     在make_request中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/dynamodb/layer1.py”,第119行       retry_handler = self._retry_handler)     在_mexe中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/connection.py”,第932行       status = retry_handler(response,i,next_sleep)     在_retry_handler中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/dynamodb/layer1.py”,第156行       response.status,response.reason,data)   boto.dynamodb.exceptions.DynamoDBValidationError:DynamoDBValidationError:400错误请求   {u'message':你的一个或多个参数值无效:当没有指定属性值时,只允许DELETE操作',''__ type':u'com.amazon.coral.validate#ValidationException'}

当我像这样更改此行时:

 newI = imageTable.new_item(data["parent"], data)

我没有收到错误,但信息没有正确存储在发电机中。我只获得ID而没有其他列。

另外,对于我的文本设置非常相似,这可以正常工作:

        newI = textTable.new_item(split[1]+split[2]+split[11],item_data["time"], item_data)

文本代码:

#TODO this will not work ID is unique only for the swf, not for the text file, it will need each   text
def createText(loc,theNewKey):
with open(loc, "r") as myfile:
    item_data={}
    item_data["time"] = int(getTimeAsInt())
    theText=""
    inText=False
    count = 0;
    split = theNewKey.split("/")
    for line in myfile:
        if line.__len__() >3:
            #if the line starts with text
            if line[0]=="]" and line[1] !="[":
                if("[" in line):
                    line=re.sub("[\]\[]","",line)
                    inText= False;
                    item_data["display_text"+str(count)]=""
                    item_data["display_text"+str(count)] = item_data["display_text"+str(count)] + " " + line[0:line.__len__()]
                    count+=1
                    #if the line does not end the next line will also contain text
                else:
                    line=re.sub("[\]]","",line)
                    inText=True
                    #for some reason adding this line fixes the concatenation issue
                    item_data["display_text"+str(count)]=""
                    item_data["display_text"+str(count)] = item_data["display_text"+str(count)] + " " + line[0:line.__len__()]
                theText+=" " + line
            elif line is not None and inText is False:
                splitL= line.split(" ");
                if splitL is not None and splitL.__len__()>=2:
                    place = splitL[0]
                    item_data[place+str(count)]=splitL[1]
            elif inText:
                if("[" in line):
                    inText=False
                    re.sub("\]\[","",line)
                    item_data["display_text"+str(count)]+=" "+line
                    count+=1
                else:
                    re.sub("\]\[","",line)
                    item_data["display_text"+str(count)]+=" "+line
                theText+=" " + line
        elif("[" in line):
            if inText:
                inText = False
                count+=1
    item_data["parent"]=split[1]+split[2]
    newI = textTable.new_item(split[1]+split[2]+split[11],item_data["time"], item_data)
    try:
        newI.save()
        return(split[1]+split[2]+split[11])
    except:
        pass

0 个答案:

没有答案