本文整理汇总了Python中models.Page.page_title方法的典型用法代码示例。如果您正苦于以下问题:Python Page.page_title方法的具体用法?Python Page.page_title怎么用?Python Page.page_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Page
的用法示例。
在下文中一共展示了Page.page_title方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_pages
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import page_title [as 别名]
def store_pages(self, route_handlers):
"""Stores information on each handler in the datastore and returns a list
of routes for the Router.
:param routes_handler:
A list of FrameworkHandler subclasses which identify routes and
their meta data.
:returns:
A list of webapp2.Route instance.
"""
memcache.delete('navigation_pages')
routes = []
new_key_set = set()
for route_handler in route_handlers:
# Checks if datastore entry exits and uses if it is.
query = Page.query(Page.url == route_handler.url)
datastore_list = query.fetch(1)
if datastore_list:
datastore_entity = datastore_list[0]
else:
datastore_entity = Page()
datastore_entity.url = route_handler.url
datastore_entity.page_title = route_handler.page_title
datastore_entity.appear_in_navigation = route_handler.appear_in_navigation
#TODO: Not write to the datastore if there are no changes to be made
datastore_entity.put()
new_key_set.add(datastore_entity.key)
# Creates a route for each handler and adds it to the routes list
routes.append(webapp2.Route(route_handler.url, route_handler))
# The following removes old pages from the datastore
old_key_set = set(Page.query().fetch(keys_only=True))
ndb.delete_multi(list(old_key_set - new_key_set))
return routes