本文整理汇总了Python中model.Link.put方法的典型用法代码示例。如果您正苦于以下问题:Python Link.put方法的具体用法?Python Link.put怎么用?Python Link.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Link
的用法示例。
在下文中一共展示了Link.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import put [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))
示例2: post
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import put [as 别名]
def post(self):
action = self.param('action')
name,url = (self.request.get(item) for item in ('linkName', 'linkURL'))
if(action == 'edit'):
key = self.param('id')
link = Link.get_by_id(int(key))
link.linkName = name
link.linkURL = url
else:
link = Link(linkName=name,linkURL=url)
link.put()
self.redirect('/admin/links')
return
示例3: save_link
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import put [as 别名]
def save_link(cls, title, url, body="", tags=[], clicks=0, unread=True):
url = norm(url)
id = mmh3.hash(url)
key = ndb.Key(LinkModel, id)
domain = urlparse(url).netloc
if len(domain)>4 and domain.startswith('www.'):
domain = domain[4:]
link = LinkModel( key = key,
title = title,
url = url,
domain = domain,
body = body,
tags = tags,
clicks = clicks,
unread = unread )
link.put()
id = str(link.id)
doc = cls._buildDoc(id, title, body, domain, tags)
cls.add(doc)
return cls(doc, link)
示例4: get
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import put [as 别名]
def get(self):
link = Link(title="linkx1", target="http://baidu.com", sequence=9)
link.put()
link = Link(title="linkx2", target="http://baidu.com", sequence=9)
link.put()
link = Link(title="linkx3", target="http://baidu.com", sequence=9)
link.put()
return self.response.out.write(render_template("index.html", {}, "basic", False))