def _sync_remotely(): """Synchronize posts from remote blog-system (cnblogs)""" #print 'do synchronizing...' # get current max-postid in database ids = _find_ids(0, 1) cur_max_postid = ids[0] if ids else 0 num_to_get = 5 while True: try: latest_posts = post.recent(num_to_get) latest_ids = [int(p['postid']) for p in latest_posts] # we've gotten all the latest posts possible if min(latest_ids) <= cur_max_postid: for postid in latest_ids: if postid > cur_max_postid: insert(unicode(postid)) break # task is done, get out # maybe some new posts are missed, we need to check more num_to_get += 5 except ValueError: break
def GET(self): ps = post.recent(1) return render.index(ps)