當前位置: 首頁>>代碼示例>>Python>>正文


Python Category.get_by_key_name方法代碼示例

本文整理匯總了Python中models.Category.get_by_key_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Category.get_by_key_name方法的具體用法?Python Category.get_by_key_name怎麽用?Python Category.get_by_key_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Category的用法示例。


在下文中一共展示了Category.get_by_key_name方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import get_by_key_name [as 別名]
 def post(self, subdomain):
     namespace_manager.set_namespace(subdomain)
     visible = False
     if self.request.get('visible') == 'yes':
         visible = True
     name = self.request.get('name')
     categories = self.request.get('category').split(',')
     logging.info(categories)
     cat_refs = []
     for category in categories:
         logging.info(category)
         if Category.get_by_key_name(category):
             cat_refs.append(Category.get_by_key_name(category).key())
     logging.info(cat_refs)
     entity = Product(key_name=name,
                       name=name,
                       shop_id=Shop.get_by_key_name(subdomain),
                       stock=int(self.request.get('qty')),
                       description=self.request.get('description'),
                       price=float(self.request.get('price')),
                       tags=self.request.get('tags').split(','),
                       video=self.request.get('video'),
                       visible=visible,
                       categories=cat_refs
                           )
     entity.put()
     self.redirect(webapp2.uri_for('addproducts'))
開發者ID:itaogit,項目名稱:shopapp,代碼行數:29,代碼來源:admin.py

示例2: delete_category

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import get_by_key_name [as 別名]
def delete_category(category_name):
    """Delete an post object"""
    category = Category.get_by_key_name(category_name)
    try:
        category.delete()
        flash(u"Example %s successfully deleted." % category.name, "success")
        return redirect(url_for("list_categories"))
    except CapabilityDisabledError:
        flash(u"App Engine Datastore is currently in read-only mode.", "info")
        return redirect(url_for("list_categories"))
開發者ID:cenzino,項目名稱:vp-gae,代碼行數:12,代碼來源:views.py

示例3: edit_category

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import get_by_key_name [as 別名]
def edit_category(category_name):
    category = Category.get_by_key_name(category_name)
    form = CategoryForm(obj=category)

    if form.validate_on_submit():
        form.populate_obj(category)
        try:
            category.put()
            flash(u"Example %s successfully saved." % category.name, "success")
            return redirect(url_for("list_categories"))
        except CapabilityDisabledError:
            flash(u"App Engine Datastore is currently in read-only mode.", "info")
            return redirect(url_for("list_categories"))
    return render_template("edit_category.html", form=form, category_name=category.id)
開發者ID:cenzino,項目名稱:vp-gae,代碼行數:16,代碼來源:views.py


注:本文中的models.Category.get_by_key_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。