'Set the value of a stanza interface using dictionary-like syntax.
Example::
>>> msg[\'body\'] = "Hi!"
>>> msg[\'body\']
\'Hi!\'
Stanza interfaces are typically mapped directly to the underlying XML
object, but can be overridden by the presence of a ``set_attrib``
method (or ``set_foo`` where the interface is named ``\'foo\'``, etc).
The effect of interface value assignment for an interface
named ``\'foo\'`` will be one of:
1. Delete the interface\'s contents if the value is None.
2. Call the ``set_foo`` override handler, if it exists.
3. Call ``set_foo``, if it exists.
4. Call ``setFoo``, if it exists.
5. Set the text of a ``foo`` element, if ``\'foo\'`` is
in :attr:`sub_interfaces`.
6. Add or remove an empty subelement ``foo``
if ``foo`` is in :attr:`bool_interfaces`.
7. Set the value of a top level XML attribute named ``foo``.
8. Attempt to pass the value to a plugin named ``\'foo\'`` using
the plugin\'s ``\'foo\'`` interface.
9. Do nothing.
:param string attrib: The name of the stanza interface to modify.
:param value: The new value of the stanza interface.'

def __setitem__(self, attrib, value):

    full_attrib = attrib
    attrib_lang = (u'%s|' % attrib).split(u'|')
    attrib = attrib_lang[0]
    lang = (attrib_lang[1] or None)
    kwargs = {}
    if (lang and (attrib in self.lang_interfaces)):
        kwargs[u'lang'] = lang
    kwargs = safedict(kwargs)
    if ((attrib in self.interfaces) or (attrib == u'lang')):
        if (value is not None):
            set_method = (u'set_%s' % attrib.lower())
            set_method2 = (u'set%s' % attrib.title())
            if self.plugin_overrides:
                name = self.plugin_overrides.get(set_method, None)
                if name:
                    plugin = self._get_plugin(name, lang)
                    if plugin:
                        handler = getattr(plugin, set_method, None)
                        if handler:
                            return handler(value, **kwargs)
            if hasattr(self, set_method):
                getattr(self, set_method)(value, **kwargs)
            elif hasattr(self, set_method2):
                getattr(self, set_method2)(value, **kwargs)
            elif (attrib in self.sub_interfaces):
                if (lang == u'*'):
                    return self._set_all_sub_text(attrib, value, lang=u'*')
                return self._set_sub_text(attrib, text=value, lang=lang)
            elif (attrib in self.bool_interfaces):
                if value:
                    return self._set_sub_text(attrib, u'', keep=True, lang=lang)
                else:
                    return self._set_sub_text(attrib, u'', keep=False, lang=lang)
            else:
                self._set_attr(attrib, value)
        else:
            self.__delitem__(attrib)
    elif (attrib in self.plugin_attrib_map):
        plugin = self._get_plugin(attrib, lang)
        if plugin:
            plugin[full_attrib] = value
    return self
