ActivityRuntimeEnvironment.py 892 Bytes
Newer Older
1
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
2 3 4

def getActivityRuntimeEnvironment():
  """
5
    Raises KeyError if called outside activity.
6
  """
7
  return getTransactionalVariable(None)['activity_runtime_environment']
8 9

def _getActivityRuntimeEnvironment():
10 11 12 13
  try:
    return getActivityRuntimeEnvironment()
  except KeyError:
    return
14 15


16 17 18 19 20 21 22 23 24 25 26
class BaseMessage:

  delay = None
  # None means infinite retry
  max_retry = 5
  # For errors happening after message invocation (ConflictError),
  # should we retry quickly without increasing 'retry' count ?
  conflict_retry = True


class ActivityRuntimeEnvironment(object):
27

28 29
  def __init__(self, message):
    self._message = message
30

31 32 33 34 35
  def edit(self, **kw):
    # There is no point allowing to modify other attributes from a message
    for k in kw:
      getattr(BaseMessage, k)
    self._message.__dict__.update(kw)