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


Python Category.put方法代码示例

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


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

示例1: create_category

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import put [as 别名]
 def create_category(category_name):
     """ Create a category in datastore """
     query = Category.all()
     query.filter("description =", category_name)
     ret = query.get()
     if ret is None:
         ret = Category()
         ret.description = category_name
         ret.put()
     return ret
开发者ID:szilardhuber,项目名称:shopper,代码行数:12,代码来源:adminhandler.py

示例2: post

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import put [as 别名]
 def post(self):
   name = urllib.quote(self.request.get('name').encode('utf8'))
   category = Category.all().filter('name',name).get()
   if category is not None:
     self.response.out.write('category: %s has already existed' % (name))
   else:
     category = Category()
     category.name = name
     category.put()
     categories = Category.all()
     template_values = {
       'categories': categories,
     }
     self.generate('../templates/admin.html', template_values)
开发者ID:BlowBlood,项目名称:blowblood,代码行数:16,代码来源:admin.py

示例3: post

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import put [as 别名]
    def post(self):
        result = {'message': '', 'status': 'success', 'content': ''}

        logging.info(self.request.POST)
        current_cate_id = self.request.POST.get("current_cate_id")
        cate_name = self.request.POST.get("cate_name")
        cate_slug = self.request.POST.get("cate_slug")
        operation = self.request.POST.get("operation")
        logging.info("CategoryManager post: current_cate_id = %s, cate_name = %s, cate_slug = %s, operation = %s" % (current_cate_id, cate_name, cate_slug, operation))

        if current_cate_id:
            # edit existed link
            cate = Category.get_by_id(long(current_cate_id))
            if cate:
                # current_cate_id exists
                if operation == "delete":
                    if cate.entrycount == 0:
                        cate.delete()
                        result['message'] = "category %s has been deleted" % (current_cate_id)
                    else:
                        result['status'] = 'failed'
                        result['message'] = "category %s can't be delete since it's still being used!" % (current_cate_id)
                else:
                    cate.name = cate_name
                    cate.slug = cate_slug
                    cate.put()
                    result['message'] = "category %s has been updated" % (cate.name)
            else:
                logging.info("category id=%s does not exist!" % (current_cate_id))
        else:
            # create new cate
            cate = Category(name=cate_name, slug=cate_slug)
            cate.put()
            result['message'] = "category %s has been created" % (cate.name)
            result['content'] = render_template("category_block.html", {'cate': cate}, "", True)
            logging.info("content = %s" % (result['content']))

        # return json result
        self.response.content_type = 'application/json'
        return self.response.out.write(json.encode(result))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:42,代码来源:admin.py


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