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


Python Cursor.from_websafe_string方法代码示例

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


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

示例1: set_cursor

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
def set_cursor(queryset, start=None, end=None):
    queryset = _add_mixin(queryset)

    if start is not None:
        start = Cursor.from_websafe_string(start)
        setattr(queryset.query, '_gae_start_cursor', start)
    if end is not None:
        end = Cursor.from_websafe_string(end)
        setattr(queryset.query, '_gae_end_cursor', end)

    return queryset
开发者ID:Chitrank-Dixit,项目名称:django-appengine-sample,代码行数:13,代码来源:utils.py

示例2: set_cursor

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
def set_cursor(queryset, start=None, end=None):
    queryset = queryset.all()
    class CursorQuery(CursorQueryMixin, queryset.query.__class__):
        pass
    queryset.query = queryset.query.clone(klass=CursorQuery)
    if start is not None:
        start = Cursor.from_websafe_string(start)
    queryset.query._gae_start_cursor = start
    if end is not None:
        end = Cursor.from_websafe_string(end)
    queryset.query._gae_end_cursor = end
    # Evaluate QuerySet
    return queryset
开发者ID:HBehrens,项目名称:feedsanitizer,代码行数:15,代码来源:utils.py

示例3: retrieve_dbs

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
def retrieve_dbs(model_class, query, order=None, limit=None, cursor=None,
                 **filters):
  ''' Retrieves entities from datastore, by applying cursor pagindation
  and equality filters. Returns dbs and more cursor value
  '''
  limit = limit or config.DEFAULT_DB_LIMIT
  if cursor:
    cursor = Cursor.from_websafe_string(cursor)

  #apply order if any
  if order:
    for o in order.split(','):
      if o.startswith('-'):
        query = query.order(-model_class._properties[o[1:]])
      else:
        query = query.order(model_class._properties[o])

  for prop in filters:
    if filters.get(prop, None) is None:
      continue
    if type(filters[prop]) == list:
      for value in filters[prop]:
        query = query.filter(model_class._properties[prop] == value)
    else:
      query = query.filter(model_class._properties[prop] == filters[prop])

  model_dbs, more_cursor, more = query.fetch_page(limit, start_cursor=cursor)
  if not more:
    more_cursor = None
  else:
    more_cursor = more_cursor.to_websafe_string()
  return list(model_dbs), more_cursor
开发者ID:gmist,项目名称:3dhero.ru,代码行数:34,代码来源:util.py

示例4: retrieve_dbs

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
def retrieve_dbs(
    query, order=None, limit=None, cursor=None, keys_only=None, **filters
  ):
  limit = limit or config.DEFAULT_DB_LIMIT
  cursor = Cursor.from_websafe_string(cursor) if cursor else None
  model_class = ndb.Model._kind_map[query.kind]
  if order:
    for o in order.split(','):
      if o.startswith('-'):
        query = query.order(-model_class._properties[o[1:]])
      else:
        query = query.order(model_class._properties[o])

  for prop in filters:
    if filters.get(prop, None) is None:
      continue
    if isinstance(filters[prop], list):
      for value in filters[prop]:
        query = query.filter(model_class._properties[prop] == value)
    else:
      query = query.filter(model_class._properties[prop] == filters[prop])

  model_dbs, more_cursor, more = query.fetch_page(
      limit, start_cursor=cursor, keys_only=keys_only,
    )
  more_cursor = more_cursor.to_websafe_string() if more else None
  return list(model_dbs), more_cursor
开发者ID:georstef,项目名称:gae-init-docs,代码行数:29,代码来源:util.py

示例5: retrieve_dbs

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
def retrieve_dbs(query, order=None, limit=None, cursor=None, **filters):
    """ Retrieves entities from datastore, by applying cursor pagination
  and equality filters. Returns dbs and more cursor value
  """
    limit = limit or config.DEFAULT_DB_LIMIT
    cursor = Cursor.from_websafe_string(cursor) if cursor else None
    model_class = ndb.Model._kind_map[query.kind]
    if order:
        for o in order.split(","):
            if o.startswith("-"):
                query = query.order(-model_class._properties[o[1:]])
            else:
                query = query.order(model_class._properties[o])

    for prop in filters:
        if filters.get(prop, None) is None:
            continue
        if isinstance(filters[prop], list):
            for value in filters[prop]:
                query = query.filter(model_class._properties[prop] == value)
        else:
            query = query.filter(model_class._properties[prop] == filters[prop])

    model_dbs, more_cursor, more = query.fetch_page(limit, start_cursor=cursor)
    more_cursor = more_cursor.to_websafe_string() if more else None
    return list(model_dbs), more_cursor
