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


Python product.Product类代码示例

本文整理汇总了Python中product.Product的典型用法代码示例。如果您正苦于以下问题:Python Product类的具体用法?Python Product怎么用?Python Product使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: manage_beverages_add

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')))
开发者ID:ulrichknecht,项目名称:baroness,代码行数:32,代码来源:views.py

示例2: __init__

 def __init__(self, path):
     global netCdfReady
     Product.__init__(self, path)
     print " init class netCDF_Product"
     self.netCdfReady=netCDFloaded
     self.type=Product.TYPE_NETCDF
     self.dataset=None
开发者ID:gilav,项目名称:eoSip_converter,代码行数:7,代码来源:netCDF_product.py

示例3: get_product_by_name

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
开发者ID:ulrichknecht,项目名称:baroness,代码行数:8,代码来源:database.py

示例4: get_product_by_id

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
开发者ID:ulrichknecht,项目名称:baroness,代码行数:9,代码来源:database.py

示例5: addNewProduct

def addNewProduct():
    form = AddNewProductForm()
    if request.method == "POST" and form.validate():
        # Add the new product.
        newProduct = Product(form.name.data, float(form.price.data), int(form.stock.data))

        newProduct.category = form.category.data
        newProduct.description = form.description.data

        db.session.add(newProduct)
        db.session.commit()

        # We should, also, add the product specifications.
        # Specifications are sent as a json string. We do this because it
        # is really hard to generate dynamic for fields on the client with wtforms.
        # The solution is to have a single string field generated with wtforms and
        # to simulate the rest of the string fields on the client, when the client
        # will submit the form, the values of that fields will be collected and saved
        # in that master field. We use a javascript object on the client to track
        # the fields an their values, so at the submission the master field will
        # contain the json representation of that object.
        specifications = json.loads(form.specifications.data)

        for spec_name, spec_value in specifications.iteritems():
            db.session.add(ProductSpecifications(newProduct.id, spec_name, spec_value))
        db.session.commit()

        # Now add the images.
        pictures = json.loads(form.pictures.data)

        for pictureLink in pictures:
            db.session.add(ProductPictures(pictureLink, newProduct.id))
        db.session.commit()

        # Now that the product has an id we can add the rest of the components.
        # First, if the product's category is not already in the database we should add it.
        category = Categories.query.filter_by(name=newProduct.category).first()
        if category is None:
            newCategory = Categories(newProduct.category)
            db.session.add(newCategory)
            db.session.commit()
        else:
            # The product category may exist, but is unavailable, because there
            # are no products available left in it. We should make it available.
            if not category.available:
                category.available = True
                db.session.add(category)
                db.session.commit()

        return redirect(url_for('productAddedSuccessfully', name=newProduct.name))

    flashErrors(form.errors, flash)
    return render_template('add_new_product.html',
                           form=form)
开发者ID:cristid9,项目名称:web-store,代码行数:54,代码来源:views.py

示例6: Main

class Main(Controler):
  def __init__(self):
    Controler.__init__(self)

    self.__sql = core.Sql()    

    self._brand = Brand()
    self._product = Product()

  def main(self):
    self._product.menu()
开发者ID:pritam2505,项目名称:pytoner,代码行数:11,代码来源:main.py

示例7: get_products

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
开发者ID:ulrichknecht,项目名称:baroness,代码行数:11,代码来源:database.py

示例8: test_readAndSum

    def test_readAndSum(self):

        sold=SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_TEST.csv")
        
        eA = Product()
        eA.setAddStyle(SalesAddBehavior())
        eA=eA.addStyle.addItem(eA, -4, 5, 10) #calculated manually

        assert sold['602'].totalCost == eA.totalCost
        assert sold['602'].count == eA.count
        assert sold['602'].retail == eA.retail
开发者ID:jasrusable,项目名称:InventoryCalculator,代码行数:12,代码来源:test_inventory.py

示例9: next_turn

 def next_turn(self):
     "Reset the city for the next turn"
     if self.current_progress >= Product.cost [self.current_product]:
         self.current_progress -= Product.cost [self.current_product]
         if Product.isUnit(self.current_product):
             print ("{:s} has produced product id {:s}".format (self.name, self.current_product))
             return Unit (self.x, self.y, self.current_product)
         elif Product.isBuilding(self.current_product):
             self.city_improvements.append (self.current_product)
             self.current_product = Product.NONE
     self.current_progress += self.productivity
     return None
开发者ID:c2huc2hu,项目名称:Isometric-Game,代码行数:12,代码来源:city.py

