Re: [web2py] Re: Pagination [Web2py Utils] returns None
Hey Thadeus! where would you like me to submit it? I can upload it here to this news group. The only thing I changed was what you suggested ;) adding self.r.args to the generate links function ;) def generate_links(self): self.backward = A(' previous()', _href=URL(r=self.r, args=self.r.args, vars={'p': self.current - self.display_count})) if self.current else ' previous(False)' self.forward = A('next() ', _href=URL(r=self.r, args=self.r.args, vars={'p': self.current + self.display_count})) if self.total_results self.current + self.display_count else 'next(False) ' self.location = 'Showing %d to %d out of %d records' % (self.current + 1, self.current + self.num_results, self.total_results) return (self.backward, self.forward, self.location) Anyway I attached the paginate.py *cheers On Thu, Nov 11, 2010 at 9:45 PM, Thadeus Burgess thade...@thadeusb.comwrote: Mind sending me a patch? -- Thadeus On Thu, Nov 11, 2010 at 6:02 PM, Andrew Evans randra...@gmail.com wrote: hey thanks for the tips I have it working now *cheers Andrew paginate.py Description: Binary data
Re: [web2py] Re: Pagination [Web2py Utils] returns None
Thanks. I uploaded a new version to pypi. -- Thadeus On Fri, Nov 12, 2010 at 10:27 AM, Andrew Evans randra...@gmail.com wrote: Hey Thadeus! where would you like me to submit it? I can upload it here to this news group. The only thing I changed was what you suggested ;) adding self.r.args to the generate links function ;) def generate_links(self): self.backward = A(' previous()', _href=URL(r=self.r, args=self.r.args, vars={'p': self.current - self.display_count})) if self.current else ' previous(False)' self.forward = A('next() ', _href=URL(r=self.r, args=self.r.args, vars={'p': self.current + self.display_count})) if self.total_results self.current + self.display_count else 'next(False) ' self.location = 'Showing %d to %d out of %d records' % (self.current + 1, self.current + self.num_results, self.total_results) return (self.backward, self.forward, self.location) Anyway I attached the paginate.py *cheers On Thu, Nov 11, 2010 at 9:45 PM, Thadeus Burgess thade...@thadeusb.comwrote: Mind sending me a patch? -- Thadeus On Thu, Nov 11, 2010 at 6:02 PM, Andrew Evans randra...@gmail.comwrote: hey thanks for the tips I have it working now *cheers Andrew
Re: [web2py] Re: Pagination [Web2py Utils] returns None
Hello ty for the reply You wouldn't by chance be able to help me with a patch. Your talking about the paginate.py file to patch set_links in there or with in the set_links value in my code? Your the developer of Web2py Utils is that correct? Nice work on it :D *cheers Andrew On Wed, Nov 10, 2010 at 5:24 PM, Thadeus Burgess thade...@thadeusb.comwrote: Its losing the args when it creates a new URL. It will require a patch on set_links so you can pass custom args and vars to URL. -- Thadeus On Wed, Nov 10, 2010 at 4:36 PM, Andrew Evans randra...@gmail.com wrote: I just noticed the difference in URLs https://127.0.0.1:8000/Working/display/product_wall/4056 above is the comments on the product notice the id. below is the next link of the pagination https://www.127.0.0.1:8000/Working/display/product_wall?p=5 it loses the 4056 which is the id of the product I think it may have to do with response value. Any ideas? On Wed, Nov 10, 2010 at 9:04 AM, Andrew Evans randra...@gmail.comwrote: Hello I am trying to create some pagination on my comments page everything seems to be working, however when I click the next link it goes to a page that all it says is None Anyone know why this is happening and how to fix it There are entries in the db. Thanks in Advance below is my code *cheers def product_wall(): this_page = request.args(0) product=db(db.product.id == this_page).select(db.product.ALL) for products in product: #comments=db(db.comment.product == this_page).select(db.comment.ALL) comments=db.comment.product == this_page orderby = ~db.comment.id pcache = (cache.ram, 15) stars = StarRatingWidget(single_vote=True) db.comment.rating.widget = stars.widget db.comment.product.default = products.id form = SQLFORM(db.comment) db.comment.product.id = products.id if form.accepts(request.vars,session): response.flash = 'Your Comment has been submitted' paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products) elif form.errors: response.flash = 'Please correct your error' paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products) else: paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products)
Re: [web2py] Re: Pagination [Web2py Utils] returns None
There are two alternatives. Have the generate_links function assume args when creating the url. This could be based on the existing args in request. URL(r=self.r, args=self.r.args) Or patch get_set to allow passing args as part of the function declaration, it would in turn pass these args to the generate_links() function and then URL would use those args. In the first case you would not need to change anything on your side. The second option would look something like qry = paginate.get_set(set_links=True, args=['myarg1', 'myarg2']) Which would YOU prefer? -- Thadeus On Thu, Nov 11, 2010 at 3:09 AM, Andrew Evans randra...@gmail.com wrote: ur the developer of Web2py Utils is that corr
Re: [web2py] Re: Pagination [Web2py Utils] returns None
hey thanks for the tips I have it working now *cheers Andrew
Re: [web2py] Re: Pagination [Web2py Utils] returns None
Mind sending me a patch? -- Thadeus On Thu, Nov 11, 2010 at 6:02 PM, Andrew Evans randra...@gmail.com wrote: hey thanks for the tips I have it working now *cheers Andrew
[web2py] Re: Pagination [Web2py Utils] returns None
I just noticed the difference in URLs https://127.0.0.1:8000/Working/display/product_wall/4056 above is the comments on the product notice the id. below is the next link of the pagination https://www.127.0.0.1:8000/Working/display/product_wall?p=5 it loses the 4056 which is the id of the product I think it may have to do with response value. Any ideas? On Wed, Nov 10, 2010 at 9:04 AM, Andrew Evans randra...@gmail.com wrote: Hello I am trying to create some pagination on my comments page everything seems to be working, however when I click the next link it goes to a page that all it says is None Anyone know why this is happening and how to fix it There are entries in the db. Thanks in Advance below is my code *cheers def product_wall(): this_page = request.args(0) product=db(db.product.id == this_page).select(db.product.ALL) for products in product: #comments=db(db.comment.product == this_page).select(db.comment.ALL) comments=db.comment.product == this_page orderby = ~db.comment.id pcache = (cache.ram, 15) stars = StarRatingWidget(single_vote=True) db.comment.rating.widget = stars.widget db.comment.product.default = products.id form = SQLFORM(db.comment) db.comment.product.id = products.id if form.accepts(request.vars,session): response.flash = 'Your Comment has been submitted' paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products) elif form.errors: response.flash = 'Please correct your error' paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products) else: paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products)
Re: [web2py] Re: Pagination [Web2py Utils] returns None
Its losing the args when it creates a new URL. It will require a patch on set_links so you can pass custom args and vars to URL. -- Thadeus On Wed, Nov 10, 2010 at 4:36 PM, Andrew Evans randra...@gmail.com wrote: I just noticed the difference in URLs https://127.0.0.1:8000/Working/display/product_wall/4056 above is the comments on the product notice the id. below is the next link of the pagination https://www.127.0.0.1:8000/Working/display/product_wall?p=5 it loses the 4056 which is the id of the product I think it may have to do with response value. Any ideas? On Wed, Nov 10, 2010 at 9:04 AM, Andrew Evans randra...@gmail.com wrote: Hello I am trying to create some pagination on my comments page everything seems to be working, however when I click the next link it goes to a page that all it says is None Anyone know why this is happening and how to fix it There are entries in the db. Thanks in Advance below is my code *cheers def product_wall(): this_page = request.args(0) product=db(db.product.id == this_page).select(db.product.ALL) for products in product: #comments=db(db.comment.product == this_page).select(db.comment.ALL) comments=db.comment.product == this_page orderby = ~db.comment.id pcache = (cache.ram, 15) stars = StarRatingWidget(single_vote=True) db.comment.rating.widget = stars.widget db.comment.product.default = products.id form = SQLFORM(db.comment) db.comment.product.id = products.id if form.accepts(request.vars,session): response.flash = 'Your Comment has been submitted' paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products) elif form.errors: response.flash = 'Please correct your error' paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products) else: paginate = Pagination(db,comments,orderby,display_count=2,cache=pcache,r=request,res=response) rows=paginate.get_set(set_links=True) return dict(comments=rows,form=form,products=products)