[web2py] Re: Pagination manual bug?

2010-08-26 Thread Niphlod
@dlin: it doesn't works because URL helper has been improved lately,
in case you were asking yourself.

PS:  sadly if you put web2py pagination on google, the first link
that appears is from mengu.net and that implementation is wrong, also
if the analysis is correct.

limitby works like python slices, not in the way SQLians thinks in
terms of offset and limit.

I just sent a comment with the correction, hopefully he'll correct
that page.


[web2py] Re: Pagination manual bug?

2010-08-25 Thread mdipierro
This is not a bug. the manual syntax is correct for web2py 1.83.1 and
beyond.

On Aug 24, 10:56 pm, dlin dlin...@gmail.com wrote:
 As I know, at least this is manual's bug.

 In the mannual, it use
 a href={{=URL(args=[page+1])}}next/a

 But, it will raise error, I use this line instead
 a href={{=URL(r=request, args=[page+1])}}next/a

 On 8月25日, 上午1時55分, Vidul Petrov vidul.r...@gmail.com wrote:

  Not sure if this help, but you may want to take a look at this
  Pagination class:http://packages.python.org/web2py_utils/paginate.html

  On Aug 24, 6:37 pm, dlin dlin...@gmail.com wrote:

   ref:http://web2py.com/book/default/chapter/12#Pagination

   In following code, there is two problem:
   1. The 'next' button always show.  And the len(rows) always = 2
   2. I don't know how to proper show the {{=rows}} without last row, I
   want to use the odd row background-color trick.

   I wrote simliar code in default.py
   -
   def listall():
       if len(request.args): page=int(request.args[0])
       else: page=0
       items_per_page=2
       limitby=(page*items_per_page,(page+1)*items_per_page + 1)
       words= db().select(db.mytable.ALL, limitby=limitby)
       cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]]
       hdrs = dict([(str(c),c.label) for c in db.mytable])
       rows =SQLTABLE(words,
            headers = hdrs,
            columns=cols,
            truncate=32)
       rows['_id'] = 'rows'
       return dict(rows=rows, page=page, items_per_page=items_per_page)

   And the view listall.html:
   ---
   {{extend 'layout.html'}}
   {{=rows}}
   page:{{=page}} br /
   len(rows):{{=len(rows)}} br /

   {{if page:}}
   a href={{=URL(r=request, args=[page-1])}}previous/a
   {{pass}}

   {{if len(rows)=items_per_page:}}
   a href={{=URL(r=request, args=[page+1])}}next/a
   {{pass}}

   scriptjQuery(#rows tr:odd).css(background-color, #ff);/
   script


[web2py] Re: Pagination manual bug?

2010-08-24 Thread Vidul Petrov
Not sure if this help, but you may want to take a look at this
Pagination class:
http://packages.python.org/web2py_utils/paginate.html

On Aug 24, 6:37 pm, dlin dlin...@gmail.com wrote:
 ref:http://web2py.com/book/default/chapter/12#Pagination

 In following code, there is two problem:
 1. The 'next' button always show.  And the len(rows) always = 2
 2. I don't know how to proper show the {{=rows}} without last row, I
 want to use the odd row background-color trick.

 I wrote simliar code in default.py
 -
 def listall():
     if len(request.args): page=int(request.args[0])
     else: page=0
     items_per_page=2
     limitby=(page*items_per_page,(page+1)*items_per_page + 1)
     words= db().select(db.mytable.ALL, limitby=limitby)
     cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]]
     hdrs = dict([(str(c),c.label) for c in db.mytable])
     rows =SQLTABLE(words,
          headers = hdrs,
          columns=cols,
          truncate=32)
     rows['_id'] = 'rows'
     return dict(rows=rows, page=page, items_per_page=items_per_page)

 And the view listall.html:
 ---
 {{extend 'layout.html'}}
 {{=rows}}
 page:{{=page}} br /
 len(rows):{{=len(rows)}} br /

 {{if page:}}
 a href={{=URL(r=request, args=[page-1])}}previous/a
 {{pass}}

 {{if len(rows)=items_per_page:}}
 a href={{=URL(r=request, args=[page+1])}}next/a
 {{pass}}

 scriptjQuery(#rows tr:odd).css(background-color, #ff);/
 script


[web2py] Re: Pagination manual bug?

2010-08-24 Thread dlin
As I know, at least this is manual's bug.

In the mannual, it use
a href={{=URL(args=[page+1])}}next/a

But, it will raise error, I use this line instead
a href={{=URL(r=request, args=[page+1])}}next/a

On 8月25日, 上午1時55分, Vidul Petrov vidul.r...@gmail.com wrote:
 Not sure if this help, but you may want to take a look at this
 Pagination class:http://packages.python.org/web2py_utils/paginate.html

 On Aug 24, 6:37 pm, dlin dlin...@gmail.com wrote:

  ref:http://web2py.com/book/default/chapter/12#Pagination

  In following code, there is two problem:
  1. The 'next' button always show.  And the len(rows) always = 2
  2. I don't know how to proper show the {{=rows}} without last row, I
  want to use the odd row background-color trick.

  I wrote simliar code in default.py
  -
  def listall():
      if len(request.args): page=int(request.args[0])
      else: page=0
      items_per_page=2
      limitby=(page*items_per_page,(page+1)*items_per_page + 1)
      words= db().select(db.mytable.ALL, limitby=limitby)
      cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]]
      hdrs = dict([(str(c),c.label) for c in db.mytable])
      rows =SQLTABLE(words,
           headers = hdrs,
           columns=cols,
           truncate=32)
      rows['_id'] = 'rows'
      return dict(rows=rows, page=page, items_per_page=items_per_page)

  And the view listall.html:
  ---
  {{extend 'layout.html'}}
  {{=rows}}
  page:{{=page}} br /
  len(rows):{{=len(rows)}} br /

  {{if page:}}
  a href={{=URL(r=request, args=[page-1])}}previous/a
  {{pass}}

  {{if len(rows)=items_per_page:}}
  a href={{=URL(r=request, args=[page+1])}}next/a
  {{pass}}

  scriptjQuery(#rows tr:odd).css(background-color, #ff);/
  script