当前位置: 首页>>代码示例>>Python>>正文


Python Product.category方法代码示例

本文整理汇总了Python中models.Product.category方法的典型用法代码示例。如果您正苦于以下问题:Python Product.category方法的具体用法?Python Product.category怎么用?Python Product.category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Product的用法示例。


在下文中一共展示了Product.category方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SaveChanges

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import category [as 别名]
 def SaveChanges(self):
     for row in self.change_rows.keys():
         row = int(row)
         product = Product()
         product.category = models.ALL_PRODUCT_TYPE[self.m_grid5.GetCellValue(row, 0)]
         product.type = self.m_grid5.GetCellValue(row, 1)
         product.length = self.m_grid5.GetCellValue(row, 2)
         product.width = self.m_grid5.GetCellValue(row, 3)
         product.height = self.m_grid5.GetCellValue(row, 4)
         product.per_weight = self.m_grid5.GetCellValue(row, 5)
         product.price = self.m_grid5.GetCellValue(row, 6)
         db.UpdateProduct(product)
     for new_row in self.new_products.keys():
         product = Product()
         product.category = models.ALL_PRODUCT_TYPE[self.m_grid5.GetCellValue(row, 0)]
         product.type = self.m_grid5.GetCellValue(new_row, 1)
         product.length = self.m_grid5.GetCellValue(new_row, 2)
         product.width = self.m_grid5.GetCellValue(new_row, 3)
         product.height = self.m_grid5.GetCellValue(new_row, 4)
         product.per_weight = self.m_grid5.GetCellValue(new_row, 5)
         product.price = self.m_grid5.GetCellValue(new_row, 6)
         db.InsertProduct(product)
开发者ID:dizengrong,项目名称:dzr_code,代码行数:24,代码来源:DlgManagerProduct.py

示例2: GetAllProducts

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import category [as 别名]
def GetAllProducts():
    """获取所有的产品数据"""
    db_cur = db_conn.cursor()
    db_cur.execute(SQL_ALL_PRODUCT)
    all_products = {}
    for category in models.ALL_PRODUCT_TYPE.values():
        all_products[category] = {}
    for row in db_cur:
        rec = Product()
        rec.category = str(row[0])
        rec.type = row[1]
        rec.length = str(row[2])
        rec.width = str(row[3])
        rec.height = str(row[4])
        rec.per_weight = str(row[5])
        rec.price = str(row[6])
        all_products[rec.category][rec.type] = rec
    return all_products
开发者ID:dizengrong,项目名称:dzr_code,代码行数:20,代码来源:db.py

示例3: fetch_category

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import category [as 别名]
def fetch_category(search_index, amazon_node_id):
    api = caching.ResponseCachingAPI(
        settings.AMAZON_AWS_KEY,
        settings.AMAZON_SECRET_KEY,
        settings.AMAZON_API_LOCALE,
        settings.AMAZON_ASSOCIATE_TAG,
        cachedir='cache',
        cachetime=86400)

    try:
        for root in api.item_search(search_index, BrowseNode=str(amazon_node_id),
            ResponseGroup=settings.AMAZON_RESPONSE_GROUP):

            for item in root.Items.Item:
                product = Product()
                product.category = Category.objects.get(amazon_node_id=amazon_node_id)
                product.asin = item.ASIN
                product.title = unicode(item.ItemAttributes.Title)
                product.detailpageurl = unicode(item.DetailPageURL)
                product.manufacturer = unicode(getattr(item.ItemAttributes, 'Manufacturer', None))
                product.publisher = unicode(getattr(item.ItemAttributes, 'Publisher', None))
                product.brand = unicode(getattr(item.ItemAttributes, 'Brand', None))
                product.popularity = getattr(item, 'SalesRank', 1000)
                if hasattr(item, 'MediumImage'):
                    product.medium_image = getattr(item.MediumImage, 'URL', None)
                if hasattr(item, 'LargeImage'):
                    product.large_image = getattr(item.LargeImage, 'URL', None)
                if hasattr(item, 'EditorialReviews'):
                    product.description = unicode(getattr(item.EditorialReviews.EditorialReview, 'Content', None))
                if hasattr(item.Offers, 'Offer'):
                    product.price = item.Offers.Offer.OfferListing.Price.FormattedPrice.pyval
                elif hasattr(item.ItemAttributes, 'ListPrice'):
                    product.price = item.ItemAttributes.ListPrice.FormattedPrice.pyval
                elif hasattr(item.OfferSummary, 'LowestUsedPrice'):
                    product.price =  u'used from %s' % item.OfferSummary.LowestUsedPrice.FormattedPrice.pyval
                else:
                    product.price = None
                product.save()

    except AWSError, e:
        if e.code == 'AWS.ParameterOutOfRange':
            pass # reached the api limit of 10 pages
        else:
            raise ValidationError(message=e.msg)
开发者ID:hnejadi,项目名称:AmazonDjangoShop,代码行数:46,代码来源:amazon.py


注:本文中的models.Product.category方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。