Instead of rows.append(morerows), you can do: rows &= morerows
rows1 & rows2 will append rows2 to rows1, and rows1 | rows2 does the same but removes from rows2 any duplicates of rows that appear in rows1. In addition to & and |, you can also use &= and |=, as in the above example. This information is top secret, so please don't tell anyone. ;-) Anthony On Sunday, August 12, 2012 2:46:52 AM UTC-4, Annet wrote: > > I have the following function: > > def classes(): > response.view='site/classes.html' > alert='' > if session[request.args(0)].tab_1: > weekday=request.now.weekday()+1 > > query1=db((db.Timetable.nodeID==session[request.args(0)].id)&(db.Timetable.dayID== > db.Day.id)&\ > > (((db.Timetable.dayID==weekday)&(db.Timetable.startTime>request.now))|(db.Timetable.dayID>weekday))) > if int(query1.count())<8: > i=query1.count() > rows=query1.select(db.Timetable.ALL,db.Day.name > ,orderby=db.Timetable.dayID|db.Timetable.startTime,limitby=(0,i)) > > morerows=db((db.Timetable.nodeID==session[request.args(0)].id)&(db.Timetable.dayID== > db.Day.id)&(db.Timetable.dayID>=1))\ > .select(db.Timetable.ALL,db.Day.name > ,orderby=db.Timetable.dayID|db.Timetable.startTime,limitby=(0,8-i)) > for row in morerows: > rows.append(row) > else: > rows=query1.select(db.Timetable.ALL,db.Day.name > ,orderby=db.Timetable.dayID|db.Timetable.startTime,limitby=(0,8)) > if not rows: > response.flash='Geen informatie over lessen beschikbaar' > alert='alert-info' # to set alert class for flash > return dict(rows=rows,alert=alert) > > When I run this function I get the following error: > > Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line > 205, in restricted > exec ccode in environment > File > "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py" > <http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py>, > line 190, in <module> > File "/Library/Python/2.5/site-packages/web2py/gluon/globals.py", line 173, > in <lambda> > self._caller = lambda f: f() > File > "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py" > <http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py>, > line 146, in classes > rows.append(row) > AttributeError: 'Rows' object has no attribute 'append' > > When I comment out row.append(row) and return rows and morerows rows > contains 3 records and morerows 5. Why doesn't this work? > > > Kind regards, > > Annet > --

