本文整理汇总了Python中product.Product.name方法的典型用法代码示例。如果您正苦于以下问题:Python Product.name方法的具体用法?Python Product.name怎么用?Python Product.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product.Product
的用法示例。
在下文中一共展示了Product.name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manage_beverages_add
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import name [as 别名]
def manage_beverages_add():
if request.method == 'POST':
p = Product()
error = None
logging.info(request)
p.name = request.form['name']
#if request.form['price'].isnumeric():
p.price = float(request.form['price'])
#else:
# error = "Preis muss eine Nummer sein."
if 'isshown' in request.form:
p.isshown = True
else:
p.isshown = False
pic = request.files['file']
logging.info(pic.filename)
if pic:
extension = pic.filename.rsplit('.', 1)[1].lower()
logging.info(extension)
if extension == "png" or extension == "jpg":
pic.seek(0) # Move cursor back to beginning so we can write to disk
fpath = os.path.join("./app/static/", "product_%s.png" % p.name)
pic.save(fpath)
if error is None:
add_product(p)
return render_template('manage_beverages_add.html', success="Konsumat hinzugefuegt.", user=get_user_by_name(session.get('name')))
return render_template('manage_beverages_add.html', error=error, user=get_user_by_name(session.get('name')))
return render_template('manage_beverages_add.html', user=get_user_by_name(session.get('name')))
示例2: manage_beverages_edit
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import name [as 别名]
def manage_beverages_edit(name=None):
if request.method == 'GET':
error = None
p = get_product_by_name(name)
if p is None:
error = "Product existiert nicht"
return render_template('manage_beverages_edit.html', product_to_edit=p, error=error, user=get_user_by_name(session.get('name')))
if request.method == 'POST':
p = Product()
#print request.form
p.id = request.form['id']
p.name = request.form['name']
p.price = float(request.form['price'])
if 'isshown' in request.form:
p.isshown = True
else:
p.isshown = False
pic = request.files['file']
if pic:
extension = pic.filename.rsplit('.', 1)[1].lower()
if extension == "png" or extension == "jpg":
pic.seek(0) # Move cursor back to beginning so we can write to disk
fpath = os.path.join("./app/static/", "product_%s.png" % p.name)
pic.save(fpath)
update_product(p)
# update_user(u)
return redirect('/manage_beverages')
示例3: get_product_by_name
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import name [as 别名]
def get_product_by_name(name):
row = query_db("SELECT * FROM PRODUCTS WHERE NAME = ?", [str(name)], one=True)
p = Product()
p.id = row[0]
p.name = row[1]
p.price = row[2]
p.isshown = row[3]
return p
示例4: get_product_by_id
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import name [as 别名]
def get_product_by_id(id):
row = query_db("SELECT * FROM PRODUCTS WHERE ID = ?", [str(id)], one=True)
# print row
p = Product()
p.id = row[0]
p.name = row[1]
p.price = row[2]
p.isshown = row[3]
return p
示例5: get_products
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import name [as 别名]
def get_products():
rows = query_db("SELECT * FROM PRODUCTS")
products = []
for row in rows:
p = Product()
p.id = row[0]
p.name = row[1]
p.price = row[2]
p.isshown = row[3]
products.append(p)
return products