Fixed the example so it actually does what it says. It said "The last 10 entries will appear sorted in a table below.". What it did was if the number of entries was 10, it would truncate the entries and start over again. So, in order for this to show the last 10 entries, it has to delete the oldest entry after 10. The best way to do that is to not sort the list, except when displaying and then delete the first entry in the list before inserting the 11th entry.
22 lines
390 B
Python
22 lines
390 B
Python
def index():
|
|
return dict()
|
|
|
|
|
|
def data():
|
|
if not session.m:
|
|
session.m = []
|
|
if request.vars.q:
|
|
if len(session.m) == 10:
|
|
del(session.m[0])
|
|
session.m.append(request.vars.q)
|
|
return TABLE(*[TR(v) for v in sorted(session.m)]).xml()
|
|
|
|
|
|
def flash():
|
|
response.flash = 'this text should appear!'
|
|
return dict()
|
|
|
|
|
|
def fade():
|
|
return dict()
|