def price_uplader(request): upload_files = get_uploads(request, 'file') if not len(upload_files): return redirect(url_for('admin/add_price')) blob_info = upload_files[0] bl = BlobInfo.get(blob_info.key()) filename = os.path.basename(bl.filename.replace('\\','/')) price = Price(name=filename, file_key=str(blob_info.key()), length=blob_info.size) price.put() return redirect(url_for('admin/prices'))
def unpack(request, key, name): price = memcache.get('price_%s' % key) if not price: try: price = Price.get(key) except BadKeyError: return redirect(url_for('price/index')) if price: memcache.add('price_%s' % key, price, 1200) if price: blob = BlobInfo.get(price.file_key) headers = Headers() headers['Content-Type'] = blob.content_type.encode('utf-8') headers['Last-Modified'] = price.modif_time.strftime(HTTP_DATE_FMT) return Response(blob.open().read(), headers=headers) return Response(status=304)
def price_delete(request, key): price = Price.get(key) if price: price.delete() return redirect('/admin/prices')
def prices(request): return render_to_response('admin/prices.html', {'prices': Price.all()})
def index(request): prices = Price.all() return render_to_response('price/index.html', {'prices': prices})