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


Python Page.query方法代码示例

本文整理汇总了Python中models.Page.query方法的典型用法代码示例。如果您正苦于以下问题:Python Page.query方法的具体用法?Python Page.query怎么用?Python Page.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Page的用法示例。


在下文中一共展示了Page.query方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
 def get(self):
     template = JINJA_ENVIRONMENT.get_template('blog.html')
     if self.request.get('id'):
         pages = Page.query(Page.allowed == 0,
                            Page.slug == self.request.get('id')).fetch(1)
     else:
         pages = Page.query(Page.allowed == 0).order(-Page.when).fetch(10)
         
     self.response.write(
         template.render({'pages':pages})
     )
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:13,代码来源:main.py

示例2: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
    def post(self,slug):
        page = Page.query(Page.slug == slug).get()
        if page:
            page.slug = slug
            page.title = self.request.get('title')
            page.text = self.request.get('text')
            page.prev = self.request.get('prev')
            page.next = self.request.get('next')
            page.doc  = self.request.get('doc')
            page.allowed = int(self.request.get('level'))
            page.put()

            self.redirect('/content/{}'.format(slug))
        
        else:
            page = Page(title = self.request.get('title'),
                        slug = slug,
                        author = users.get_current_user(),
                        text = self.request.get('text'),
                        prev = self.request.get('prev'),
                        next = self.request.get('next'),
                        doc = self.request.get('doc'),
                        allowed = int(self.request.get('level'))
                    )
            page.put()
        
            self.redirect('/content/{}'.format(slug))
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:29,代码来源:main.py

示例3: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
 def get(self, story_id, page_id):
   story, page = self.story_page(story_id, page_id, is_author=True)
   pages = list(Page.query(ancestor=story.key))
   self.render_html('edit.html',
                    story=story,
                    page=page,
                    pages=pages)
开发者ID:seanpont,项目名称:chooseyourownadventure,代码行数:9,代码来源:views.py

示例4: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
	def get(self, locale_id):
		page = Page.query(Page.locale==ndb.Key(Locale, locale_id), Page.menu==ndb.Key(Menu, "the-manor")).fetch()

		if len(page) == 0:
			self.abort(404)

		self.redirect('/{0}/{1}'.format(locale_id, page[0].key.id()))
开发者ID:daseeds,项目名称:pennsylvania,代码行数:9,代码来源:pennsylvania.py

示例5: get_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
	def get_pages(self, locale_id):
		pages = memcache.get("pages {0}".format(locale_id))
		if pages is None:
			pages = Page.query(Page.locale==ndb.Key(Locale, locale_id)).fetch()
			if not pages:
				return None
			memcache.set(key="pages {0}".format(locale_id), value=pages)
		return pages	
开发者ID:daseeds,项目名称:pennsylvania,代码行数:10,代码来源:pennsylvania.py

示例6: fetch_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
  def fetch_pages(self):
    queue = taskqueue.Queue('facebook')
    keys = Page.query().fetch(keys_only=True)

    for key in keys:
      task = taskqueue.Task(
        url='/worker/fetch_page',
        params={
          'key': key.urlsafe(),
        }
      )
      queue.add(task)
开发者ID:studyindenmark,项目名称:clerkster,代码行数:14,代码来源:cron.py

示例7: get_navigation_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
 def get_navigation_pages(self):
   """Returns the pages to be included in the navigation bar"""
   navigation_pages = memcache.get('navigation_pages')
   if navigation_pages is not None:
     return navigation_pages
   else:
     query = Page.query(Page.appear_in_navigation == True)
     #TODO: Change the fetch limit or document that it'll only fetch 10
     navigation_pages = query.fetch()
     if not memcache.set('navigation_pages', navigation_pages):
       logging.error('Write to memcache failed!')
     return navigation_pages
开发者ID:RaspberryPiFi,项目名称:CloudCode,代码行数:14,代码来源:customframework.py

示例8: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
    def get(self):
        q = Page.query()

        logging.info('Starting Dispatch process')

        for page in q.iter():
            logging.info('Adding task to the queue to proccess '
                         '%s Web Page' % page.name)

            logging.info('urlsafe key %s' % page.key.urlsafe())
            taskqueue.add(url='/task/ping',
                          queue_name='ping',
                          params={'key': page.key.urlsafe()})
开发者ID:josemontesdeoca,项目名称:web-monitor,代码行数:15,代码来源:handlers.py

示例9: store_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [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
开发者ID:RaspberryPiFi,项目名称:CloudCode,代码行数:39,代码来源:customframework.py

示例10: process_text_admin

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
def process_text_admin(text):
    # Process the small markup here.
    slugs = re.findall(r"#(\w+)",text)
    replacements = list()
    for slug in slugs:
        page = Page.query(Page.slug == slug).fetch(1)
        if page:
            replacements.append('content')
            replacements.append('<i class="fa fa-external-link-square"></i>')
        else:
            replacements.append('content')
            replacements.append('<i class="fa fa-edit"></i>')

    newtext = re.sub(r"#(\w+)", '<a href="/{}/\g<1>">{}</a>', text)
    return newtext.format(*replacements)
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:17,代码来源:main.py

示例11: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import query [as 别名]
 def get(self):
   sources = Page.query().fetch()
   self.render_template('sources.html', sources=sources)
开发者ID:jabrouwer82,项目名称:creepy-kumquat,代码行数:5,代码来源:sources.py


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