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 work on the update of
        elements.
docstring_summary: This method is called in updateNode and allows to work on the update of
        elements.
docstring_tokens: This method is called in updateNode and allows to work on the update of elements .
function: def _updateXupdateUpdate(self, document=None, xml=None, previous_xml=None, **kw):
      """
        This method is called in updateNode and allows to work on the update of
        elements.
      """
      conflict_list = []
      xpath_expression = xml.get('select')
      tag_list = xpath_expression.split('/')
  
      base_tag = None
      remaining_tag_list = []
      for tag in tag_list:
        if not len(tag) or tag == "resource":
          continue
        elif base_tag is None:
          base_tag = tag
        else:
          remaining_tag_list.append(tag)
  
      new_value = xml.text
      keyword = {}
  
      # retrieve the previous xml etree through xpath
      previous_xml = previous_xml.xpath(xpath_expression)
      try:
        previous_value = previous_xml[0].text
      except IndexError:
        raise IndexError(
            'Too little or too many value, only one is required for %s'
            % previous_xml
        )
  
      if isinstance(previous_value, unicode):
        previous_value = previous_value.encode('utf-8')
  
      if isinstance(new_value, unicode):
        new_value = new_value.encode('utf-8')
  
      # check if it'a work on product or on categories
      if base_tag.startswith('category'):
        # init base category, variation and boolean which check update
        base_category, variation = new_value.split('/', 1)
        old_base_category, old_variation = previous_value.split('/', 1)
        # retrieve the base_categories and the variations
        base_category_list = document.getVariationBaseCategoryList()
        variation_list = document.getVariationCategoryList()
  
        # about shared and individual variations, it's necessary to check the
        # mapping existency
        shared_variation = True
        try:
          # Try to access the category
          document.getPortalObject().portal_categories.restrictedTraverse(new_value)
        except KeyError:
          # This is an individual variation
          shared_variation = False
  
        # the mapping of an element must only be defined one time
        individual_variation = document.searchFolder(
            portal_type='Product Individual Variation',
            title=old_variation,
            base_category=old_base_category,
        )
        # If this is badly defined, fix the objects
        if len(individual_variation) > 1:
          id_to_remove = []
          for individual in individual_variation[1:]:
            id_to_remove.append(individual.getId())
          document.manage_delObjects(id_to_remove)
        if len(individual_variation) and previous_value in variation_list:
          for individual in individual_variation:
            id_to_remove.append(individual.getId())
          document.manage_delObjects(id_to_remove)
  
        # Update variation
        if not shared_variation:
          # work on the cases :
          # new = individual variation
          #   old = individual variation -> update
          #   old = shared variation -> remoce shared and add individual
  
          # Fist check individual base
          if base_category not in document.getIndividualVariationBaseCategoryList():
            base_category_list = document.getIndividualVariationBaseCategoryList()
            base_category_list.append(base_category)
            document.setIndividualVariationBaseCategoryList(base_category_list)
            self.updateSystemPreference(document.getPortalObject(), base_category, True)
  
          # Then update or add variation
          if len(individual_variation):
            individual_variation = individual_variation[0].getObject()
            individual_variation.setTitle(variation)
            individual_variation.setVariationBaseCategory(base_category)
          else:
            # create the individual variation
            document.newContent(
                portal_type='Product Individual Variation',
                title=variation,
                base_category=base_category,
            )
        else:
          # work on the cases :
          # new = shared variation
          #   old = individual variation -> remove individual and add shared
          #   old = shared variation -> update shared
          if len(individual_variation):
            # remove individual if previous was that
            document.manage_delObjects([individual_variation[0].getId(), ])
          else:
            # remove the shared from the list if it's a shared
            variation_list.remove(previous_value)
  
          # set the base category and the variations
          if base_category not in document._baseGetVariationBaseCategoryList():
            base_category_list = document._baseGetVariationBaseCategoryList()
            base_category_list.append(base_category)
            document.setVariationBaseCategoryList(base_category_list)
            self.updateSystemPreference(document.getPortalObject(), base_category)
  
          if new_value not in variation_list:
            variation_list.append(new_value)
            document.setVariationCategoryList(variation_list)
      elif base_tag.startswith('mapping'):
        index_value = int(base_tag[-2]) # because it is tag[index]
        if len(remaining_tag_list) > 1 or not(remaining_tag_list):
          raise NotImplementedError
        tag = remaining_tag_list[0]
        # Retrieve the mapping cell
        cell = self._getPropertyMappingCell(resource=document, prop=tag,
                                            index=index_value)[0]
        getter_id = "get%s" %(tag.capitalize(),)
        getter = getattr(cell, getter_id)
        current_value = getter()
        if isinstance(current_value, unicode):
          current_value = current_value.encode('utf-8')
        if current_value not in [new_value, previous_value]:
          conflict_list.append(self._generateConflict(document.getPhysicalPath(),
                                                      base_tag+'/'+tag,
                                                      etree.tostring(xml, encoding='utf-8'),
                                                      current_value,
                                                      new_value,
                                                      kw['signature']))
        else:
          setter_id = "set%s" %(tag.capitalize(),)
          setter = getattr(cell, setter_id)
          current_value = setter(new_value)
      else:
        # getter used to retrieve the current values and to check conflicts
        getter_value_dict = {
            'title': document.getTitle(),
            'reference': document.getReference(),
            'ean13': document.getEan13Code(),
            'description': document.getDescription(),
        }
  
        # create and fill a conflict when the integration site value, the erp5
        # value and the previous value are differents
        current_value = getter_value_dict[base_tag]
        if isinstance(current_value, float):
          current_value = '%.6f' % current_value
        if isinstance(current_value, unicode):
          current_value = current_value.encode('utf-8')
        if current_value not in [new_value, previous_value]:
          conflict_list.append(self._generateConflict(document.getPhysicalPath(),
                                                      base_tag,
                                                      etree.tostring(xml, encoding='utf-8'),
                                                      current_value,
                                                      new_value,
                                                      kw['signature']))
        else:
          keyword[base_tag] = new_value
          self.editDocument(object=document, **keyword)
  
      return conflict_list
