本文整理汇总了Python中product.Product.get方法的典型用法代码示例。如果您正苦于以下问题:Python Product.get方法的具体用法?Python Product.get怎么用?Python Product.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product.Product
的用法示例。
在下文中一共展示了Product.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get [as 别名]
def write(user_id, password, model, odoo_id, vals):
_check_user(user_id, password)
if model not in ["customer", "product"]:
raise Fault("unknown_model", "Reference model does not exist!")
if model == "customer":
try:
customer = Customer.get(Customer.odoo_id == odoo_id)
except Customer.DoesNotExist:
raise Fault("unknown_registry", "Customer not found!")
q = Customer.update(**vals).where(Customer.odoo_id == odoo_id)
else:
try:
product = Product.get(Product.odoo_id == odoo_id)
except Product.DoesNotExist:
raise Fault("unknown_registry", "Product not found!")
q = Product.update(**vals).where(Product.odoo_id == odoo_id)
q.execute()
return True
示例2: create
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get [as 别名]
def create(user_id, password, model, vals):
_check_user(user_id, password)
odoo_id = vals["odoo_id"]
if model not in ["customer", "product"]:
raise Fault("unknown_model", "Reference model does not exist!")
if model == "customer":
try:
customer = Customer.get(Customer.odoo_id == odoo_id)
except Customer.DoesNotExist:
q = Customer.insert(**vals)
else:
q = Customer.update(**vals).where(Customer.odoo_id == odoo_id)
else:
try:
product = Product.get(Product.odoo_id == odoo_id)
except Product.DoesNotExist:
q = Product.insert(**vals)
else:
q = Product.update(**vals).where(Product.odoo_id == odoo_id)
q.execute()
return True
示例3: unlink
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get [as 别名]
def unlink(user_id, password, model, odoo_id):
_check_user(user_id, password)
if model not in ["customer", "product"]:
raise Fault("unknown_model", "Reference model does not exist!")
q = False
if model == "customer":
try:
customer = Customer.get(Customer.odoo_id == odoo_id)
except Customer.DoesNotExist:
pass
else:
q = Customer.delete().where(Customer.odoo_id == odoo_id)
else:
try:
product = Product.get(Product.odoo_id == odoo_id)
except Product.DoesNotExist:
pass
else:
q = Product.delete().where(Product.odoo_id == odoo_id)
if q:
q.execute()
return True
示例4: fetch
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get [as 别名]
def fetch(self, handle, id):
from product import Product
from artist import Artist
jtrack = qobuz.api.get_track(id)
if not jtrack:
print "Cannot fetch data"
return False
print pprint.pformat(jtrack)
where = {}
if 'album' in jtrack:
P = Product()
album = P.get(handle, jtrack['album']['id'])
if not album:
P.insert_json(handle, jtrack['album'])
for field in self.fields_name.keys():
f = self.fields_name[field]
if not f['jsonmap']: continue
value = self.get_property(jtrack, f['jsonmap'])
if not value: continue
where[field] = value
if 'interpreter' in jtrack:
I = Artist()
interpreter = I.get(handle, jtrack['interpreter'])
if not interpreter:
I.insert(handle, jtrack['interpreter'])
if 'performer' in jtrack:
I = Artist()
interpreter = I.get(handle, jtrack['performer'])
if not interpreter:
I.insert(handle, jtrack['performer'])
artist = None
artist_type = ('artist', 'interpreter', 'composer', 'performer')
for a in artist_type:
if a in jtrack and jtrack[a]['name'] and jtrack[a]['name'] != 'None':
artist = jtrack[a]
break
self.insert(handle, where)
return False
示例5: insert_json
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get [as 别名]
def insert_json(self, handle, json):
print "JSON: " + pprint.pformat(json)
from product import Product
from artist import Artist
where = {}
subtype = ['album', 'interpreter', 'composer', 'performer']
for type in subtype:
if type in json:
db = None
if type == 'album': db = Product()
elif type in ['interpreter', 'composer', 'performer']:
db = Artist()
if not 'id' in json[type] or not json[type]['id']: continue
if not db.get(handle, int(json[type]['id'])):
db.insert_json(handle, json[type])
for field in self.fields_name.keys():
f = self.fields_name[field]
if not f['jsonmap']: continue
value = self.get_property(json, f['jsonmap'])
if not value: continue
where[field] = value
print "Where %s" % (pprint.pformat(where))
return self.insert(handle, where)