Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (31 sloc) 999 Bytes
""" Script to refresh comment thread IDs after updating the security token
pipenv run python3 /path/to/comments.db
import sys
import app
import sqlite3
import re
from publ import model, entry
from pony import orm
db = sqlite3.connect(sys.argv[1])
def update_thread(tid, uri):
match = re.match(r'/[a-f0-9]{16}/([0-9]*)$', uri)
if not match:
entry_id = int(
record = model.Entry.get(id=entry_id)
if not record:
print("Couldn't find entry", entry_id)
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))
for row in db.cursor().execute('SELECT id,uri FROM threads'):
tid, uri = row
update_thread(tid, uri)
You can’t perform that action at this time.