aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/utils.py')
-rwxr-xr-xpyaggr3g470r/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index c6264106..01bcd36c 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -52,9 +52,10 @@ from collections import Counter
from contextlib import contextmanager
import conf
-from pyaggr3g470r import db
+from flask import g
from pyaggr3g470r.models import User, Feed, Article
+
# regular expression to check URL
url_finders = [
re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\),\\\"]"), \
@@ -136,7 +137,7 @@ def import_opml(email, opml_content):
return nb
nb = read(subscriptions)
- db.session.commit()
+ g.db.session.commit()
return nb
def import_json(email, json_content):
@@ -159,7 +160,7 @@ def import_json(email, json_content):
enabled=feed["enabled"])
user.feeds.append(new_feed)
nb_feeds += 1
- db.session.commit()
+ g.db.session.commit()
# Create articles
for feed in json_account["result"]:
@@ -179,7 +180,7 @@ def import_json(email, json_content):
user_feed.articles.append(new_article)
nb_articles += 1
- db.session.commit()
+ g.db.session.commit()
return nb_feeds, nb_articles
bgstack15