Changeset 17763


Ignore:
Timestamp:
11 May 2024, 19:55:45 (4 months ago)
Author:
Henrik Bettermann
Message:

DocumentProcessorBase?: import state and history

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/documents/batching.py

    r13145 r17763  
    2424import unicodecsv as csv  # XXX: csv ops should move to dedicated module.
    2525from time import time
     26from ast import literal_eval
    2627from datetime import datetime
    2728from zope.i18n import translate
     
    3233from zope.catalog.interfaces import ICatalog
    3334from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
    34 from waeup.kofa.interfaces import (
     35from waeup.kofa.interfaces import (IObjectHistory,
    3536    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount,
    3637    IGNORE_MARKER)
     
    6364
    6465    location_fields = ['document_id',]
    65     additional_fields = ['class_name',]
     66    additional_fields = ['class_name', 'state', 'history']
    6667
    6768    factory_name = None
     
    114115        items_changed = super(DocumentProcessorBase, self).updateEntry(
    115116            obj, row, site, filename)
     117        # Replace entire history
     118        if 'history' in row:
     119            new_history = row.get('history', IGNORE_MARKER)
     120            if new_history not in (IGNORE_MARKER, ''):
     121                history = IObjectHistory(obj)
     122                history._annotations[
     123                    history.history_key] = literal_eval(new_history)
     124                items_changed += ('%s=%s, ' % ('history', new_history))
     125            row.pop('history')
     126        # Update state
     127        if 'state' in row:
     128            state = row.get('state', IGNORE_MARKER)
     129            if state not in (IGNORE_MARKER, ''):
     130                IWorkflowState(obj).setState(state)
     131                msg = _("State '${a}' set", mapping = {'a':state})
     132                history = IObjectHistory(obj)
     133                history.addMessage(msg)
     134                items_changed += ('%s=%s, ' % ('state', state))
     135            row.pop('state')
    116136        # Log actions...
    117137        location_field = self.location_fields[0]
Note: See TracChangeset for help on using the changeset viewer.