开发者ID:handol,项目名称:gae-init,代码行数:28,代码来源:util.py

示例6: all

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
    def all(cls, cursor):
        page_size = int(os.environ['PAGE_SIZE'])
        query = cls.query().order(-cls.creation_time)

        if cursor:
            cursor_obj = Cursor.from_websafe_string(cursor)
            return query.fetch_page(page_size, start_cursor=cursor_obj)
        return query.fetch_page(page_size)
开发者ID:szkocka,项目名称:api,代码行数:10,代码来源:db.py

示例7: by_creator

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
    def by_creator(cls, user_key, cursor):
        page_size = int(os.environ['PAGE_SIZE'])
        query = cls.query(
                cls.status == StatusType.ACTIVE,
                cls.creator_key == user_key).order(cls.status, cls.key)

        if cursor:
            cursor_obj = Cursor.from_websafe_string(cursor)
            return query.fetch_page(page_size, start_cursor=cursor_obj)
        return query.fetch_page(page_size)
开发者ID:szkocka,项目名称:api,代码行数:12,代码来源:db.py

示例8: get_comments_more

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
        def get_comments_more(self,key):
            cursor=self.param('next')
            entry=Entry.get(key)
            from google.appengine.datastore.datastore_query import Cursor
            cur=Cursor.from_websafe_string(cursor)

            comments,cursor,more=Comment.query().filter(Comment.entry ==entry.key).order(-Comment.date).fetch_page(10,start_cursor=cur)

            vals= dict(entry=entry, comments=comments,cursor=more and  cursor.to_websafe_string() or '',more=more)
            html=self.get_render('comments_more',vals)
            self.write(html)
开发者ID:SeanStar,项目名称:micolog,代码行数:13,代码来源:blog.py

示例9: by_research

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
    def by_research(cls, research_key, cursor):
        page_size = int(os.environ['PAGE_SIZE'])
        query = cls.query(
                cls.status == StatusType.ACTIVE,
                cls.research_key == research_key)\
            .order(-cls.creation_time, cls.status, cls.key)

        if cursor:
            cursor_obj = Cursor.from_websafe_string(cursor)
            return query.fetch_page(page_size, start_cursor=cursor_obj)
        return query.fetch_page(page_size)
开发者ID:szkocka,项目名称:api,代码行数:13,代码来源:db.py

示例10: by_user

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
    def by_user(cls, user_key, cursor):
        page_size = int(os.environ['PAGE_SIZE'])
        q = cls.query(ndb.OR(
                cls.supervisor_key == user_key,
                cls.researchers_keys == user_key),
                cls.status.IN([StatusType.ACTIVE, StatusType.BANNED]))\
            .order(cls.key)

        if cursor:
            cursor_obj = Cursor.from_websafe_string(cursor)
            return q.fetch_page(page_size, start_cursor=cursor_obj)
        return q.fetch_page(page_size)
开发者ID:szkocka,项目名称:api,代码行数:14,代码来源:db.py

示例11: get_dbs

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
def get_dbs(
    query, order=None, limit=None, cursor=None, keys_only=None, **filters
  ):
  limit = limit or config.DEFAULT_DB_LIMIT
  cursor = Cursor.from_websafe_string(cursor) if cursor else None
  model_class = ndb.Model._kind_map[query.kind]

  for prop in filters:
    if filters.get(prop, None) is None:
      continue
    if isinstance(filters[prop], list):
      for value in filters[prop]:
        query = query.filter(model_class._properties[prop] == value)
# new custom wodor app -------------
    elif isinstance(filters[prop], dict):
      if filters[prop]['test'] == '>':
        query = query.filter(model_class._properties[prop] > filters[prop]['value'])
      elif filters[prop]['test'] == '>=':
        query = query.filter(model_class._properties[prop] >= filters[prop]['value'])
      elif filters[prop]['test'] == '<':
        query = query.filter(model_class._properties[prop] < filters[prop]['value'])
      elif filters[prop]['test'] == '<=':
        query = query.filter(model_class._properties[prop] < filters[prop]['value'])
      elif filters[prop]['test'] == '==':
        query = query.filter(model_class._properties[prop] == filters[prop]['value'])
      elif filters[prop]['test'] == '!=':
        query = query.filter(model_class._properties[prop] != filters[prop]['value'])
      elif filters[prop]['test'] == 'IN':
        values = filters[prop]['value']
        if isinstance(values, list):
          values = filters[prop]['value']
        else:
           values = values.split(',')
        query = query.filter(model_class._properties[prop].IN(values))
        query = query.order(model_class._key)
      query = query.order(model_class._properties[prop]) # TODO does it work?
    else:
      query = query.filter(model_class._properties[prop] == filters[prop])
