creates link from obj.attr to self
        :param obj: object to register link to
        :param attr: attribute name to register link to
355706
def register_link(self, obj, attr=None):
        
        name = repr(self)
        if not name:
            return self
        l = self.__class__._get_links()
        if name not in l:
            l[name] = set()
        v = WeakAttrLink(obj, attr)
        if v not in l[name]:
            l[name].add(v)
        return self
1054042
def popattr(obj, attr, default=NOT_PROVIDED):
    
    val = getattr(obj, attr, default)
    try:
        delattr(obj, attr)
    except AttributeError:
        if default is NOT_PROVIDED:
            raise
    return val
1156580
def func_attr(f, attr):
    
    if hasattr(f, 'func_%s' % attr):
        return getattr(f, 'func_%s' % attr)
    elif hasattr(f, '__%s__' % attr):
        return getattr(f, '__%s__' % attr)
    else:
        raise ValueError('Object %s has no attr' % (str(f), attr))
1271215
def add_link_attribute(mut_attr_string)
      range_pointer = Pointer.new(NSRange.type)
      attributes = mut_attr_string.attributesAtIndex(0, effectiveRange: range_pointer).dup

      attributes[NSFontAttributeName] = self.font
      attributes[NSForegroundColorAttributeName] = self.textColor
      mut_attr_string.addAttributes(attributes, range: range_pointer[0])

      active_elements.each do |type, elements|
        case type
        when :mention  then attributes[NSForegroundColorAttributeName] = mention_color
        when :hashtag  then attributes[NSForegroundColorAttributeName] = hashtag_color
        when :url      then attributes[NSForegroundColorAttributeName] = url_color
        when :category then attributes[NSForegroundColorAttributeName] = category_color
        end

        elements.each do |element|
          mut_attr_string.setAttributes(attributes, range: element.range)
        end
      end
    end
425117
def model_attr(attr_name):
    

    def model_attr(value, context, **_params):
        setattr(context["model"], attr_name, value)
        return _attr()

    return model_attr
889370
def resolve_attr(obj, name):
    """"""
    # TODO: setup some hinting, so we can go directly to the correct
    # Maybe it's a dict ? Let's try dict lookup, it's the fastest
    try:
        return obj[name]
    except TypeError:
        pass
    except KeyError:
        raise exceptions.MissingField('Dict {0} has no attribute or key "{1}"'.format(obj, name))

    # Okay, it's not a dict, what if we try to access the value as for a regular object attribute?
    try:
        # Slight hack for better speed, since accessing dict is fast
        return obj.__dict__[name]
    except (KeyError, AttributeError):
        pass

    try:
        # Lookup using regular attribute
        return getattr(obj, name)
    except AttributeError:
        pass

    # Last possible choice, it's an iterable
    if isinstance(obj, collections.Iterable):
        return IterableAttr(obj, name)

    raise exceptions.MissingField('Object {0} has no attribute or key "{1}"'.format(obj, name))
528151
def get_attr_chain(obj, attr_chain, sep='.'):
    
    if sep is None:
        sep = '.'

    attr_names = attr_chain.split(sep)

    new_obj = obj

    for attr_name in attr_names:
        new_obj = getattr(new_obj, attr_name)

    return new_obj
989930
def view_attr(attr_name):
    

    def view_attr(value, context, **_params):
        setattr(context["view"], attr_name, value)
        return _attr()

    return view_attr
315581
def _object_with_attr(self, name):
        
        for obj in self._objects:
            if hasattr(obj, name):
                return obj

        raise AttributeError("No object has attribute {!r}".format(name))
1313089
def link_add(self, rel, href, **atts):
        
        self.link_set(rel, href, allow_duplicates=True, **atts)
776756
def setattr_path(obj, path, value):
    
    path = path.split('__')
    o = obj
    for name in path[:-1]:
        o = getattr(o, name)
    setattr(o, path[-1], value)
    return obj
36382
def chain_getattr(obj, attr, value=None):
    
    try:
        return _resolve_value(safe_chain_getattr(obj, attr))
    except AttributeError:
        return value
1299497
def attr(obj, attr):
    
    if not obj or not hasattr(obj, attr):
        return ''

    return getattr(obj, attr, '')
8982
def link(self, var):
        
        assert self._dtype is not None or hasattr(var, 'dtype')
        self._link = var
        self.changed()
1046618
function Link (rel, value) {
    if (!(this instanceof Link)) {
      return new Link(rel, value);
    }

    if (!rel) throw new Error('Required <link> attribute "rel"');

    this.rel = rel;

    if (typeof value === 'object') {

      // If value is a hashmap, just copy properties
      if (!value.href) throw new Error('Required <link> attribute "href"');
      var expectedAttributes = ['rel', 'href', 'name', 'hreflang', 'title', 'templated', 'icon', 'align', 'method'];
      for (var attr in value) {
        if (value.hasOwnProperty(attr)) {
          if (!~expectedAttributes.indexOf(attr)) {
            // Unexpected attribute: ignore it
            continue;
          }
          this[attr] = value[attr];
        }
      }

    } else {

      // value is a scalar: use its value as href
      if (!value) throw new Error('Required <link> attribute "href"');
      this.href = String(value);

    }
  }
150666
def getattr(self, obj, attribute):
        
        try:
            value = getattr(obj, attribute)
        except AttributeError:
            try:
                return obj[attribute]
            except (TypeError, LookupError):
                pass
        else:
            if self.is_safe_attribute(obj, attribute, value):
                return value
            return self.unsafe_undefined(obj, attribute)
        return self.undefined(obj=obj, name=attribute)
338518
def getattrdeep(obj, attr, *default):
    ''
    attrs = attr.split('.')
    if default:
        getattr_default = lambda o,a,d=default[0]: getattr(o, a, d)
    else:
        getattr_default = lambda o,a: getattr(o, a)

    for a in attrs[:-1]:
        obj = getattr_default(obj, a)

    return getattr_default(obj, attrs[-1])