def get_head_object_state_rpm(sub_context): """IRolePermissionMap(context) adapter factory. Lighweight and high-performance wrapper on get_object_state(context), to *lookup* (note: no creation of any instance) the workflow.states.State singleton instance for the sub context's head's status. Note that sub context is NOT workflowed. On lookup error, returns NONE_STATE_RPM, instead of what would be a zope.component.ComponentLookupError. """ # !+HEAD_DOCUMENT_ITEM(mr, sep-2011) standardize name, "head", "document" # or "item"? try: head = _tmp_hack_protected_get_context_head(sub_context) return interfaces.IWorkflow(head).get_state(sub_context.status) except interfaces.InvalidStateError: from bungeni.models.interfaces import IChange if sub_context.status is None and IChange.providedBy(sub_context): # if status is None,then must have an "add" change action... ignore. assert sub_context.action == "add" else: # log it... !+bungeni.ui.utils.debug cls, exc, tb = sys.exc_info() log.error(""" ***get_head_object_state_rpm/%s:%s [%s] %s """ % (type(sub_context).__name__, sub_context.pk, cls.__name__, exc)) return NONE_STATE_RPM
def get_object_state(context): """Lookup the workflow.states.State instance for the context's status. Serves also as the IRolePermissionMap(context) adapter factory. May need to be called numerous times per request, so is a lightweight and performance-aware adapter -- there is no creation of any adapter instance, just lookup of the object's Workflow instance off which to retrieve existing State instances. """ return interfaces.IWorkflow(context).get_state(context.status)
def get_object_state(context): """Utility to look up the workflow.states.State singleton instance that corresponds to the context's urrent status. Implemented as the IWorkflow adaptor for the context--but as may need to be called numerous times per request, note that it is a lightweight and performance-aware adapter -- there is no creation of any adapter instance, just lookup of the object's Workflow instance off which to retrieve existing State instances. """ return interfaces.IWorkflow(context).get_state(context.status)
def get_head_object_state_rpm(sub_context): """IRolePermissionMap(context) adapter factory. Lighweight and high-performance wrapper on get_object_state(context), to *lookup* (note: no creation of any instance) the workflow.states.State singleton instance for the sub context's head's status. Note that sub context is NOT workflowed. """ # !+HEAD_DOCUMENT_ITEM(mr, sep-2011) standardize name, "head", "document" # or "item"? return interfaces.IWorkflow(sub_context.head).get_state(sub_context.status)
def get_head_object_state_rpm(sub_context): """IRolePermissionMap(context) adapter factory. Lighweight and high-performance wrapper on get_object_state(context), to *lookup* (note: no creation of any instance) the workflow.states.State singleton instance for the sub context's head's status. Note that sub context is NOT workflowed. On lookup error, returns NONE_STATE_RPM, instead of what would be a zope.component.ComponentLookupError. """ # !+HEAD_DOCUMENT_ITEM(mr, sep-2011) standardize name, "head", "document" # or "item"? try: return interfaces.IWorkflow(sub_context.head).get_state( sub_context.status) except interfaces.InvalidStateError, e: return NONE_STATE_RPM
def workflow(self): """ () -> bungeni.core.workflow.states.Workflow """ return interfaces.IWorkflow(self.context)