original_docstring: Decorator function to have a database read with paging abilities.
docstring: Decorator function to have a database read with paging abilities.
docstring_tokens: Decorator function to have a database read with paging abilities .
code: def paged_db_read(func):
      """Decorator function to have a database read with paging abilities."""
      def get_pager(limit):
          tempstorage = type(b'tempstorage', (object,), {})
  
          def pager_fetch(*args, **kwargs):
              f, table, cols, conds = args
              conds = database.expand_cond(conds)
              if limit:
                  conds['limit'] = limit
  
              ret = f(table, cols, conds, _calc_found=True, **kwargs)
  
              tempstorage.count = database.fetch_info(
                  database.RawSQL('FOUND_ROWS()'))
  
              return ret
  
          def pager_return(data):
              if limit:
                  return tempstorage.count, data
  
              return data
  
          return pager_fetch, pager_return
  
      @wraps(func)
      def decorated_function(*args, **kwargs):
          return func(pager=get_pager(kwargs.pop('limit', None)),
                      *args, **kwargs)
  
      return decorated_function
code_tokens: def paged_db_read ( func ) : def get_pager ( limit ) : tempstorage = type ( b'tempstorage' , ( object , ) , { } ) def pager_fetch ( * args , ** kwargs ) : f , table , cols , conds = args conds = database . expand_cond ( conds ) if limit : conds [ 'limit' ] = limit ret = f ( table , cols , conds , _calc_found = True , ** kwargs ) tempstorage . count = database . fetch_info ( database . RawSQL ( 'FOUND_ROWS()' ) ) return ret def pager_return ( data ) : if limit : return tempstorage . count , data return data return pager_fetch , pager_return @ wraps ( func ) def decorated_function ( * args , ** kwargs ) : return func ( pager = get_pager ( kwargs . pop ( 'limit' , None ) ) , * args , ** kwargs ) return decorated_function
short_docstring: Decorator function to have a database read with paging abilities.
short_docstring_tokens: Decorator function to have a database read with paging abilities .
comment: """Decorator function to have a database read with paging abilities."""