# ----------------------------------

  if order:
    for o in order.split(','):
      if o.startswith('-'):
        query = query.order(-model_class._properties[o[1:]])
      else:
        query = query.order(model_class._properties[o])
  model_dbs, next_cursor, more = query.fetch_page(
      limit, start_cursor=cursor, keys_only=keys_only,
    )
  next_cursor = next_cursor.to_websafe_string() if more else None
  return list(model_dbs), next_cursor
开发者ID:wodore,项目名称:wodore-gae,代码行数:53,代码来源:util.py

示例12: fetch_cursor

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
    def fetch_cursor(self,next_cursor='',prev_cursor='',order=None):
        from google.appengine.datastore.datastore_query import Cursor
##        cur=Cursor.from_websafe_string(p)
##        results,cur2,more= self.query.fetch_page(self.items_per_page,start_cursor=cur)

##        # setup query
        if prev_cursor:
            query = self.query.order(order.reversed())
            cur=Cursor.from_websafe_string(prev_cursor)
        elif next_cursor:
            query = self.query.order(order)
            cur=Cursor.from_websafe_string(next_cursor)
        else:
            query = self.query.order(order)
            cur=None

        # fetch results
        results,cur2,more = query.fetch_page(self.items_per_page,start_cursor=cur)
        if prev_cursor:
            results.reverse()
        sPrev=''
        sNext=''
        # pagination
        if prev_cursor:
            sNext=cur.reversed().to_websafe_string()
            sPrev=more and cur2.to_websafe_string() or ''


        else:
            if next_cursor:
                 sPrev=cur.reversed().to_websafe_string()
            sNext=more and cur2.to_websafe_string() or ''

        links = { 'prev': sPrev, 'next': sNext, 'more': more }
##
##        links = {'prev': cur2.reversed().to_websafe_string(), 'next':more and cur2.to_websafe_string() or '','more':more }
##
        return (results, links)
开发者ID:gkso,项目名称:micolog,代码行数:40,代码来源:base.py

示例13: find_all

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
    def find_all(cls, cursor, keyword):
        page_size = int(os.environ['PAGE_SIZE'])

        q = cls.query(cls.status.IN([StatusType.ACTIVE, StatusType.BANNED])) \

        if keyword:
            q = q.filter(cls.email >= keyword)
            q = q.filter(cls.email < keyword + u'\ufffd')

        q = q.order(cls.email, cls.key)

        if cursor:
            cursor_obj = Cursor.from_websafe_string(cursor)
            return q.fetch_page(page_size, start_cursor=cursor_obj)
        return q.fetch_page(page_size)
开发者ID:szkocka,项目名称:api,代码行数:17,代码来源:db.py

示例14: artists

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
 def artists(self, request):
     '''API endpoint to query for artists'''
     next_page = request.next_page or 'first_artists_page'
     cache = memcache.get(next_page)
     if cache:
         return ArtistsResponse(artists=cache[0], next_page=cache[1])
     query = Artist.query()
     if next_page is 'first_artists_page':
         artists, cursor, more = query.fetch_page(300) 
     else:
         artists, cursor, more = query.fetch_page(300, 
                 start_cursor=Cursor.from_websafe_string(next_page))
     artists = [artist.to_message() for artist in artists]
     memcache.add(next_page, (artists, cursor.to_websafe_string()))
     return ArtistsResponse(artists=artists, next_page=cursor.to_websafe_string())
开发者ID:juancferrer,项目名称:lma,代码行数:17,代码来源:api.py

示例15: validate_request

# 需要导入模块: from google.appengine.datastore.datastore_query import Cursor [as 别名]
# 或者: from google.appengine.datastore.datastore_query.Cursor import from_websafe_string [as 别名]
 def validate_request(cls, request):
     args = cls.get_dwc_args(request)            
     if len(args) == 0 and request.get('q', None) is None:
         return None
     keywords = [x.lower() for x in request.get('q', '').split(',') if x]
     limit = request.get_range('limit', min_value=1, max_value=100, default=10)
     offset = request.get('offset', None)
     cursor = None
     if offset:
         cursor = Cursor.from_websafe_string(offset)
     return dict(
         args=args, 
         keywords=keywords, 
         limit=limit, 
         offset=offset, 
         cursor=cursor)
开发者ID:VertNet,项目名称:Darwin-Core-Engine,代码行数:18,代码来源:app.py


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