def __setitem__(self, name, vessel): try: attrs = vessel.attrs except AttributeError: raise ValueError(u"no attributes found, cannot convert.") if name in self: raise KeyError(u"Key already exists: '%s'." % (name,)) nextvessel = AttributedNode() nextvessel.__name__ = name nextvessel.attribute_access_for_attrs = False principal = self.principal_factory( nextvessel, attraliaser=self.principal_attraliaser) principal.__name__ = name principal.__parent__ = self # XXX: cache for key, val in attrs.iteritems(): principal.attrs[key] = val self.context[name] = nextvessel
def __setitem__(self, name, vessel): """XXX: mechanism for defining a target container if search scope is SUBTREE """ try: attrs = vessel.attrs except AttributeError: raise ValueError(u"no attributes found, cannot convert.") if name in self: raise KeyError(u"Key already exists: '%s'." % (name, )) nextvessel = AttributedNode() nextvessel.__name__ = name nextvessel.attribute_access_for_attrs = False principal = self.principal_factory( nextvessel, attraliaser=self.principal_attraliaser) principal.__name__ = name principal.__parent__ = self # XXX: cache for key, val in attrs.iteritems(): principal.attrs[key] = val self.context[name] = nextvessel