Add a child attachment
192616
def add_child(role, &block)
      attachment = self.children.build
      attachment.role = role
      attachment.owner = self.owner
      attachment.file_name = self.file_name
      attachment.file_type = self.file_type
      attachment.disposition = self.disposition
      attachment.cache_type = self.cache_type
      attachment.cache_max_age = self.cache_max_age
      attachment.type = self.type
      block.call(attachment)
      attachment.save!
    end
827089
def addAttachment(self, oid, file_path):
        
        if self.hasAttachments == True:
            attachURL = self._url + "/%s/addAttachment" % oid
            params = {'f':'json'}
            parsed = urlparse.urlparse(attachURL)

            files = {'attachment': file_path}
            res = self._post(url=attachURL,
                             param_dict=params,
                             files=files,
                             securityHandler=self._securityHandler,
                             proxy_port=self._proxy_port,
                             proxy_url=self._proxy_url)
            return self._unicode_convert(res)
        else:
            return "Attachments are not supported for this feature service."
788887
def attachment_form(context, obj):
    
    if context['user'].has_perm('attachments.add_attachment'):
        return {
            'form': AttachmentForm(),
            'form_url': add_url_for_obj(obj),
            'next': context.request.build_absolute_uri(),
        }
    else:
        return {'form': None}
388212
public E attachment(File attachment, String name) {
        addBinaryAttachment(attachment, name);
        return getThis();
    }
644241
def append(self, _, child, name=None):
        """"""
        self._insert(child, name=name)
        return self
1008759
def attachment_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/attachments/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
647194
def add(self, child):
        

        if isinstance(child, Parameter):
            self.add_parameter(child)
        elif isinstance(child, Property):
            self.add_property(child)
        elif isinstance(child, DerivedParameter):
            self.add_derived_parameter(child)
        elif isinstance(child, IndexParameter):
            self.add_index_parameter(child)
        elif isinstance(child, Constant):
            self.add_constant(child)
        elif isinstance(child, Exposure):
            self.add_exposure(child)
        elif isinstance(child, Requirement):
            self.add_requirement(child)
        elif isinstance(child, ComponentRequirement):
            self.add_component_requirement(child)
        elif isinstance(child, InstanceRequirement):
            self.add_instance_requirement(child)
        elif isinstance(child, Children):
            self.add_children(child)
        elif isinstance(child, Text):
            self.add_text(child)
        elif isinstance(child, Link):
            self.add_link(child)
        elif isinstance(child, Path):
            self.add_path(child)
        elif isinstance(child, EventPort):
            self.add_event_port(child)
        elif isinstance(child, ComponentReference):
            self.add_component_reference(child)
        elif isinstance(child, Attachments):
            self.add_attachments(child)
        else:
            raise ModelError('Unsupported child element')
140837
def add_to_parent(self):
        """"""
        parent = self.parent
        if parent is not None:
            try:
                children = parent.children
            except AttributeError: pass
            else:
                include(children, self)
153883
function createAttach() {
    $cnt = count( $this->attach );
    if( 0 >= $cnt )
      return;
    $output    = null;
    foreach( $this->attach as $attachPart ) {
      $attributes = $this->_createParams( $attachPart['params'] );
      $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
    }
    return $output;
  }
222435
def attachment_upload(instance, filename):
    """"""
    return 'attachments/{app}_{model}/{pk}/{filename}'.format(
        app=instance.content_object._meta.app_label,
        model=instance.content_object._meta.object_name.lower(),
        pk=instance.content_object.pk,
        filename=filename,
    )
52774
def add(self, child):
        

        if isinstance(child, Action):
            self.add_action(child)
        else:
            raise ModelError('Unsupported child element')
954412
def build_attachment(self, text, target, attachment, thread):
        '''
        '''

        attachment = {
            'as_user': True,
            'text': text,
            'channel': target,
            'attachments': [
                {
                    'fallback': text,
                    'image_url': attachment
                }
            ]
        }
        if thread:
            attachment['thread_ts'] = thread
        return attachment
141379
function( attachment ) {
			var noChange = ( attachment && this._attachment && attachment.id === this._attachment.id ) || ( ! attachment && ! this._attachment );

			if ( ! attachment ) {
				this._resetContent();

				if ( noChange ) {
					return;
				}

				this.element.val( null );
				this.element.trigger( 'change' );

				if ( 'function' === typeof this.options.clear ) {
					this.options.clear.call( this );
				}

				$( document ).trigger( 'wpMediaPicker.updateField', [ null, this ] );
				return;
			}

			this._createContent( attachment );

			if ( noChange ) {
				return;
			}

			if ( 'url' === this.options.store ) {
				this.element.val( attachment.url );
			} else {
				this.element.val( attachment.id );
			}
			this.element.trigger( 'change' );

			if ( 'function' === typeof this.options.change ) {
				this.options.change.call( this );
			}

			$( document ).trigger( 'wpMediaPicker.updateField', [ attachment, this ] );
		}
229576
def pickAttachment(self):
        
        filename = QFileDialog.getOpenFileName(self.window(),
                                               'Select Attachment',
                                               '',
                                               'All Files (*.*)')
        
        if type(filename) == tuple:
            filename = nativestring(filename[0])
        
        filename = nativestring(filename)
        if filename:
            self.addAttachment(os.path.basename(filename), filename)
814676
def add_child(self, child):
        
        if child.tag in self.contained_children:
            self.children.append(child)
        else:
            raise UNTLStructureException(
                'Invalid child "%s" for parent "%s"' % (
                    child.tag,
                    self.tag
                )
            )
230091
protected void addLogical(Widget child) {
		// Detach new child.
		child.removeFromParent();

		// Logical attach.
		getChildren().add(child);

		// Adopt.
		adopt(child);
	}
1044103
function addToChildren(parent, key, descriptor) {

		var target,
		    i;

		if (!parent.children || !parent.children.length) {
			return;
		}

		for (i = 0; i < parent.children.length; i++) {
			target = parent.children[i];
			Object.defineProperty(target, key, descriptor);
			addToStaticChain(target, key, descriptor);
		}
	}