summaryrefslogtreecommitdiffstats
path: root/module/interaction/InteractionTask.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/interaction/InteractionTask.py')
-rw-r--r--module/interaction/InteractionTask.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/module/interaction/InteractionTask.py b/module/interaction/InteractionTask.py
index b372321b0..d2877b2b0 100644
--- a/module/interaction/InteractionTask.py
+++ b/module/interaction/InteractionTask.py
@@ -19,12 +19,12 @@
from time import time
from module.Api import InteractionTask as BaseInteractionTask
-from module.Api import Input, Output
+from module.Api import Interaction, InputType, Input
#noinspection PyUnresolvedReferences
class InteractionTask(BaseInteractionTask):
"""
- General Interaction Task extends ITask defined by thrift with additional fields and methods.
+ General Interaction Task extends ITask defined by api with additional fields and methods.
"""
#: Plugins can put needed data here
storage = None
@@ -38,8 +38,21 @@ class InteractionTask(BaseInteractionTask):
error = None
#: Timeout locked
locked = False
+ #: A task that was retrieved counts as seen
+ seen = False
+ #: A task that is relevant to every user
+ shared = False
+ #: primary uid of the owner
+ owner = None
def __init__(self, *args, **kwargs):
+ if 'owner' in kwargs:
+ self.owner = kwargs['owner']
+ del kwargs['owner']
+ if 'shared' in kwargs:
+ self.shared = kwargs['shared']
+ del kwargs['shared']
+
BaseInteractionTask.__init__(self, *args, **kwargs)
# additional internal attributes
@@ -54,28 +67,34 @@ class InteractionTask(BaseInteractionTask):
def getResult(self):
return self.result
+ def setShared(self):
+ """ enable shared mode, should not be reversed"""
+ self.shared = True
+
def setResult(self, value):
self.result = self.convertResult(value)
def setWaiting(self, sec, lock=False):
+ """ sets waiting in seconds from now, < 0 can be used as infinitive """
if not self.locked:
- self.wait_until = max(time() + sec, self.wait_until)
+ if sec < 0:
+ self.wait_until = -1
+ else:
+ self.wait_until = max(time() + sec, self.wait_until)
+
if lock: self.locked = True
def isWaiting(self):
- if self.result or self.error or time() > self.waitUntil:
+ if self.result or self.error or self.timedOut():
return False
return True
def timedOut(self):
- return time() > self.wait_until > 0
+ return time() > self.wait_until > -1
def correct(self):
[x.taskCorrect(self) for x in self.handler]
def invalid(self):
- [x.taskInvalid(self) for x in self.handler]
-
- def __str__(self):
- return "<InteractionTask '%s'>" % self.id \ No newline at end of file
+ [x.taskInvalid(self) for x in self.handler] \ No newline at end of file