# get workflow assigned in portal types: for workflow_id in portal_type_workflow_list: workflow_value = self._getOb(workflow_id, None) if workflow_value is not None: workflow_list.append(workflow_value) else: LOG( "WorkflowTool", WARNING, "getWorkflowValueListFor: workflow %s declared on portal_type %s " "does not exist" % (workflow_id, portal_type.getId())) return workflow_list # WITH_LEGACY_WORKFLOW getWorkflowsFor = deprecated( "getWorkflowsFor() is deprecated; use getWorkflowValueListFor() instead" )(getWorkflowValueListFor) @deprecated( "getChainFor() is deprecated; use getWorkflowValueListFor() instead") def getChainFor(self, ob): return [wf.getId() for wf in self.getWorkflowValueListFor(ob)] @staticmethod def getHistoryOf(wf_id, ob): """ Get the history of an object for a given workflow. """ if hasattr(aq_base(ob), 'workflow_history'): return ob.workflow_history.get(wf_id, None) return ()
class WorkflowTool(BaseTool, OriginalWorkflowTool): """ A new container for DC workflow and workflow; inherits methods from original WorkflowTool.py; contains patches from ERP5Type/patches/WorkflowTool.py. """ id = 'portal_workflow' title = 'Workflow Tool' meta_type = 'Workflow Tool' portal_type = 'Workflow Tool' allowed_types = ('Workflow', 'Interaction Workflow') security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) property_sheets = ( 'Base', 'XMLObject', 'CategoryCore', 'DublinCore', ) def _isBootstrapRequired(self): """ Required by synchronizeDynamicModules() to bootstrap an empty site and thus create portal_components """ return False def _bootstrap(self): """ Required by synchronizeDynamicModules() to bootstrap an empty site and thus create portal_components """ pass def filtered_meta_types(self, user=None): return False def _jumpToStateFor(self, ob, state_id, wf_id=None, *_, **__): """Inspired from doActionFor. This is public method to allow passing meta transition (Jump form any state to another in same workflow) """ from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition from Products.ERP5Type.Core.InteractionWorkflow import InteractionWorkflow workflow_list = self.getWorkflowValueListFor(ob.getPortalType()) if wf_id is None: if not workflow_list: raise WorkflowException('No workflows found.') found = False for workflow in workflow_list: if not isinstance(workflow, (InteractionWorkflowDefinition, InteractionWorkflow,)) and \ state_id in workflow.getStateReferenceList(): found = True break if not found: raise WorkflowException('No workflow provides the destination state %r'\ % state_id) else: workflow = self._getOb(wf_id, None) if workflow is None: raise WorkflowException( 'Requested workflow definition not found.') workflow._executeMetaTransition(ob, state_id) def _isJumpToStatePossibleFor(self, ob, state_id, wf_id=None): """Test if given state_id is available for ob in at least one associated workflow """ from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition from Products.ERP5Type.Core.InteractionWorkflow import InteractionWorkflow for workflow in (wf_id and (self[wf_id], ) or self.getWorkflowValueListFor(ob.getPortalType())): if not isinstance( workflow, (InteractionWorkflowDefinition, InteractionWorkflow)): if state_id in workflow.getStateReferenceList(): return True return False security.declarePrivate('getCatalogVariablesFor') def getCatalogVariablesFor(self, ob): """ Get a mapping of "workflow-relevant" attributes. original code from zope CMFCore/WorkflowTool.py """ wfs = self.getWorkflowValueListFor(ob) if wfs is None: return None # Iterate through the workflows backwards so that # earlier workflows can override later workflows. wfs.reverse() variable_dict = {} for wf in wfs: v = wf.getCatalogVariablesFor(ob) if v is not None: variable_dict.update(v) return variable_dict def _invokeWithNotification(self, wfs, ob, action, func, args, kw): """ Private utility method: call 'func', and deal with exceptions indicating that the object has been deleted or moved. """ from zope.event import notify from Products.CMFCore.WorkflowCore import ActionRaisedExceptionEvent from Products.CMFCore.WorkflowCore import ActionSucceededEvent from Products.CMFCore.WorkflowCore import ActionWillBeInvokedEvent from Products.CMFCore.WorkflowCore import ObjectDeleted from Products.CMFCore.WorkflowCore import ObjectMoved from Products.CMFCore.WorkflowCore import WorkflowException reindex = 1 for w in wfs: w.notifyBefore(ob, action) notify(ActionWillBeInvokedEvent(ob, w, action)) try: res = func(*args, **kw) except ObjectDeleted as ex: res = ex.getResult() reindex = 0 except ObjectMoved as ex: res = ex.getResult() ob = ex.getNewObject() except: import sys exc = sys.exc_info() try: for w in wfs: w.notifyException(ob, action, exc) notify(ActionRaisedExceptionEvent(ob, w, action, exc)) reraise(*exc) finally: exc = None for w in wfs: w.notifySuccess(ob, action, res) notify(ActionSucceededEvent(ob, w, action, res)) if reindex: self._reindexWorkflowVariables(ob) return res security.declarePublic('doActionFor') def doActionFor(self, ob, action, wf_id=None, *args, **kw): workflow_id = wf_id workflow_list = self.getWorkflowValueListFor(ob.getPortalType()) if workflow_id is None: if not workflow_list: raise WorkflowException(Message(u'No workflows found.')) for workflow in workflow_list: is_action_supported = workflow.isActionSupported( ob, action, **kw) if is_action_supported: kw['is_action_supported'] = is_action_supported break else: raise WorkflowException( Message(u"No workflow provides the '${action_id}' action.", mapping={'action_id': action})) else: workflow = self._getOb(workflow_id, None) if workflow is None: raise WorkflowException( Message(u'Requested workflow not found.')) return self._invokeWithNotification(workflow_list, ob, action, workflow.doActionFor, (ob, action) + tuple(args), kw) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowValueListFor') def getWorkflowValueListFor(self, ob): """ Return a list of workflows bound to selected object, this workflow list may contain both DC Workflow and Workflow. """ workflow_list = [] if isinstance(ob, basestring): portal_type = self.getPortalObject().portal_types.getTypeInfo(ob) elif hasattr(aq_base(ob), 'getTypeInfo'): portal_type = ob.getTypeInfo() else: portal_type = None portal_type_workflow_list = tuple() if portal_type is not None: portal_type_workflow_list = portal_type.getTypeWorkflowList() # get workflow assigned in portal types: for workflow_id in portal_type_workflow_list: workflow_value = self._getOb(workflow_id, None) if workflow_value is not None: workflow_list.append(workflow_value) else: LOG( "WorkflowTool", WARNING, "getWorkflowValueListFor: workflow %s declared on portal_type %s " "does not exist" % (workflow_id, portal_type.getId())) return workflow_list # WITH_LEGACY_WORKFLOW getWorkflowsFor = deprecated( "getWorkflowsFor() is deprecated; use getWorkflowValueListFor() instead" )(getWorkflowValueListFor) @deprecated( "getChainFor() is deprecated; use getWorkflowValueListFor() instead") def getChainFor(self, ob): return [wf.getId() for wf in self.getWorkflowValueListFor(ob)] @staticmethod def getHistoryOf(wf_id, ob): """ Get the history of an object for a given workflow. """ if hasattr(aq_base(ob), 'workflow_history'): return ob.workflow_history.get(wf_id, None) return () @staticmethod def getScriptPathList(workflow, initial_script_name_list): if not initial_script_name_list: return [] script_path_list = [] if isinstance(initial_script_name_list, str): initial_script_name_list = [initial_script_name_list] for script_name in initial_script_name_list: if script_name: script = getattr(workflow, workflow.getScriptIdByReference(script_name), None) or \ getattr(workflow, workflow.getTransitionIdByReference(script_name), None) if script is not None: script_path_list.append(script.getRelativeUrl()) return script_path_list _reindexWorkflowVariables = lambda self, ob: \ hasattr(aq_base(ob), 'reindexObjectSecurity') and ob.reindexObjectSecurity() security.declarePublic('isTransitionPossible') def isTransitionPossible(self, ob, transition_id, wf_id=None): """Test if the given transition exist from the current state. """ for workflow in (wf_id and (self[wf_id], ) or self.getWorkflowValueListFor(ob)): state = workflow._getWorkflowStateOf(ob) if state and transition_id in state.getDestinationReferenceList(): return True return False getFutureStateSetFor = lambda self, wf_id, *args, **kw: \ self[wf_id].getFutureStateSet(*args, **kw) security.declarePrivate('getStatusOf') def getStatusOf(self, workflow_id, current_object): # code taken from CMFCore """ Get the last element of a workflow history for a given workflow. """ workflow_history = self.getHistoryOf(workflow_id, current_object) if workflow_history: return workflow_history[-1] return None def setStatusOf(self, wf_id, ob, status): """ Append an entry to the workflow history. o Invoked by workflow definitions. """ from Products.ERP5Type.Workflow import WorkflowHistoryList as NewWorkflowHistoryList wfh = None has_history = 0 if getattr(aq_base(ob), 'workflow_history', None) is not None: history = ob.workflow_history if history is not None: has_history = 1 wfh = history.get(wf_id, None) if wfh is not None and not isinstance(wfh, NewWorkflowHistoryList): wfh = NewWorkflowHistoryList(wfh) ob.workflow_history[wf_id] = wfh if wfh is None: wfh = NewWorkflowHistoryList() if not has_history: ob.workflow_history = PersistentMapping() ob.workflow_history[wf_id] = wfh wfh.append(status) security.declareProtected(Permissions.ManagePortal, 'refreshWorklistCache') def refreshWorklistCache(self): """ Refresh worklist cache table. - delete everything from that table - if it fails, create the table - insert new lines - if it fails, recrete the table and retry """ # Contrary to WorkflowTool_listActions, related keys are NOT supported. Base_zInsertIntoWorklistTable = getattr( self, 'Base_zInsertIntoWorklistTable', None) if Base_zInsertIntoWorklistTable is not None: # XXX: Code below is duplicated from WorkflowTool_listActions info = self._getOAI(None) worklist_dict = {} wf_ids = self.objectIds() for wf_id in wf_ids: wf = self._getOb(wf_id, None) if wf is not None: a = wf.getWorklistVariableMatchDict(info, check_guard=False) if a is not None: worklist_dict[wf_id] = a # End of duplicated code if len(worklist_dict): Base_zClearWorklistTable = getattr(self, 'Base_zClearWorklistTable', None) if Base_zClearWorklistTable is None: LOG('WorkflowTool', WARNING, 'Base_zClearWorklistTable cannot be found. ' \ 'Falling back to former refresh method. Please update ' \ 'erp5_worklist_sql business template.') self.Base_zCreateWorklistTable() else: try: self.Base_zClearWorklistTable() except ProgrammingError as error_value: # 1146 = table does not exist if error_value[0] != 1146: raise self.Base_zCreateWorklistTable() portal_catalog = self.getPortalObject().portal_catalog search_result = portal_catalog.unrestrictedSearchResults sql_catalog = portal_catalog.getSQLCatalog() table_column_id_set = frozenset( [COUNT_COLUMN_TITLE] + self.Base_getWorklistTableColumnIDList()) security_column_id_list = list( sql_catalog.getSQLCatalogSecurityUidGroupsColumnsDict().values()) + \ [x[1] for x in sql_catalog.getSQLCatalogRoleKeysList()] + \ [x[1] for x in sql_catalog.getSQLCatalogLocalRoleKeysList()] security_column_id_set = set(security_column_id_list) assert len(security_column_id_set) == len( security_column_id_list), (security_column_id_set, security_column_id_list) del security_column_id_list security_column_id_set.difference_update( self._getWorklistIgnoredSecurityColumnSet()) for security_column_id in security_column_id_set: assert security_column_id in table_column_id_set (worklist_list_grouped_by_condition, worklist_metadata) = \ groupWorklistListByCondition( worklist_dict=worklist_dict, sql_catalog=sql_catalog) assert COUNT_COLUMN_TITLE in table_column_id_set for grouped_worklist_dict in worklist_list_grouped_by_condition: # Generate the query for this worklist_list (total_criterion_id_list, query) = \ getWorklistListQuery( getQuery=SimpleQuery, grouped_worklist_dict=grouped_worklist_dict, ) for criterion_id in total_criterion_id_list: assert criterion_id in table_column_id_set for security_column_id in security_column_id_set: assert security_column_id not in total_criterion_id_list total_criterion_id_list.append(security_column_id) group_by = total_criterion_id_list assert COUNT_COLUMN_TITLE not in total_criterion_id_list select_dict = dict.fromkeys(total_criterion_id_list) select_dict[COUNT_COLUMN_TITLE] = 'count(*)' search_result_kw = { 'select_dict': select_dict, 'group_by': group_by, 'query': query, 'limit': None, } #LOG('refreshWorklistCache', WARNING, 'Using query: %s' % \ # (search_result(src__=1, **search_result_kw), )) catalog_brain_result = search_result(**search_result_kw) value_column_dict = {x: [] for x in table_column_id_set} for catalog_brain_line in catalog_brain_result.dictionaries( ): for column_id, value in six.iteritems( catalog_brain_line): if column_id in value_column_dict: value_column_dict[column_id].append(value) if len(value_column_dict[COUNT_COLUMN_TITLE]): try: Base_zInsertIntoWorklistTable(**value_column_dict) except (ProgrammingError, OperationalError) as error_value: # OperationalError 1054 = unknown column if isinstance(error_value, OperationalError ) and error_value[0] != 1054: raise LOG('WorkflowTool', WARNING, 'Insertion in worklist cache table ' \ 'failed. Recreating table and retrying.', error=True) self.Base_zCreateWorklistTable() Base_zInsertIntoWorklistTable(**value_column_dict) def _getWorklistIgnoredSecurityColumnSet(self): return getattr(self, 'Base_getWorklistIgnoredSecurityColumnSet', lambda: ())() def listActions(self, info=None, object=None, src__=False): """ Returns a list of actions to be displayed to the user. o Invoked by the portal_actions tool. o Allows workflows to include actions to be displayed in the actions box. o Object actions are supplied by workflows that apply to the object. o Global actions are supplied by all workflows. This patch attemps to make listGlobalActions aware of worklists, which allows factorizing them into one single SQL query. Related keys are supported. Warning: the worklist cache does not support them. """ if object is not None or info is None: info = self._getOAI(object) actions = [] portal = self.getPortalObject() developer_mode_enabled = portal.portal_preferences.getPreferredHtmlStyleDevelopperMode( ) if info.object is not None: object_portal_type = info.object.getTypeInfo() if object_portal_type is not None: for wf_id in object_portal_type.getTypeWorkflowList(): wf = self._getOb(wf_id, None) if wf is not None: if developer_mode_enabled: actions.append({ "id": "onlyjio_%s" % wf.getReference(), "name": wf.getTitle(), "url": "%s/Base_redirectToWorkflowDocument?workflow_id=%s" % (wf.absolute_url(), wf.getId()), "icon": None, "category": "object_onlyjio_jump", "priority": 100 }) actions.extend(wf.listObjectActions(info)) portal_url = portal.portal_url() def _getWorklistActionList(): worklist_dict = {} for wf in self.objectValues(): if wf is not None: a = wf.getWorklistVariableMatchDict(info) if a is not None: worklist_dict[wf.getId()] = a if not worklist_dict: return () is_anonymous = portal.portal_membership.isAnonymousUser() portal_catalog = portal.portal_catalog sql_catalog = portal_catalog.getSQLCatalog() catalog_security_uid_groups_columns_dict = \ sql_catalog.getSQLCatalogSecurityUidGroupsColumnsDict() getSecurityUidDictAndRoleColumnDict = \ portal_catalog.getSecurityUidDictAndRoleColumnDict search_result_ = getattr(self, "Base_getCountFromWorklistTable", None) use_cache = search_result_ is not None if use_cache: ignored_security_column_id_set = self._getWorklistIgnoredSecurityColumnSet( ) ignored_security_uid_parameter_set = { x for x, y in six.iteritems( catalog_security_uid_groups_columns_dict) if y in ignored_security_column_id_set } _getSecurityUidDictAndRoleColumnDict = getSecurityUidDictAndRoleColumnDict def getSecurityUidDictAndRoleColumnDict(**kw): security_uid_dict, role_column_dict, local_role_column_dict = \ _getSecurityUidDictAndRoleColumnDict(**kw) for ignored_security_column_id in ignored_security_column_id_set: role_column_dict.pop(ignored_security_column_id, None) local_role_column_dict.pop(ignored_security_column_id, None) for ignored_security_uid_parameter in \ ignored_security_uid_parameter_set: security_uid_dict.pop(ignored_security_uid_parameter) return security_uid_dict, role_column_dict, local_role_column_dict count_column_expression = 'sum(`%s`)' % (COUNT_COLUMN_TITLE, ) # Prevent catalog from trying to join getQuery = SimpleQuery # BBB def search_result(select_dict, group_by, query, limit, src__): select_item_list = [] for alias, expression in six.iteritems(select_dict): if expression is None: expression = alias select_item_list.append('%s AS %s' % (expression, alias)) return search_result_( select_expression=','.join(select_item_list), group_by_expression=','.join(group_by), query=query, limit=limit, src__=src__, ) else: search_result = portal_catalog.unrestrictedSearchResults count_column_expression = 'count(*)' # Let catalog join as needed getQuery = lambda comparison_operator=None, **kw: AutoQuery( operator=comparison_operator, **kw) worklist_result_dict = {} # Get a list of dict of WorklistVariableMatchDict grouped by compatible # conditions (worklist_list_grouped_by_condition, worklist_metadata) = \ groupWorklistListByCondition( worklist_dict=worklist_dict, sql_catalog=sql_catalog, getSecurityUidDictAndRoleColumnDict=\ getSecurityUidDictAndRoleColumnDict, catalog_security_uid_groups_columns_dict=\ catalog_security_uid_groups_columns_dict, ) if src__: action_list = [] for grouped_worklist_dict in worklist_list_grouped_by_condition: # Generate the query for this worklist_list (total_criterion_id_list, query) = \ getWorklistListQuery( getQuery=getQuery, grouped_worklist_dict=grouped_worklist_dict, ) group_by = total_criterion_id_list assert COUNT_COLUMN_TITLE not in total_criterion_id_list select_dict = dict.fromkeys(total_criterion_id_list) select_dict[COUNT_COLUMN_TITLE] = count_column_expression catalog_brain_result = [] try: catalog_brain_result = search_result( select_dict=select_dict, group_by=group_by, query=query, limit=None, src__=src__) except Unauthorized: if not is_anonymous: raise LOG('WorkflowTool.listActions', WARNING, 'Exception while computing worklists: %s' % grouped_worklist_dict.keys(), error=True) continue except ProgrammingError as error_value: # 1146 = table does not exist if not use_cache or error_value[0] != 1146: raise try: self.Base_zCreateWorklistTable() except ProgrammingError as error_value: # 1050 = table exists (alarm run just a bit too late) if error_value[0] != 1050: raise if src__: action_list.append(catalog_brain_result) else: grouped_worklist_result = sumCatalogResultByWorklist( grouped_worklist_dict=grouped_worklist_dict, catalog_result=catalog_brain_result) for key, value in six.iteritems(grouped_worklist_result): worklist_result_dict[ key] = value + worklist_result_dict.get(key, 0) if not src__: action_list = sorted( generateActionList(worklist_metadata=worklist_metadata, worklist_result=worklist_result_dict, portal_url=portal_url), key=lambda x: '/'.join( (x['workflow_id'], x['worklist_id'])), ) return action_list if src__: actions = _getWorklistActionList() else: actions.extend( CachingMethod( _getWorklistActionList, id=( '_getWorklistActionList', _getAuthenticatedUser(self).getIdOrUserName(), portal_url, ), cache_factory='erp5_ui_short', )()) return actions
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## from Products.ERP5Type.Utils import deprecated import json deprecated = deprecated("'%s.encodeInJson' is deprecated; use 'json.dumps' instead." % __name__) encodeInJson = deprecated(json.dumps)
for property_id in script_prop_id_to_show: if property_id == 'proxy_roles': property_value = tuple(sdef.getProperty('proxy_role_list')) property_type = sdef.getPropertyType('proxy_role_list') else: property_value = sdef.getProperty(property_id) property_type = sdef.getPropertyType(property_id) sub_object = SubElement(script, property_id, attrib=dict(type=property_type)) if property_value is None or property_value == [] or property_value == (): property_value = '' sub_object.text = str(property_value) # return xml object if return_as_object: return root return etree.tostring(root, encoding='utf-8', xml_declaration=True, pretty_print=True) from Products.ERP5Type import WITH_LEGACY_WORKFLOW if WITH_LEGACY_WORKFLOW: from Products.ERP5Type.Utils import deprecated from ComputedAttribute import ComputedAttribute from Products.ERP5Type.Core.Workflow import _ContainerTab InteractionWorkflow.interactions = ComputedAttribute( deprecated('`interactions` is deprecated; use getTransitionValueList()')\ (lambda self: _ContainerTab(self, self.getTransitionValueList())), 1) # must be Acquisition-wrapped InteractionWorkflow.security.declareProtected(Permissions.AccessContentsInformation, 'interactions')
cache_factory='erp5_ui_short', )()) return actions from Products.ERP5Type import WITH_LEGACY_WORKFLOW if WITH_LEGACY_WORKFLOW: # DCWorkflow copy/paste: WorkflowTool inherits from but CMFCore.WorkflowTool, # ObjectManager ends up before IFAwareObjectManager in mro()... from OFS.ObjectManager import IFAwareObjectManager WorkflowTool.all_meta_types = IFAwareObjectManager.all_meta_types # CMFCore methods checking that Workflows implement IWorkflowDefinition, not # implemented by ERP5 Workflow WorkflowTool.getWorkflowIds = \ deprecated('getWorkflowIds() is deprecated; use objectIds()')\ (lambda self: self.objectIds()) WorkflowTool.security.declarePrivate('getWorkflowIds') WorkflowTool.getWorkflowById = \ deprecated('getWorkflowById() is deprecated')\ (lambda self, wf_id: self._getOb(wf_id, None)) WorkflowTool.security.declarePrivate('getWorkflowById') InitializeClass(WorkflowTool) class ExclusionList(list): """ This is a dummy subclass of list. It is only used to detect wether contained values must be negated. It is not to be used outside of the scope of this document nor outside of the scope of worklist criterion handling.
'getAvailableTypeList') def getAvailableTypeList(self): """ This is a method specific to ERP5. This returns a list of state types, which are used for portal methods. """ return ('draft_order', 'planned_order', 'future_inventory', 'reserved_inventory', 'transit_inventory', 'current_inventory') from Products.ERP5Type import WITH_LEGACY_WORKFLOW if WITH_LEGACY_WORKFLOW: from Products.ERP5Type.Utils import deprecated WorkflowState.getTransitions = \ deprecated('getTransitions() is deprecated; use getDestinationIdList()')\ (lambda self: self.getDestinationIdList()) WorkflowState.security.declareProtected( Permissions.AccessContentsInformation, 'getTransitions') from ComputedAttribute import ComputedAttribute WorkflowState.transitions = ComputedAttribute( deprecated('`transitions` is deprecated; use getDestinationValueList()')\ (WorkflowState.getDestinationIdList), 1) # must be Acquisition-wrapped WorkflowState.security.declareProtected( Permissions.AccessContentsInformation, 'transitions') InitializeClass(WorkflowState)
return None security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionVariableValueList') def getTransitionVariableValueList(self): """ Return Transition Variables """ return self.objectValues(portal_type='Workflow Transition Variable') from Products.ERP5Type import WITH_LEGACY_WORKFLOW if WITH_LEGACY_WORKFLOW: from Products.ERP5Type.Utils import deprecated from ComputedAttribute import ComputedAttribute WorkflowTransition.actbox_url = ComputedAttribute( deprecated('`actbox_url` is deprecated; use getAction()')\ (lambda self: self.getAction())) WorkflowTransition.security.declareProtected( Permissions.AccessContentsInformation, 'actbox_url') WorkflowTransition.actbox_name = ComputedAttribute( deprecated('`actbox_name` is deprecated; use getActionName()')\ (lambda self: self.getActionName())) WorkflowTransition.security.declareProtected( Permissions.AccessContentsInformation, 'actbox_name') InitializeClass(WorkflowTransition)
'getActionType') def getActionType(self): prefix_length = len('action_type/') action_type_list = [ path[prefix_length:] for path in self.getCategoryList() if path.startswith('action_type/') ] try: return action_type_list[0] except IndexError: return None from Products.ERP5Type import WITH_LEGACY_WORKFLOW if WITH_LEGACY_WORKFLOW: Worklist.security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatchKeys') Worklist.getVarMatchkeys = \ deprecated('getVarMatchKeys() deprecated; use getCriterionPropertyList()')\ (lambda self: self.getCriterionPropertyList()) Worklist.security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatch') Worklist.getVarMatch = \ deprecated('getVarMatch() deprecated; use getIdentityCriterionDict()')\ (lambda self, id: tuple(self._identity_criterion.get(id, ()))) from Products.ERP5Type.Globals import InitializeClass InitializeClass(Worklist)
# # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## from Products.ERP5Type.Utils import deprecated import json deprecated = deprecated( "'%s.encodeInJson' is deprecated; use 'json.dumps' instead." % __name__) encodeInJson = deprecated(json.dumps)
# programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## """A wrapper module for simplejson or json.""" from Products.ERP5Type.Utils import deprecated import json deprecated = deprecated("%r is deprecated; use 'json' instead." % __name__) dumps = deprecated(json.dumps) loads = deprecated(json.loads)