Changeset 1452 in products


Ignore:
Timestamp:
Dec 8, 2009 10:52:48 AM (14 years ago)
Author:
piv
Message:

merge 2390 revision from trunk: multiple workflows in object history now can be imported

Location:
quintagroup.transmogrifier/branches/plone-2.1/quintagroup.transmogrifier
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.transmogrifier/branches/plone-2.1/quintagroup.transmogrifier

    • Property svn:mergeinfo changed from /quintagroup.transmogrifier/trunk:1447-1448 to /quintagroup.transmogrifier/trunk:1447-1448,1451
  • quintagroup.transmogrifier/branches/plone-2.1/quintagroup.transmogrifier/quintagroup/transmogrifier/namespaces/cmfns.py

    r1413 r1452  
    1414     
    1515    def processXml(self, context, node): 
    16         tag, namespace = utils.fixtag(node.tag,context.ns_map) 
    1716        nsprefix = node.tag[:node.tag.find('}')+1] 
    1817        local_roles = node.findall(nsprefix+self.name) 
     
    2827         
    2928        return True 
     29 
     30class WorkflowAttribute(base.WorkflowAttribute): 
    3031     
     32    def processXml(self, context, node): 
     33        data = context.getDataFor(self.namespace.xmlns) 
     34        wf_data = data.setdefault(self.name, {}) 
     35        nsprefix = node.tag[:node.tag.find('}')+1] 
     36 
     37        for wf_node in node.findall(nsprefix+'workflow'): 
     38            # workflow 
     39            wf_id = wf_node.attrib.get(nsprefix+'id') or \ 
     40                    wf_node.attrib.get('id') 
     41            if wf_id is None: 
     42                continue 
     43 
     44            # history 
     45            wf = wf_data.setdefault(wf_id, []) 
     46            hist_nodes = wf_node.findall(nsprefix+'history') 
     47            for hist_node in hist_nodes: 
     48                record = {} 
     49                wf.append(record) 
     50 
     51                #var 
     52                var_nodes = hist_node.findall(nsprefix+'var') 
     53                vid = vtype = value = None 
     54 
     55                for var_node in var_nodes: 
     56                    vid = var_node.attrib.get(nsprefix+'id') or \ 
     57                          var_node.attrib.get('id') 
     58                    vtype = var_node.attrib.get(nsprefix+'type',None) or \ 
     59                            var_node.attrib.get('type') 
     60                    value = var_node.attrib.get(nsprefix+'value',None) or \ 
     61                            var_node.attrib.get('value') or '' 
     62 
     63                    if not (vid and vtype and value is not None): 
     64                        continue 
     65 
     66                    value = base.demarshall_value(value, vtype) 
     67                    record[vid] = value 
     68 
     69        return True 
     70 
    3171class CMF(base.CMF): 
    3272     
    3373    attributes = ( 
    3474        base.TypeAttribute('type'), 
    35         base.WorkflowAttribute('workflow_history '), 
     75        WorkflowAttribute('workflow_history'), 
    3676        LocalRolesAttribute('local_role') 
    3777        ) 
Note: See TracChangeset for help on using the changeset viewer.