aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/utils.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-01-17 16:50:38 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-03-03 22:22:14 +0100
commit2849c82255b4b889c7342a0a8fa8a4aecfbe599d (patch)
tree3ad31fd3a0e84bc3f40367cf4963cf8db8c65d06 /pyaggr3g470r/utils.py
parentadding news fields and migrations scripts (diff)
downloadnewspipe-2849c82255b4b889c7342a0a8fa8a4aecfbe599d.tar.gz
newspipe-2849c82255b4b889c7342a0a8fa8a4aecfbe599d.tar.bz2
newspipe-2849c82255b4b889c7342a0a8fa8a4aecfbe599d.zip
a first big refacto of the existing arch
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