本文整理匯總了Python中serializer.Serializer.loads方法的典型用法代碼示例。如果您正苦於以下問題:Python Serializer.loads方法的具體用法?Python Serializer.loads怎麽用?Python Serializer.loads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類serializer.Serializer
的用法示例。
在下文中一共展示了Serializer.loads方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_product
# 需要導入模塊: from serializer import Serializer [as 別名]
# 或者: from serializer.Serializer import loads [as 別名]
def get_product(self, product_id):
"""
Returns the cart details as a Dictionary for the given product_id
"""
if self.user_cart_exists:
product_string = self.redis_connection.hget(
self.user_redis_key, product_id)
if product_string:
return Serializer.loads(product_string)
else:
return {}
else:
raise ErrorMessage("The user cart is Empty")
示例2: get_product_dicts
# 需要導入模塊: from serializer import Serializer [as 別名]
# 或者: from serializer.Serializer import loads [as 別名]
def get_product_dicts(self):
"""
Returns the list of all product details
"""
return [Serializer.loads(product_string) for product_string in self.redis_connection.hvals(self.user_redis_key)]
示例3: get
# 需要導入模塊: from serializer import Serializer [as 別名]
# 或者: from serializer.Serializer import loads [as 別名]
def get(self):
"""
Returns all the products and their details present in the cart as a dictionary
"""
return {key: Serializer.loads(value) for key, value in self.__get_raw_cart().iteritems()}