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


Python Item.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
 def post(self):
     user = users.get_current_user()
     
     if user == None:
         self.redirect("/")
         return 
     
     # get category information
     category = self.request.get('category') 
     item = self.request.get('newItem')
     if item != "":
         cs = Category.all()
         cs.filter('user =', user.email()) # get user category
         cs.filter('category =', category) # get category
         c = cs.get()
         if c != None:
             items = Item.all()
             items.filter('item =', item)
             items.ancestor(c.key())
             if items.get() == None:
                 newItem = Item(item = item, win = 0, lose = 0, rate = 0, parent = c.key()) # post a new item
                 newItem.put() # save 
             else:
                 errorMessage = "Item %s already exists!" % item
                 self.redirect("/manageCategory?category=%s&error=%s" % (category, errorMessage))
                 return 
     
     self.redirect("/manageCategory?category=%s" % category)
开发者ID:freedomd,项目名称:Head2Head,代码行数:30,代码来源:item.py

示例2: save_edited_category

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
def save_edited_category():
    cat_name = request.form.get("category")
    key = request.form.get("key")
    existing = Category.all().filter("owner =", users.get_current_user())
    for e in existing:
        if e.title.lower() == cat_name.lower():
            if not str(e.key()) == key:
                error = "You already have a category with that name. Please choose a different name"
                return Response(status=400)
    category = Category.get(key)
    items_from_form = request.form.get("items").split(",")
    old_items_from_db = Item.all().ancestor(category)
    for item in old_items_from_db:
        if not item.title in items_from_form:
            db.delete(item)
        else:
            items_from_form.remove(item.title)

    for new_item in items_from_form:
        if not new_item == "":
            i = Item(parent=category, title=new_item)
            i.put()
    category.title = request.form.get("category")
    category.put()
    return jsonify(new_items=items_from_form)
开发者ID:ssb402,项目名称:Vote-or-Skip-Web-App,代码行数:27,代码来源:views.py

示例3: commit_item_changes

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
 def commit_item_changes(self,item=None):
     creation=not(item)
     if not item: item=Item(parent=self.current_user.key())
     item_name=self.request.get('name')
     item_price=self.request.get('price')
     item_description=rich_text.from_style_runs(self.request.get('description'))
     item_picture=self.request.get('picture_512')
     errors=[]
     if item_name=="": errors.append("The item name must not be blank.")
     if item_description=="": errors.append("The item description must not be blank.")
     try:
         item_price=float(item_price)
     except ValueError:
         errors.append("The price must be a number.")
     if item_price <=0: errors.append("The price must be greater than zero.")
     if len(errors):
         self.render_template('items/form.html',title="Add an Item",item_picture_data=item_picture,item_picture=("data:image/png;base64,%s"%item_picture if item_picture or creation else item.url(named=False,action="picture")),errors=errors,item_expiry=datetime.now()+Item.EXPIRATION_DELTA,item_name=item_name,item_description=item_description,item_price=item_price)
     else:
         item.name=item_name
         item.price=item_price
         item.description=item_description
         if item_picture: item.picture=base64.b64decode(item_picture)
         item.put()
         self.log("item %s"%("created" if creation else "edited"))
         self.flash("'%s' was %s!"%(item_name,"created" if creation else "edited"))
         self.redirect(self.current_user.url())
开发者ID:maz,项目名称:saviors-of-middle-earth,代码行数:28,代码来源:items_controller.py

示例4: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
 def post(self):
     name    = self.request.get('name')
     itemNum = self.request.get('itemNum')
     origin = self.request.get('origin')
     
     item_post = Item(name=name, itemNum=itemNum, origin=origin)
     item_post.put()
     self.redirect('/')    
开发者ID:ForrestSutton,项目名称:foodsafely,代码行数:10,代码来源:views.py

示例5: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
    def post(self):
        try:
            newitem = Item(name = self.request.get('name'),
                price = int(self.request.get('price')),
                quantity = int(self.request.get('quantity')),
                description = self.request.get('description'))
            newitem.put()
        except ValueError:
            return self.error(500)

        self.redirect('/')
开发者ID:dements,项目名称:online-shop,代码行数:13,代码来源:handler.py

