def fixitems(cursor=None, num_updated=0): query = Item.all() if cursor: query.with_cursor(cursor) to_put = [] for item in query.fetch(limit=100): if (item.disable == None): item.disable = False if (item.ebayid == None): item.ebayid = "" if (item.ebayid == ""): item.disable = True img = item.getImage(0) if img: img = ImageData(image=item.picture, name=item.name, parent=item, idx=0) item.picture = None to_put.append(item) if to_put: db.put(to_put) num_updated += len(to_put) logging.debug('Scan %d entities to Datastore for a total of %d', len(to_put), num_updated) deferred.defer(fixitems, cursor=query.cursor(), num_updated=num_updated) else: logging.debug('Scan items complete with %d updates!', num_updated) return None
def checkurl(request): imgs = ImageData.all() for img in imgs: img.url = "http://" + request.META[ 'HTTP_HOST'] + "/admin/fetchimage/" + img.parent().parent( ).name + "/" + str(img.parent().key().id()) + "/" + str( img.idx) + "/" img.put() return HttpResponse("ok")
def blobimage(request, shop, key, index='0'): registerAdminAction(request, "blobimage", shop + "/" + key) #file = request.FILES['image'].read() #type = request.FILES['image'].content_type #image = request.FILES['image'].content_type_extra file = request.FILES['image'].read() picture = rescale(file, 600, 600) item = Item.get_by_id(int(key), parent=getSupplier(shop)) idx = int(index) if item: img = item.getImage(idx) if img: img.image = picture else: img = ImageData(image=picture, name=item.name, parent=item, idx=idx) img.url = "http://" + request.META[ 'HTTP_HOST'] + "/admin/fetchimage/" + shop + "/" + key + "/" + str( idx) img.small = createsc(picture) img.put() del picture item.galleryurl = img.url item.put() return HttpResponse("ok") else: return HttpResponse("fail")
def addimages(request,supplier): file = request.FILES['files[]'].read() name = request.FILES['files[]'].name.split(".") name.pop() rid = ".".join(name) item = createDefaultItem(rid,supplier) picture = quickrescale(file, 600) idx = 0 img = item.getImage(idx) if img: img.image = picture img.small = createsc(img.image) img.put() else: img = ImageData(image=picture,name=item.name,parent=item,idx=idx) img.url = "http://" + request.META['HTTP_HOST'] + "/admin/fetchimage/" + item.parent().name + "/" + str(item.key().id()) + "/" + str(idx) img.small = createsc(img.image) img.put() del picture item.galleryurl = img.url item.put() return HttpResponse("ok")
def blobimage(request,shop,key,index='0'): registerAdminAction(request,"blobimage",shop+"/"+key) #file = request.FILES['image'].read() #type = request.FILES['image'].content_type #image = request.FILES['image'].content_type_extra file = request.FILES['image'].read() picture = rescale(file,600,600) item = Item.get_by_id(int(key),parent = getSupplier(shop)) idx = int(index) if item: img = item.getImage(idx) if img: img.image = picture else: img = ImageData(image=picture,name=item.name,parent=item,idx=idx) img.url = "http://" + request.META['HTTP_HOST'] + "/admin/fetchimage/" + shop + "/" + key + "/" + str(idx) img.small = createsc(picture) img.put() del picture item.galleryurl = img.url item.put() return HttpResponse("ok") else: return HttpResponse("fail")
def addimages(request, supplier): file = request.FILES['files[]'].read() name = request.FILES['files[]'].name.split(".") name.pop() rid = ".".join(name) item = createDefaultItem(rid, supplier) picture = quickrescale(file, 600) idx = 0 img = item.getImage(idx) if img: img.image = picture img.small = createsc(img.image) img.put() else: img = ImageData(image=picture, name=item.name, parent=item, idx=idx) img.url = "http://" + request.META[ 'HTTP_HOST'] + "/admin/fetchimage/" + item.parent( ).name + "/" + str(item.key().id()) + "/" + str(idx) img.small = createsc(img.image) img.put() del picture item.galleryurl = img.url item.put() return HttpResponse("ok")
def checkurl(request): imgs = ImageData.all() for img in imgs: img.url = "http://" + request.META['HTTP_HOST'] + "/admin/fetchimage/" + img.parent().parent().name + "/" + str(img.parent().key().id()) + "/" + str(img.idx) +"/" img.put() return HttpResponse("ok")