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


Python Entry.query方法代码示例

本文整理汇总了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)
开发者ID:sw00,项目名称:rigmarolesoup,代码行数:11,代码来源:blog.py

示例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))
开发者ID:liantian-cn,项目名称:StaticGAE,代码行数:14,代码来源:views.py

示例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')
开发者ID:sw00,项目名称:rigmarolesoup,代码行数:22,代码来源:admin.py

示例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
开发者ID:barykaed,项目名称:comic-scraper,代码行数:7,代码来源:main.py

示例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)
开发者ID:sw00,项目名称:rigmarolesoup,代码行数:31,代码来源:blog.py


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