parameters: (self, xml=None, object=None, object_id=None, sub_object=None, # pylint: disable=redefined-builtin
        reset_local_roles=0, reset_workflow=0, simulate=0, **kw)
return_statement: return sub_object
docstring: This is the method calling to create an object.
docstring_summary: This is the method calling to create an object.
docstring_tokens: This is the method calling to create an object .
function: def _createContent(self, xml=None, object=None, object_id=None, sub_object=None, # pylint: disable=redefined-builtin
        reset_local_roles=0, reset_workflow=0, simulate=0, **kw):
      """ This is the method calling to create an object. """
      # if DEBUG:
      # LOG("ERP5NodeContuide._createContent", INFO, "xml = %s" %(etree.tostring(xml, pretty_print=True),))
      if True: # object_id is not None:
        sub_object = None
        if sub_object is None: # If so, it doesn't exist
          # Check if we can find it in module
          sub_object, reset_local_roles, reset_workflow = self.constructContent(
              object,
              object_id,
              self.getObjectType(xml),
          )
  
          # if exist namespace retrieve only the tag
          index = 0
          if xml.nsmap not in [None, {}]:
            index = -1
  
          default_address_created = False
          # browse the xml
          phone_list = []
          cellphone = None
          fax_list = []
          relation = None
          category_list = []
          role_list =[]
          address_tag_mapping = {"street" : "street_address",
                                 "zip" : "zip_code",
                                 "country" : "region",}
          address_int_index = 0
          for node in xml.getchildren():
            # works on tags, no on comments
            if not isinstance(node.tag, str):
              continue
            tag = node.tag.split('}')[index]
  
            # specific for phone
            if tag == "phone":
              phone_list.append(node.text)
            elif tag == "cellphone":
              cellphone = node.text
            elif tag == "fax":
              fax_list.append(node.text)
            elif tag == "relation":
              relation = node.text
            elif tag == "category":
              if node.text.startswith('role'):
                role_list.append(node.text[len("role/"):])
              else:
                category_list.append(node.text)
            elif tag == 'address':
              # Build dict of address properties
              address_data_dict = {}
              for element in node.getchildren():
                if not isinstance(element.tag, str):
                  continue
                element_tag = element.tag.split('}')[index]
                address_data_dict[address_tag_mapping.get(element_tag, element_tag)] = element.text
              # Create the address once we are sure it is well defined
              if len(address_data_dict):
                # Define address id
                if not default_address_created:
                  address_id = "default_address"
                  default_address_created = True
                else:
                  address_id = None
                # Create the address object
                address = sub_object.newContent(portal_type='Address',
                                                int_index=address_int_index,
                                                **address_data_dict)
                address_int_index += 1
                # Rename to default if necessary
                if address_id is not None:
                  address.edit(int_index=0)
                  sub_object.activate(activity="SQLQueue",
                                      after_method_id="immediateReindexObject",
                                      priority=5
                                      ).manage_renameObject(address.getId(), address_id)
  
          # Set telephone
          default_phone_set = False
          if cellphone is not None:
            sub_object.edit(mobile_telephone_text=cellphone)
  
          for phone in phone_list:
            if not default_phone_set:
              sub_object.edit(default_telephone_text=phone)
              default_phone_set = True
            else:
              # Create new subobject
              sub_object.newContent(portal_type="Telephone",
                                    telephone_number=phone)
          # Set fax
          default_fax_set = False
          for fax in fax_list:
            if not default_fax_set:
              sub_object.edit(default_fax_text=fax)
              default_fax_set = True
              continue
            # Create new subobject
            sub_object.newContent(portal_type="Fax",
                                  telephone_number=fax)
  
          # Link to organisation
          if relation is not None:
            self._setRelation(sub_object, None, relation, kw.get('domain'), None, kw.get('signature'))
  
          # Set category
          if len(category_list):
            sub_object.setCategoryList(category_list)
  
          if len(role_list):
            if sub_object.getPortalType() == "Person":
              sub_object.edit(career_role_list=role_list)
            elif sub_object.getPortalType() == "Organisation":
              sub_object.edit(role_list=role_list)
  
        # build the content of the node
        self.newObject(
            object=sub_object,
            xml=xml,
            simulate=simulate,
            reset_local_roles=reset_local_roles,
            reset_workflow=reset_workflow,
            )
        self.afterCreateMethod(sub_object, **kw)
      return sub_object