示例6: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
    def post(self):  
        user = users.get_current_user()
        
        if user == None:
            self.redirect("/")
            return 

        content = self.request.get('content')
        if content == None or content == "":
            self.redirect("/category")
            return 
        xmldoc = minidom.parseString(content)
        category = xmldoc.getElementsByTagName('CATEGORY')[0]
        categoryName = category.getElementsByTagName('NAME')[0].childNodes[0].nodeValue
        itemList = category.getElementsByTagName('ITEM')
        
        cats = Category.all()
        cats.filter("category =", str(categoryName))
        c = cats.get()
        
        if c == None: # category not exist
            newCat = Category() # create a new category
            newCat.category = categoryName
            newCat.user = user.email()
            newCat.username = user.nickname()
            newCat.put() # save
            for item in itemList:
                itemName = item.getElementsByTagName('NAME')[0].childNodes[0].nodeValue
                newItem = Item(item = itemName, win = 0, lose = 0, rate = 0, parent = newCat.key())
                newItem.put()
            importMessage = 'Import new category "%s" successfully.' % categoryName
            self.redirect("/category?importMessage=%s" % importMessage)
        else: # category exists
            items = Item.all()
            items.ancestor(c.key())
            
            oldItemNameList = []
            for item in items.run():
                oldItemNameList.append(item.item)
            
            newItemNameList = []
            for item in itemList:
                itemName = item.getElementsByTagName('NAME')[0].childNodes[0].nodeValue
                newItemNameList.append(itemName)
                if itemName not in oldItemNameList: # new item not exist
                    newItem = Item(item = itemName, win = 0, lose = 0, rate = 0, parent = c.key())
                    newItem.put()
            
            for item in items: # get old items
                if item.item not in newItemNameList: # old item not in new list, delete
                    item.delete()
                    
            importMessage = 'Import existed category "%s" successfully.' % categoryName
            self.redirect("/category?importMessage=%s" % importMessage)
开发者ID:freedomd,项目名称:Head2Head,代码行数:56,代码来源:xmlHandler.py

示例7: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
  def post(self):
    checklist = Checklist.get(Key(self.request.get('cl_key')))
    if not helpers.checkPermissionAndRespond(self, cl=checklist): return
    
    item = Item(
        title=self.request.get('title'),
        checklist=checklist,
        deleted=False)

    item.put()
    helpers.createResponse(self, 'new_item.html', {'item': item})
开发者ID:yoooyle,项目名称:checklist,代码行数:13,代码来源:create.py

示例8: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
	def post(self):

		user = users.get_current_user()

		if user is None:
			login_url = users.create_login_url('/home')

			template_data = {}
			template_data['login_url'] = login_url

			template = JINJA_ENVIRONMENT.get_template('login.html')
			self.response.write(template.render(template_data))
			return

		residence = Residence.get_residence_by_user(user)

		category = self.request.get('category')
		name = self.request.get('name')
		price = self.request.get('price')


		room_name = self.request.get("room")

		if name.strip() == '' or category.strip() == '':
			if room_name == "miscellaneous":
				self.redirect("home")
			else:
				self.redirect("/room-tour?room=" + urllib.quote(room_name))
			return

		price = float(price)

		inventory = Inventory.get_inventory_by_user(user)
		item = Item(category=category, name=name, price=price, parent=inventory.key)
		item.put()


		residence = Residence.get_residence_by_user(user)
		room = Room.query(ancestor=residence.key).filter(Room.name==room_name).get()
		if room is None:
			room = Room(name=room_name, parent=residence.key)
			room.put()
		
		relation = ItemRoomRelation(item=item.key, room=room.key, parent=inventory.key)
		relation.put()

		if room_name == "miscellaneous":
			self.redirect("/home")
			return



		self.redirect("/room-tour?room=" + urllib.quote(room_name))
开发者ID:alexweaver,项目名称:tdp-hackathon-2016,代码行数:55,代码来源:main.py

示例9: save_new_category

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
def save_new_category():
    category = request.form.get("category")
    existing = Category.all().filter("owner =", users.get_current_user())
    for e in existing:
        if e.title.lower() == category.lower():
            return Response(status=400)
    else:
        items = request.form.get("items").split(",")
        cat = Category(title=category, owner=users.get_current_user())
        cat.put()
        for i in items:
            if not i == "":
                item = Item(parent=cat.key(), title=i)
                item.put()
        return Response(status=200)
开发者ID:ssb402,项目名称:Vote-or-Skip-Web-App,代码行数:17,代码来源:views.py

示例10: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
 def post(self):
     user = users.get_current_user()
     item_name = self.request.get("item_name")
     item_description = self.request.get("item_description")
     item_price = float(self.request.get("item_price"))
     memento_user_query = ndb.gql("SELECT * from MementoUser WHERE user_name = :1", user.nickname())
     curr_memento_user = memento_user_query.get()
     curr_memento_user_key = curr_memento_user.key
     existing_items = Item.query(ancestor=curr_memento_user_key)
     alreadyExists = existing_items.filter(ndb.GenericProperty("item_name") == item_name)
     if (alreadyExists.count(limit=1000) == 0):
         new_item = Item(parent = curr_memento_user_key, item_name = item_name, item_price = item_price, item_description = item_description)
         new_item.put()
         curr_memento_user.user_data.get().inventory.append(new_item.key)
         curr_memento_user.user_data.get().put()
     self.redirect("/VendorHub")
