parameters: (self, document=None, xml=None, previous_xml=None, **kw)
return_statement: return conflict_list
docstring: This method is called in updateNode and allows to add elements.
docstring_summary: This method is called in updateNode and allows to add elements.
docstring_tokens: This method is called in updateNode and allows to add elements .
function: def _updateXupdateInsertOrAdd(self, document=None, xml=None, previous_xml=None, **kw):
      """ This method is called in updateNode and allows to add elements. """
      conflict_list = []
      keyword = {}
      mapping_list = []
      category_dict = self._getCategoryDict(resource=document)
      # browse subnode of the insert and check what will be create
      for subnode in xml.getchildren():
        new_tag = subnode.attrib['name']
        new_value = subnode.text
        if new_tag == 'category':
          # init base category, variation and boolean which check update
          base_category, variation = new_value.split('/', 1)
          updated = False
  
          # check first in shared variations
          shared_variation_list = document.getVariationCategoryList()
          if new_value not in shared_variation_list:
            # set variation if it's an existing shared variation, else
            # it's an individual
            base_category_object = document.portal_categories[base_category]
            if getattr(base_category_object, variation, None) is not None:
              updated = True
              shared_variation_list.append(new_value)
              document.setVariationCategoryList(shared_variation_list)
          # if no update has occured, check in individual variations
          if not updated and \
              new_value not in document.getVariationCategoryList():
            # individual variation list filtered on base_category
            individual_variation = [individual
                for individual in document.contentValues(
                  portal_type='Product Individual Variation',
                )
                if individual.getTitle() == variation and \
                    individual.getVariationBaseCategoryList() == \
                    [base_category, ]
            ]
            if not individual_variation: # empty list
              new_variation = document.newContent(
                  portal_type='Product Individual Variation',
                  title=variation,
              )
              new_variation.setVariationBaseCategoryList([base_category, ])
        elif new_tag == "mapping":
          # build mapping list here
          mapping_dict = {'category' : [],}
          for item in subnode.getchildren():
            # Build the tag (without is Namespace)
            tag = item.tag
            if tag == "category":
              # Retrieve the category path
              mapping_dict['category'].append(category_dict[item.text.encode('utf-8')])
            else:
              mapping_dict[tag] = item.text.encode('utf-8')
          mapping_list.append(mapping_dict)
        else:
          if len(subnode.getchildren()):
            raise NotImplementedError
          keyword[new_tag] = new_value
          self.editDocument(object=document, **keyword)
        if len(mapping_list):
          conflict_list = self._createMapping(document, mapping_list)
          for cell, current_value, new_value in conflict_list:
            conflict_list.append(self._generateConflict(cell.getPhysicalPath(),
                                                        'mapping',
                                                        etree.tostring(xml, encoding='utf-8'),
                                                        current_value,
                                                        new_value,
                                                        kw['signature']))
  
      return conflict_list
function_tokens: def _updateXupdateInsertOrAdd ( self , document = None , xml = None , previous_xml = None , * * kw ) : conflict_list = [ ] keyword = { } mapping_list = [ ] category_dict = self . _getCategoryDict ( resource = document ) # browse subnode of the insert and check what will be create for subnode in xml . getchildren ( ) : new_tag = subnode . attrib [ 'name' ] new_value = subnode . text if new_tag == 'category' : # init base category, variation and boolean which check update base_category , variation = new_value . split ( '/' , 1 ) updated = False # check first in shared variations shared_variation_list = document . getVariationCategoryList ( ) if new_value not in shared_variation_list : # set variation if it's an existing shared variation, else # it's an individual base_category_object = document . portal_categories [ base_category ] if getattr ( base_category_object , variation , None ) is not None : updated = True shared_variation_list . append ( new_value ) document . setVariationCategoryList ( shared_variation_list ) # if no update has occured, check in individual variations if not updated and new_value not in document . getVariationCategoryList ( ) : # individual variation list filtered on base_category individual_variation = [ individual for individual in document . contentValues ( portal_type = 'Product Individual Variation' , ) if individual . getTitle ( ) == variation and individual . getVariationBaseCategoryList ( ) == [ base_category , ] ] if not individual_variation : # empty list new_variation = document . newContent ( portal_type = 'Product Individual Variation' , title = variation , ) new_variation . setVariationBaseCategoryList ( [ base_category , ] ) elif new_tag == "mapping" : # build mapping list here mapping_dict = { 'category' : [ ] , } for item in subnode . getchildren ( ) : # Build the tag (without is Namespace) tag = item . tag if tag == "category" : # Retrieve the category path mapping_dict [ 'category' ] . append ( category_dict [ item . text . encode ( 'utf-8' ) ] ) else : mapping_dict [ tag ] = item . text . encode ( 'utf-8' ) mapping_list . append ( mapping_dict ) else : if len ( subnode . getchildren ( ) ) : raise NotImplementedError keyword [ new_tag ] = new_value self . editDocument ( object = document , * * keyword ) if len ( mapping_list ) : conflict_list = self . _createMapping ( document , mapping_list ) for cell , current_value , new_value in conflict_list : conflict_list . append ( self . _generateConflict ( cell . getPhysicalPath ( ) , 'mapping' , etree . tostring ( xml , encoding = 'utf-8' ) , current_value , new_value , kw [ 'signature' ] ) ) return conflict_list