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 remove elements.
docstring_summary: This method is called in updateNode and allows to remove elements.
docstring_tokens: This method is called in updateNode and allows to remove elements .
function: def _updateXupdateDel(self, document=None, xml=None, previous_xml=None, **kw):
      """ This method is called in updateNode and allows to remove elements. """
      conflict_list = []
      base_tag = None
      remaining_tag_list = []
      tag_list = xml.get('select').split('/')
      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)
      keyword = {}
  
      if base_tag.startswith('category'):
        # retrieve the previous xml etree through xpath
        previous_xml = previous_xml.xpath(base_tag)
        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')
  
        # boolean which check update
        updated = False
        # check first in shared variations
        shared_variation_list = document.getVariationCategoryList()
        if previous_value in shared_variation_list:
          updated = True
          shared_variation_list.remove(previous_value)
          document.setVariationCategoryList(shared_variation_list)
        # if no update has occured, check in individual variations
        if not updated:
          individual_variation = document.portal_catalog(
              portal_type='Product Individual Variation',
              title=previous_value.split('/', 1)[-1],
              parent_uid=document.getUid(),
          )
          if len(individual_variation) == 1:
            individual_variation = individual_variation[0].getObject()
            document.manage_delObjects([individual_variation.getId(), ])
      elif base_tag.startswith('mapping'):
        index_value = int(base_tag[-2]) # because it is tag[index]
        if not len(remaining_tag_list):
          # We are deleting a cell
          cell_list = self._getPropertyMappingCell(resource=document, prop=None,
                                              index=index_value)
          for cell in cell_list:
            line = cell.getParentValue()
            line.manage_delObjects(cell.getId())
        else:
          # We are deleting a property only
          if len(remaining_tag_list) > 1:
            raise NotImplementedError
          tag = remaining_tag_list[0]
          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]: # pylint: disable=undefined-variable
            conflict_list.append(self._generateConflict(document.getPhysicalPath(),
                                                        base_tag+'/'+tag,
                                                        etree.tostring(xml, encoding='utf-8'),
                                                        current_value,
                                                        new_value, # pylint: disable=undefined-variable
                                                        kw['signature']))
          else:
            setter_id = "set%s" %(tag.capitalize(),)
            setter = getattr(cell, setter_id)
            current_value = setter(None)
      else:
        keyword[base_tag] = None
        self.editDocument(object=document, **keyword)
      return conflict_list
function_tokens: def _updateXupdateDel ( self , document = None , xml = None , previous_xml = None , * * kw ) : conflict_list = [ ] base_tag = None remaining_tag_list = [ ] tag_list = xml . get ( 'select' ) . split ( '/' ) 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 ) keyword = { } if base_tag . startswith ( 'category' ) : # retrieve the previous xml etree through xpath previous_xml = previous_xml . xpath ( base_tag ) 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' ) # boolean which check update updated = False # check first in shared variations shared_variation_list = document . getVariationCategoryList ( ) if previous_value in shared_variation_list : updated = True shared_variation_list . remove ( previous_value ) document . setVariationCategoryList ( shared_variation_list ) # if no update has occured, check in individual variations if not updated : individual_variation = document . portal_catalog ( portal_type = 'Product Individual Variation' , title = previous_value . split ( '/' , 1 ) [ - 1 ] , parent_uid = document . getUid ( ) , ) if len ( individual_variation ) == 1 : individual_variation = individual_variation [ 0 ] . getObject ( ) document . manage_delObjects ( [ individual_variation . getId ( ) , ] ) elif base_tag . startswith ( 'mapping' ) : index_value = int ( base_tag [ - 2 ] ) # because it is tag[index] if not len ( remaining_tag_list ) : # We are deleting a cell cell_list = self . _getPropertyMappingCell ( resource = document , prop = None , index = index_value ) for cell in cell_list : line = cell . getParentValue ( ) line . manage_delObjects ( cell . getId ( ) ) else : # We are deleting a property only if len ( remaining_tag_list ) > 1 : raise NotImplementedError tag = remaining_tag_list [ 0 ] 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 ] : # pylint: disable=undefined-variable conflict_list . append ( self . _generateConflict ( document . getPhysicalPath ( ) , base_tag + '/' + tag , etree . tostring ( xml , encoding = 'utf-8' ) , current_value , new_value , # pylint: disable=undefined-variable kw [ 'signature' ] ) ) else : setter_id = "set%s" % ( tag . capitalize ( ) , ) setter = getattr ( cell , setter_id ) current_value = setter ( None ) else : keyword [ base_tag ] = None self . editDocument ( object = document , * * keyword ) return conflict_list