示例10: test_totalSalesBySKU

    def test_totalSalesBySKU(self):

        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_TEST.csv")

        eA = Product()
        eA.setAddStyle(behavior_accumulate_retail())
        eA = eA.addStyle.addItem(eA, -6, 5, 10)  # calculated manually

        assert sold['602'].totalCost == eA.totalCost
        assert sold['602'].count == eA.count
        assert sold['602'].retail == eA.retail

        assert sold['602'].totalCost == -30
        assert sold['602'].count == -6
        assert sold['602'].retail == -60
开发者ID:CraigNielsen,项目名称:InventoryCalculator,代码行数:16,代码来源:test_sales.py

示例11: get_cost

	def get_cost(self, connection, run_size=1):
		''' Get the total project BOM cost and unit price for a given production run size.
		Returns a pair (unit_price, total_cost).'''
		self.set_prod_counts(connection)
		project_prod_counts = self.prod_counts.copy()
		unit_price = 0
		total_cost = 0
		if 'NULL' in project_prod_counts.keys():
			raise NullProductInProjectException(self.get_cost.__name__, 'Warning: Cost calculation does not account for parts with no product assigned!')
		for x in project_prod_counts.keys():
			project_prod_counts[x] = self.prod_counts[x] * run_size
			
		for x in project_prod_counts.items():
			# Find x[0] (the dict key) in the product DB
			# x is [manufacturer_pn, qty]
			if x[0] == 'NULL':
				pass
			else:
				prod = Product.select_by_pn(x[0], connection)[0]
				listing = prod.best_listing(project_prod_counts[x[0]])
				price_break = listing.get_price_break(x[1])
				unit_price += (price_break[1] * self.prod_counts[x[0]]) + listing.reel_fee
				total_cost += (price_break[1] * project_prod_counts[x[0]]) + listing.reel_fee
				
		return (unit_price, total_cost)
开发者ID:jbaker0428,项目名称:Eagle-BOM-Manager,代码行数:25,代码来源:bom.py

示例12: __init__

  def __init__(self):
    Controler.__init__(self)

    self.__sql = core.Sql()    

    self._brand = Brand()
    self._product = Product()
开发者ID:pritam2505,项目名称:pytoner,代码行数:7,代码来源:main.py

示例13: __add_data_to_dict

    def __add_data_to_dict(self):
        print("Collecting data to dictionary:")

        data = ReturnData()
        for pdf in self.pdf_list:
            notes = Notes()
            try:
                pdf_without_notes, notes = notes.extract_notes(pdf)
            except:
                continue #check impact
            else:
                if notes is None:
                    data.files_skipped += 1
                    print("NOT PREPPED: ", pdf_without_notes[:7])
                else:
                    product = Product.factory(pdf_without_notes, notes)
                    row = product.merge_notes_without_csv()

                    key = notes["stock"]
                    if notes["type"] == "FLAT":
                        data.rows_flat.setdefault(key,[]).append(row)
                    elif notes["type"] == "BOUND":
                        data.rows_bound.setdefault(key, []).append(row)

                    print("ADDED!!: ", pdf[:7])
                    data.files_added_to_csv += 1

        print("All data in dictionary!")
        return data
开发者ID:propbono,项目名称:pdf-csv-merge,代码行数:29,代码来源:data.py

示例14: test_search_sanity

    def test_search_sanity(self):
        our_products = []
        products = self.seach.search(self.product_group, self.keyword)
        our_products_item = self.api.item_search(self.product_group, Keywords=self.keyword)
        for index, item in enumerate(our_products_item):
            if index == self.MAX_RESULTS:
                break

            browse_nodes = self.api.item_lookup(ItemId=item.ASIN, ResponseGroup='OfferListings,\
                                                                                BrowseNodes,\
                                                                                OfferSummary,\
                                                                                Offers,\
                                                                                Images')
            product = Product(item, browse_nodes)
            if (product.get_img_url('SmallImage') == 'null') or \
                    (product.get_img_url('MediumImage') == 'null' and product.get_img_url('LargeImage') == 'null'):
                index -= 1
                continue

            if product.get_rating() == 'null' or \
                            product.get_review() == 'null' or product.get_price() == 'null':
                index -= 1
                continue

            our_products.append(product)

        products_ASIN = [product.ASIN for product in products]
        our_products_ASIN = [product.ASIN for product in our_products]
        self.assertItemsEqual(products_ASIN,our_products_ASIN)
开发者ID:netarachelhershko,项目名称:amazon_aotumation,代码行数:29,代码来源:product_searcher_tests.py

示例15: write

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
开发者ID:gitlabuser,项目名称:CMNT_004_15,代码行数:18,代码来源:xmlrpc_interface.py


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