本文整理汇总了Python中models.Entry.query方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.query方法的具体用法?Python Entry.query怎么用?Python Entry.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import query [as 别名]
def GET(self, key):
entry = ndb.Key(urlsafe=key).get()
q = Entry.query(Entry.published==True).order(-Entry.timestamp)
data = {
'entry': extend_entry(entry, true)
}
return render.entry(**data)
示例2: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import query [as 别名]
def get(self):
# self.response.write('Hello world!')
user = users.get_current_user()
entrys = Entry.query().fetch()
template_values = {
'user': user,
'entrys': entrys,
"logout": users.create_logout_url('/'),
"login": users.create_login_url('/'),
}
path = os.path.join(os.path.dirname(__file__) + '/templates/', 'index.html')
self.response.out.write(template.render(path, template_values))
示例3: GET
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import query [as 别名]
def GET(self, name):
if name.lower() == 'category':
q = Category.query().order(Category.name)
results, cursor, more = q.fetch_page(10)
if cursor: cursor = cursor.urlsafe()
return render.list(categories=results, cursor=cursor, more=more)
elif name.lower() == 'entry':
q = Entry.query().order(-Entry.timestamp)
results,cursor,more = q.fetch_page(10, projection=[
Entry.timestamp,
Entry.title,
Entry.published])
if cursor: cursor = cursor.urlsafe()
return render.list(posts=results, cursor=cursor, more=more)
else:
raise web.seeother('/admin')
示例4: get_feeds
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import query [as 别名]
def get_feeds():
feeds = Feed.query().order(Feed.title)
entries = Entry.query().order(-Entry.published)
return feeds, entries
示例5: extend_entry
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import query [as 别名]
def extend_entry(entries, category=False):
'''Extends each entry object with url attribute
Uses flag to determine if category should be extended too
'''
for e in entries:
d = e.timestamp
e.url = '%s/%s/%s/%s' % (d.year, d.month, d.day, e.alias)
if category:
e.category_name = e.category.get().name
return entries
categories = Category.query().order(Category.name)
e_list = Entry.query(Entry.published==True).order(-Entry.timestamp)
class index:
def GET(self):
#get latest 3 blog posts
q = Entry.query(Entry.published==True).order(-Entry.timestamp)
entries = q.fetch(3)
data = {
'entries' : extend_entry(entries, True),
'categories': categories.fetch(),
'e_list': extend_entry(e_list.fetch(5, projection=[Entry.title, Entry.alias, Entry.timestamp]))
}
return render.index(**data)