Today I encountered unusual error, while ajax sorting list thru jquery
sortable interface and at the same time reading data from table, where
sorting took place in a new browser window.

Does this have to do with connection pooling and transactions?

Here is function for sorting items, called thru ajax call:

def sort():
    #save sort order of all sites
    data = request.vars.st
    for idx in range(len(data)):
        db(db.site.id == int(data[idx])).update(sort_order=idx)
        #db.site[int(data[idx])] = dict(sort_order=idx)
    #return ok result
    response.headers['Content-Type']='text/plain'
    return "Saved!"

This is function for showing all data from database:

def show():
    sites = db().select(db.site.ALL, orderby=db.site.sort_order)
    rs = []
    sitecount = 1
    #setup date range for today
    today =
datetime.datetime(request.now.year,request.now.month,request.now.day)
    tomorrow = today + datetime.timedelta(days=1)
    for site in sites:
        news = db((db.site_news.site_id ==
site.id)&(db.site_news.news_date>=today)&(db.site_news.news_date<tomorrow)).select(db.site_news.ALL,
orderby=~db.site_news.news_date)
        entries = []
        for item in news:
            entries.append({'title': item.title, 'link': item.link,
'summary': item.get('content', ''), 'hash': item.item_hash, 'id':
item.id})
        rs.append({'name': site.name, 'link': site.site_link,
'entries': entries, 'id': site.id})
    return dict(sites=rs)

Reply via email to