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


Python Link.get_by_id方法代码示例

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


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

示例1: delete_link

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
 def delete_link(cls, id):
     link = LinkModel.get_by_id(id)
     if link:
         link.key.delete()
     linkDoc = cls.getDoc(id)
     if linkDoc:
         cls.removeDocById(id)
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:9,代码来源:docs.py

示例2: post

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
    def post(self):
        t_values = {}
        current_link_id = self.request.POST['current_link_id']
        link_title = self.request.POST['link_title']
        link_target = self.request.POST['link_target']
        link_sequence = self.request.POST['link_sequence']
        logging.info("LinkManager post: current_link_id = %s, link_title = %s, link_target = %s, link_sequence = %s" % (current_link_id, link_title, 'link_target', 'link_sequence'))

        if current_link_id:
            # edit existed link
            link = Link.get_by_id(long(current_link_id))
            link.title = link_title
            link.target = link_target
            link.sequence = long(link_sequence)
            link.put()
            t_values['alert_message'] = "link %s has been updated" % (link.title)
        else:
            # create new link
            link = Link(title=link_title, target=link_target, sequence=long(link_sequence))
            link.put()
            t_values['alert_message'] = "link %s has been added" % (link.title)

        # find all links
        links = Link.all().order("-date")
        t_values["links"] = links
        return self.response.out.write(render_template("links.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:28,代码来源:admin.py

示例3: get

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
 def get(self):
     action = self.param('action')
     values = {'action':action}
     if(action == 'edit'):
         key = self.param('id')
         link = Link.get_by_id(int(key))
         values.update({'link':link})
     self.generateBasePage('manage/link.html', values)
     return
开发者ID:sunruijia,项目名称:simblog,代码行数:11,代码来源:blog.py

示例4: post

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
 def post(self):
     try:
         checkList = self.request.get_all('checks')
         for key in checkList:
             keyID = int(key)
             link=Link.get_by_id(keyID)
             link.delete()
     finally:
         self.redirect('/admin/links')        
     return   
开发者ID:sunruijia,项目名称:simblog,代码行数:12,代码来源:blog.py

示例5: search_link

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
def search_link():
  query = request.args.get('query')
  if not query:
    return jsonify(size=0, data=[])

  query_string = to_query_string(query)
  if query_string == '':
    return jsonify(size=0, data=[])

  ids = Link.search(query_string)
  if len(ids):
    links = map(lambda x:L.get_by_id(int(x)), ids)
    links = [l.to_dict() for l in links]
    return jsonify(size = len(links), data=links)
  else:
    return jsonify(size=0, data=[])
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:18,代码来源:api.py

示例6: update_link

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
def update_link(id):
  link = L.get_by_id(id)
  if link == None:
    return jsonify(success=False, message="No link exisit by id: "+str(id))
  title = request.form.get('title')
  body = request.form.get('body')
  unread = request.form.get('unread', type=bool)
  tags = request.form.getlist('tags')
  clicks = int(request.form.get('clicks'))
  if title != link.title or body != link.body or tags != link.tags:
    Link.save_link(title, link.url, body, tags, clicks, unread)
  elif unread != link.unread or clicks != link.clicks:
    link.unread = unread
    link.clicks = clicks
    link.put()

  return jsonify(success=True, size=1, data=link)
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:19,代码来源:api.py

示例7: get

# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import get_by_id [as 别名]
    def get(self, link_id="", operation=""):
        t_values = {}
        logging.info("LinkManager: link_id = %s, operation = %s" % (link_id, operation))

        # find current_link from link_id
        if link_id:
            current_link = Link.get_by_id(long(link_id))
            if current_link:
                logging.info("found link %s from link_id: %s" % (current_link.title, link_id))
                if operation == "delete":
                    current_link.delete()
                    t_values['alert_message'] = "Link %s has been deleted." % (current_link.title)
                    # t_values['redirect_location'] = uri_for("admin.links")
                    # return self.response.out.write(render_template("alert.html", t_values, "", True))
                elif operation == "edit":
                    # pass current_link to template
                    t_values['current_link'] = current_link

        # find all links
        links = Link.all().order("-date")
        t_values["links"] = links
        return self.response.out.write(render_template("links.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:24,代码来源:admin.py


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