コード例 #1
0
def create_product(product_id=None,product_name=None):
	if product_id is None or len(product_id) <= 3:
		product_id = random_key(10)

	product = Product(product_id=product_id,product_name=product_name)
	product.put()
	import logging
	logging.error(product.properties())
	return product
コード例 #2
0
def create_product(product_id=None,product_name=None):
	if product_id is None or len(product_id) <= 3:
		product_id = random_key(10)

	existing_products = Product.query(Product.product_id == product_id).fetch(1)

	if len(existing_products) != 0:
		import logging
		logging.error('Product with ID "' + product_id + '" already exists.' )
		return make_error(400,'A product with ID ' + product_id + ' already exists, overwriting is forbidden.')

	product = Product(product_id=product_id)
	if product_name is not None:
		product.product_name = product_name
	product.put()
	return product.product_id