fix recursive import

This commit is contained in:
Thomas L 2018-03-29 00:12:19 +02:00
parent c71bc8574a
commit 8e08eb9c2e
2 changed files with 6 additions and 3 deletions

8
db.py
View file

@ -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()]

View file

@ -1,3 +1,4 @@
#!/usr/bin/env python3
import bottle
from bottle import get, post, redirect, request, response, view
from config import config