开发者ID:,项目名称:,代码行数:18,代码来源:

示例11: add_item

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
    def add_item(self, currt_user, new_item):
        cat_name = self.request.get("cat_name")
        cat_key = db.Key.from_path('Account', currt_user.nickname(), 'Category', cat_name)

        category = db.get(cat_key)

        items = Item.all()
        items.ancestor(cat_key)
        items.filter("item_name =", new_item)


        if items.count() == 0:
            item = Item(key_name=new_item, parent=category, item_name=new_item)
            item.win = 0
            item.lose = 0
            item.put()
开发者ID:xz565,项目名称:vote-item,代码行数:18,代码来源:manage_handler.py

示例12: item_create

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
def item_create(replace_key=None):
    if replace_key:
        item = replace_key.get()
    else:
        url_safe_name = make_url_safe(request.form.get('name'))
        item = Item(id = url_safe_name)
        
    item.populate(
        name = request.form.get('name'),
        description = request.form.get('description'),
        count = int(request.form.get('count')) if request.form.get('count') else 1,
        prices = [float(request.form.get('price_int')) if request.form.get('price_int') else 0,
                  float(request.form.get('price_ext')) if request.form.get('price_ext') else 0,
                  float(request.form.get('price_com')) if request.form.get('price_com') else 0,
                  float(request.form.get('price_buy')) if request.form.get('price_buy') else 0,
                  ],
        tax_per_day = True if request.form.get('tax_per_day') else False,
        category = request.form.get('category'),
        )
    id = item.put().id()

    file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
开发者ID:Hobbyhobbit,项目名称:Stock,代码行数:27,代码来源:rest.py

示例13: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
	def post(self):
		#Getting Inputs
		itemname=self.request.get("item_name")
		itemtype=self.request.get("item_type")
		itemdescription=self.request.get("item_description")
		itemprice=self.request.get("item_price")
		itemstock=self.request.get("item_stock")
		
		
		#Placing data in model
		item=Item()
		item.name=itemname
		item.type=itemtype
		item.description=itemdescription
		item.price=itemprice
		item.stock=itemstock
		item.owner=users.get_current_user().email()
		
		item.put()
		self.redirect('success')
开发者ID:Joshdsommers,项目名称:TeamZero,代码行数:22,代码来源:item_input.py

示例14: crawl_something

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
def crawl_something(something):
    import json
    o = open('output.json', 'r')
    j = json.loads(o.read())

    for item in j:
        widgets = {}
        if item['widgets']['image_carousel']:
            widgets['image_carousel'] = item['widgets']['image_carousel']
        if item['widgets']['amazon_highlights']:
            widgets['review_highlights'] = review_highlights_(item['widgets']['amazon_highlights'])

        attributes = ""
        if item['']
        item_ = Item(name=item['name'][0], widgets=widgets, )
        item_.put()

def warmup():
    """App Engine warmup handler
    See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
    """
    return ''
开发者ID:yonatano,项目名称:Compadre,代码行数:24,代码来源:views.py

示例15: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import put [as 别名]
  def post(self):
    url = urlfetch.fetch(self.request.get('content'))
    doc = lxml.html.fromstring(url.content)

    for sku in doc.cssselect('span'):
      if sku.get('id') == 'displaySkuCode':
        item_id = sku.text

    registry_item = Item.get_by_id(item_id)
    if registry_item is None:
      registry_item = Item(id=item_id, parent=ndb.Key("Website", self.request.get('website')))

    for tag in doc.cssselect('title'):
      registry_item.title = tag.text.encode('utf-8')

    for img in doc.cssselect('link'):
      if img.get('rel') == 'image_src':
        registry_item.img = img.get('href')

    for price in doc.cssselect('div'):
      if price.get('class') == 'sale-price':
        for savings in price.cssselect('strong'):
          registry_item.sale = savings.text.encode('utf-8')
      if price.get('class') == 'reg-price':
        registry_item.price = price.text.encode('utf-8').replace("Reg.", "")
    
    registry_item.category = self.request.get('category')
    registry_item.for_who = self.request.get('for_who')
    registry_item.put()

    link = URL.get_by_id(item_id)
    if link is None:
      link = URL(id=item_id, parent=ndb.Key("Website", self.request.get('website')))
    link.url = self.request.get('content')
    link.last_scrape = datetime.datetime.now()
    link.put()

    self.redirect('/listings')
开发者ID:tonycorp,项目名称:marinaregistry,代码行数:40,代码来源:scraper.py


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