function_tokens: def _updateXupdateUpdate ( self , document = None , xml = None , previous_xml = None , * * kw ) : conflict_list = [ ] xpath_expression = xml . get ( 'select' ) tag_list = xpath_expression . split ( '/' ) base_tag = None remaining_tag_list = [ ] for tag in tag_list : if not len ( tag ) or tag == "resource" : continue elif base_tag is None : base_tag = tag else : remaining_tag_list . append ( tag ) new_value = xml . text keyword = { } # retrieve the previous xml etree through xpath previous_xml = previous_xml . xpath ( xpath_expression ) try : previous_value = previous_xml [ 0 ] . text except IndexError : raise IndexError ( 'Too little or too many value, only one is required for %s' % previous_xml ) if isinstance ( previous_value , unicode ) : previous_value = previous_value . encode ( 'utf-8' ) if isinstance ( new_value , unicode ) : new_value = new_value . encode ( 'utf-8' ) # check if it'a work on product or on categories if base_tag . startswith ( 'category' ) : # init base category, variation and boolean which check update base_category , variation = new_value . split ( '/' , 1 ) old_base_category , old_variation = previous_value . split ( '/' , 1 ) # retrieve the base_categories and the variations base_category_list = document . getVariationBaseCategoryList ( ) variation_list = document . getVariationCategoryList ( ) # about shared and individual variations, it's necessary to check the # mapping existency shared_variation = True try : # Try to access the category document . getPortalObject ( ) . portal_categories . restrictedTraverse ( new_value ) except KeyError : # This is an individual variation shared_variation = False # the mapping of an element must only be defined one time individual_variation = document . searchFolder ( portal_type = 'Product Individual Variation' , title = old_variation , base_category = old_base_category , ) # If this is badly defined, fix the objects if len ( individual_variation ) > 1 : id_to_remove = [ ] for individual in individual_variation [ 1 : ] : id_to_remove . append ( individual . getId ( ) ) document . manage_delObjects ( id_to_remove ) if len ( individual_variation ) and previous_value in variation_list : for individual in individual_variation : id_to_remove . append ( individual . getId ( ) ) document . manage_delObjects ( id_to_remove ) # Update variation if not shared_variation : # work on the cases : # new = individual variation #   old = individual variation -> update #   old = shared variation -> remoce shared and add individual # Fist check individual base if base_category not in document . getIndividualVariationBaseCategoryList ( ) : base_category_list = document . getIndividualVariationBaseCategoryList ( ) base_category_list . append ( base_category ) document . setIndividualVariationBaseCategoryList ( base_category_list ) self . updateSystemPreference ( document . getPortalObject ( ) , base_category , True ) # Then update or add variation if len ( individual_variation ) : individual_variation = individual_variation [ 0 ] . getObject ( ) individual_variation . setTitle ( variation ) individual_variation . setVariationBaseCategory ( base_category ) else : # create the individual variation document . newContent ( portal_type = 'Product Individual Variation' , title = variation , base_category = base_category , ) else : # work on the cases : # new = shared variation #   old = individual variation -> remove individual and add shared #   old = shared variation -> update shared if len ( individual_variation ) : # remove individual if previous was that document . manage_delObjects ( [ individual_variation [ 0 ] . getId ( ) , ] ) else : # remove the shared from the list if it's a shared variation_list . remove ( previous_value ) # set the base category and the variations if base_category not in document . _baseGetVariationBaseCategoryList ( ) : base_category_list = document . _baseGetVariationBaseCategoryList ( ) base_category_list . append ( base_category ) document . setVariationBaseCategoryList ( base_category_list ) self . updateSystemPreference ( document . getPortalObject ( ) , base_category ) if new_value not in variation_list : variation_list . append ( new_value ) document . setVariationCategoryList ( variation_list ) elif base_tag . startswith ( 'mapping' ) : index_value = int ( base_tag [ - 2 ] ) # because it is tag[index] if len ( remaining_tag_list ) > 1 or not ( remaining_tag_list ) : raise NotImplementedError tag = remaining_tag_list [ 0 ] # Retrieve the mapping cell cell = self . _getPropertyMappingCell ( resource = document , prop = tag , index = index_value ) [ 0 ] getter_id = "get%s" % ( tag . capitalize ( ) , ) getter = getattr ( cell , getter_id ) current_value = getter ( ) if isinstance ( current_value , unicode ) : current_value = current_value . encode ( 'utf-8' ) if current_value not in [ new_value , previous_value ] : conflict_list . append ( self . _generateConflict ( document . getPhysicalPath ( ) , base_tag + '/' + tag , etree . tostring ( xml , encoding = 'utf-8' ) , current_value , new_value , kw [ 'signature' ] ) ) else : setter_id = "set%s" % ( tag . capitalize ( ) , ) setter = getattr ( cell , setter_id ) current_value = setter ( new_value ) else : # getter used to retrieve the current values and to check conflicts getter_value_dict = { 'title' : document . getTitle ( ) , 'reference' : document . getReference ( ) , 'ean13' : document . getEan13Code ( ) , 'description' : document . getDescription ( ) , } # create and fill a conflict when the integration site value, the erp5 # value and the previous value are differents current_value = getter_value_dict [ base_tag ] if isinstance ( current_value , float ) : current_value = '%.6f' % current_value if isinstance ( current_value , unicode ) : current_value = current_value . encode ( 'utf-8' ) if current_value not in [ new_value , previous_value ] : conflict_list . append ( self . _generateConflict ( document . getPhysicalPath ( ) , base_tag , etree . tostring ( xml , encoding = 'utf-8' ) , current_value , new_value , kw [ 'signature' ] ) ) else : keyword [ base_tag ] = new_value self . editDocument ( object = document , * * keyword ) return conflict_list