From 8e08eb9c2e67d56302c22b0dc17afe02a631b1ef Mon Sep 17 00:00:00 2001 From: Thomas L Date: Thu, 29 Mar 2018 00:12:19 +0200 Subject: [PATCH] fix recursive import --- db.py | 8 +++++--- frontend.py | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/db.py b/db.py index 4b62586..1254ab9 100644 --- a/db.py +++ b/db.py @@ -4,7 +4,6 @@ import logging from os import urandom from pylibscrypt import scrypt_mcf import sqlite3 -from user import User logger = logging.getLogger(__name__) @@ -96,6 +95,8 @@ class DB(object): twitter_accounts_id INTEGER, tweet_id TEXT, FOREIGN KEY(user_id) REFERENCES user(id) + FOREIGN KEY(twitter_accounts_id) + REFERENCES twitter_accounts(id) ); CREATE TABLE IF NOT EXISTS mail ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, @@ -103,8 +104,6 @@ class DB(object): email TEXT, active INTEGER, FOREIGN KEY(user_id) REFERENCES user(id) - FOREIGN KEY(twitter_accounts_id) - REFERENCES twitter_accounts(id) ); CREATE TABLE IF NOT EXISTS seen_mails ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, @@ -125,6 +124,7 @@ class DB(object): }, self.secret).decode('ascii') def confirm(self, token): + from user import User try: json = jwt.decode(token, self.secret) except jwt.DecodeError: @@ -142,6 +142,7 @@ class DB(object): return User(uid) def by_email(self, email): + from user import User self.execute("SELECT user_id FROM email WHERE email=?;", (email, )) try: uid, = self.cur.fetchone() @@ -151,6 +152,7 @@ class DB(object): @property def active_users(self): + from user import User self.execute("SELECT id FROM user WHERE enabled=1;") return [User(uid) for uid, in self.cur.fetchall()] diff --git a/frontend.py b/frontend.py index b11fd55..1c35961 100755 --- a/frontend.py +++ b/frontend.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import bottle from bottle import get, post, redirect, request, response, view from config import config