function_tokens: def _createContent ( self , xml = None , object = None , object_id = None , sub_object = None , # pylint: disable=redefined-builtin reset_local_roles = 0 , reset_workflow = 0 , simulate = 0 , * * kw ) : # if DEBUG: # LOG("ERP5NodeContuide._createContent", INFO, "xml = %s" %(etree.tostring(xml, pretty_print=True),)) if True : # object_id is not None: sub_object = None if sub_object is None : # If so, it doesn't exist # Check if we can find it in module sub_object , reset_local_roles , reset_workflow = self . constructContent ( object , object_id , self . getObjectType ( xml ) , ) # if exist namespace retrieve only the tag index = 0 if xml . nsmap not in [ None , { } ] : index = - 1 default_address_created = False # browse the xml phone_list = [ ] cellphone = None fax_list = [ ] relation = None category_list = [ ] role_list = [ ] address_tag_mapping = { "street" : "street_address" , "zip" : "zip_code" , "country" : "region" , } address_int_index = 0 for node in xml . getchildren ( ) : # works on tags, no on comments if not isinstance ( node . tag , str ) : continue tag = node . tag . split ( '}' ) [ index ] # specific for phone if tag == "phone" : phone_list . append ( node . text ) elif tag == "cellphone" : cellphone = node . text elif tag == "fax" : fax_list . append ( node . text ) elif tag == "relation" : relation = node . text elif tag == "category" : if node . text . startswith ( 'role' ) : role_list . append ( node . text [ len ( "role/" ) : ] ) else : category_list . append ( node . text ) elif tag == 'address' : # Build dict of address properties address_data_dict = { } for element in node . getchildren ( ) : if not isinstance ( element . tag , str ) : continue element_tag = element . tag . split ( '}' ) [ index ] address_data_dict [ address_tag_mapping . get ( element_tag , element_tag ) ] = element . text # Create the address once we are sure it is well defined if len ( address_data_dict ) : # Define address id if not default_address_created : address_id = "default_address" default_address_created = True else : address_id = None # Create the address object address = sub_object . newContent ( portal_type = 'Address' , int_index = address_int_index , * * address_data_dict ) address_int_index += 1 # Rename to default if necessary if address_id is not None : address . edit ( int_index = 0 ) sub_object . activate ( activity = "SQLQueue" , after_method_id = "immediateReindexObject" , priority = 5 ) . manage_renameObject ( address . getId ( ) , address_id ) # Set telephone default_phone_set = False if cellphone is not None : sub_object . edit ( mobile_telephone_text = cellphone ) for phone in phone_list : if not default_phone_set : sub_object . edit ( default_telephone_text = phone ) default_phone_set = True else : # Create new subobject sub_object . newContent ( portal_type = "Telephone" , telephone_number = phone ) # Set fax default_fax_set = False for fax in fax_list : if not default_fax_set : sub_object . edit ( default_fax_text = fax ) default_fax_set = True continue # Create new subobject sub_object . newContent ( portal_type = "Fax" , telephone_number = fax ) # Link to organisation if relation is not None : self . _setRelation ( sub_object , None , relation , kw . get ( 'domain' ) , None , kw . get ( 'signature' ) ) # Set category if len ( category_list ) : sub_object . setCategoryList ( category_list ) if len ( role_list ) : if sub_object . getPortalType ( ) == "Person" : sub_object . edit ( career_role_list = role_list ) elif sub_object . getPortalType ( ) == "Organisation" : sub_object . edit ( role_list = role_list ) # build the content of the node self . newObject ( object = sub_object , xml = xml , simulate = simulate , reset_local_roles = reset_local_roles , reset_workflow = reset_workflow , ) self . afterCreateMethod ( sub_object , * * kw ) return sub_object