code: def create_attachment(self, container, attachment_file, **kw):
          
          filename = getattr(attachment_file, "filename", "Attachment")
          attachment = api.create(container, "Attachment", title=filename)
          attachment.edit(AttachmentFile=attachment_file, **kw)
          attachment.processForm()
          attachment.reindexObject()
          logger.info("Created new Attachment {} in {}".format(
              repr(attachment), repr(container)))
          return attachment
docs: Create an Attachment object in the given container