diff options
-rw-r--r-- | module/Api.py | 3 | ||||
-rw-r--r-- | module/plugins/Base.py | 16 | ||||
-rw-r--r-- | module/threads/DownloadThread.py | 2 | ||||
-rw-r--r-- | module/web/webinterface.py | 4 |
4 files changed, 20 insertions, 5 deletions
diff --git a/module/Api.py b/module/Api.py index 182024775..dec1526b2 100644 --- a/module/Api.py +++ b/module/Api.py @@ -150,6 +150,9 @@ class Api(Iface): :param uid: user or userData instance or uid :return: :class:`UserApi` """ + if isinstance(uid, User): + uid = uid.uid + if uid not in self.user_apis: user = self.core.db.getUserData(uid=uid) if not user: #TODO: anonymous user? diff --git a/module/plugins/Base.py b/module/plugins/Base.py index 9f6499985..2b9e12653 100644 --- a/module/plugins/Base.py +++ b/module/plugins/Base.py @@ -88,8 +88,18 @@ class Base(object): self.evm = core.eventManager #: :class:`InteractionManager` self.im = core.interactionManager - #: :class:`User`, user related to this plugin - self.user = user + if user: + #: :class:`Api`, user api when user is set + self.api = self.core.api.withUserContext(user) + if self.api: + #: :class:`User`, user related to this plugin + self.user = self.api.user + else: + self.api = self.core.api + self.user = None + else: + self.api = self.core.api + self.user = None #: last interaction task self.task = None @@ -176,7 +186,7 @@ class Base(object): def checkAbort(self): """ Will be overwritten to determine if control flow should be aborted """ - if self.abort: raise Abort() + if self.abort(): raise Abort() def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=False): """Load content at url and returns it diff --git a/module/threads/DownloadThread.py b/module/threads/DownloadThread.py index 7555a82ce..0269b0660 100644 --- a/module/threads/DownloadThread.py +++ b/module/threads/DownloadThread.py @@ -106,6 +106,8 @@ class DownloadThread(BaseThread): except Fail, e: msg = e.args[0] + # TODO: activate former skipped downloads + if msg == "offline": pyfile.setStatus("offline") self.log.warning(_("Download is offline: %s") % pyfile.name) diff --git a/module/web/webinterface.py b/module/web/webinterface.py index 76d58e0e4..75907a0a8 100644 --- a/module/web/webinterface.py +++ b/module/web/webinterface.py @@ -133,14 +133,14 @@ def run_lightweight(host="0.0.0.0", port="8000"): run(app=web, host=host, port=port, quiet=True, server="bjoern") -def run_threaded(host="0.0.0.0", port="8000", theads=3, cert="", key=""): +def run_threaded(host="0.0.0.0", port="8000", threads=3, cert="", key=""): from wsgiserver import CherryPyWSGIServer if cert and key: CherryPyWSGIServer.ssl_certificate = cert CherryPyWSGIServer.ssl_private_key = key - CherryPyWSGIServer.numthreads = theads + CherryPyWSGIServer.numthreads = threads from utils import CherryPyWSGI |