本文整理汇总了Python中model.Link.all方法的典型用法代码示例。如果您正苦于以下问题:Python Link.all方法的具体用法?Python Link.all怎么用?Python Link.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Link
的用法示例。
在下文中一共展示了Link.all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_basic_info
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import all [as 别名]
def update_basic_info(
update_categories=False,
update_tags=False,
update_links=False,
update_comments=False,
update_archives=False,
update_pages=False):
from model import Entry,Archive,Comment,Category,Tag,Link
basic_info = ObjCache.get(is_basicinfo=True)
if basic_info is not None:
info = ObjCache.get_cache_value(basic_info.cache_key)
if update_pages:
info['menu_pages'] = Entry.all().filter('entrytype =','page')\
.filter('published =',True)\
.filter('entry_parent =',0)\
.order('menu_order').fetch(limit=1000)
if update_archives:
info['archives'] = Archive.all().order('-year').order('-month').fetch(12)
if update_comments:
info['recent_comments'] = Comment.all().order('-date').fetch(5)
if update_links:
info['blogroll'] = Link.all().filter('linktype =','blogroll').fetch(limit=1000)
if update_tags:
info['alltags'] = Tag.all().order('-tagcount').fetch(limit=100)
if update_categories:
info['categories'] = Category.all().fetch(limit=1000)
logging.debug('basic_info updated')
basic_info.update(info)
示例2: get
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import all [as 别名]
def get(self, page_slug=""):
if page_slug:
t_values = {}
posts = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').filter("slug =", page_slug)
if posts.count() == 1:
logging.warning("find one page with slug=%s" % (page_slug))
posts = posts.fetch(limit=1)
post = posts[0]
t_values['post'] = post
# dump(post)
# find all comments
comments = Comment.all().filter("entry =", post).order("date")
t_values['comments'] = comments
else:
logging.warning("%d entries share the same slug %s" % (posts.count(), page_slug))
links = Link.all().order("date")
t_values['links'] = links
categories = Category.all()
t_values['categories'] = categories
pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
t_values['pages'] = pages
return self.response.out.write(render_template("page.html", t_values, "basic", False))
else:
self.redirect(uri_for("weblog.index"))
示例3: post
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import all [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))
示例4: get
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import all [as 别名]
def get(self):
# find stats for this blog
stats = {}
stats['posts'] = Entry.all().filter("entrytype =", "post").filter("is_external_page =", True).count()
stats['pages'] = Entry.all().filter("entrytype =", "page").filter("is_external_page =", True).count()
stats['comments'] = Comment.all().count()
stats['categories'] = Category.all().count()
stats['links'] = Link.all().count()
t_values = {}
t_values['stats'] = stats
return self.response.out.write(render_template("index.html", t_values, "", True))
示例5: post
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import all [as 别名]
def post(self, post_slug=""):
if post_slug:
t_values = {}
post_id = self.request.POST['post_id']
post = Entry.get_by_id(long(post_id))
if post:
# ok, we find the post, try to add comment to this post
logging.warning("find one post with post_id %s" % (post_id))
t_values['post'] = post
# dump(post)
# check google recaptcha, these two fileds might not exist due to connection to reCAPTCHA
recaptcha_challenge_field = self.request.POST.get('recaptcha_challenge_field', "")
recaptcha_response_field = self.request.POST.get('recaptcha_response_field', "")
remote_ip = self.request.environ['REMOTE_ADDR']
private_key = "6LdwFdISAAAAAOYRK7ls3O-kXPTnYDEstrLM2MRo"
antispam_flag = False
try:
result = submit(recaptcha_challenge_field, recaptcha_response_field, private_key, remote_ip)
logging.info("google recaptcha %s, %s" % (result.is_valid, result.error_code))
if result.is_valid:
antispam_flag = True
except:
e = sys.exc_info()[0]
logging.info(e)
# create comment for this post
if antispam_flag:
logging.info("PostManager - add comment")
comm_author = self.request.POST['author']
comm_email = self.request.POST['email']
comm_weburl = self.request.POST['weburl']
comm_content = self.request.POST['comment']
comment_ip = self.request.environ['REMOTE_ADDR']
comm = Comment(entry=post, author=comm_author, email=comm_email, weburl=comm_weburl, content=comm_content, ip=comment_ip)
comm.put()
t_values['alert_message'] = "Thanks %s for your comment!" % (comm_author)
else:
logging.warning("comment ignored because antispam failed")
t_values['alert_message'] = "Sorry, your comment was ignored because of reCAPTCHA failure!"
# find all comments
comments = Comment.all().filter("entry =", post).order("date")
logging.info("PostHandler, post, find %d comments" % (comments.count()))
if post_id:
# only update commentcount when new comment is added
post.commentcount = comments.count()
post.put()
t_values['comments'] = comments
else:
logging.warning("post_id %s does not exist" % (post_id))
links = Link.all().order("date")
t_values['links'] = links
categories = Category.all()
t_values['categories'] = categories
pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
t_values['pages'] = pages
return self.response.out.write(render_template("post.html", t_values, "basic", False))
else:
self.redirect(uri_for("weblog.index"))
示例6: get
# 需要导入模块: from model import Link [as 别名]
# 或者: from model.Link import all [as 别名]
def get(self):
links = Link.all()
values = {'links':links}
self.generateBasePage('manage/links.html', values)
return