Exemple #1
0
def build_uri_map():
    """ Map Disqus thread-ids to tuple of (isso_uri, title) """
    with app.app.test_request_context():
        uri_map = {}
        for record in model.Entry.select():
            e = entry.Entry(record)
            thread_id = e.get('thread-id', 'publ_{}'.format(record.id))
            uri_map[thread_id] = (app.thread_id(e), record.title)
        return uri_map
def update_thread(tid, uri):
    match = re.match(r'/[a-f0-9]{16}/([0-9]*)$', uri)
    if not match:
        return

    entry_id = int(match.group(1))
    record = model.Entry.get(id=entry_id)
    if not record:
        print("Couldn't find entry", entry_id)
        return

    with app.app.test_request_context():
        e = entry.Entry(record)
        new_uri = app.thread_id(e)
        if new_uri != uri:
            print(uri, '\t->', new_uri)
            db.cursor().execute('UPDATE threads SET uri=?, title=? where id=?',
                                (app.thread_id(e), record.title, tid))
Exemple #3
0
def do_all():
    with app.app.test_request_context():
        for record in model.Entry.select():
            e = entry.Entry(record)
            migrate(e)
Exemple #4
0
def do_one(entry_id, mt_id):
    with app.app.test_request_context():
        record = model.Entry.get(id=entry_id)
        e = entry.Entry(record)
        migrate(e, mt_id)