def __setattr__(self, attr, value): try: Component.__setattr__(self, attr, value) except AttributeError: # Set it as an 'expando'. It looks like we should delegate *all* # to the outside object. logger.debug("%s set expando property %r=%r for object %r", self, attr, value, self._comobj_) # and register if an event. if attr.startswith("on"): # I'm quite confused by this :( target = self._comobj_ if _nsdom.IsOuterWindow(target): target = _nsdom.GetCurrentInnerWindow(target) go = self._context_.globalObject scope = self._context_.GetNativeGlobal() if callable(value): # no idea if this is right - set the compiled object ourselves. self._expandos_[attr] = value _nsdom.RegisterScriptEventListener(go, scope, target, attr) else: _nsdom.AddScriptEventListener(target, attr, value, False, False) _nsdom.CompileScriptEventListener(go, scope, target, attr) else: self._expandos_[attr] = value self._context_._remember_object(self)
def _prepareGlobalNamespace(self, globalObject, globalNamespace): assert isinstance(globalObject, WrappedNativeGlobal), \ "Our global should have been wrapped in WrappedNativeGlobal" if __debug__: logger.debug("%r initializing (outer=%s), ns=%d", self, _nsdom.IsOuterWindow(globalObject), id(globalNamespace)) assert len(globalObject._expandos_)==0, \ "already initialized this global?" ns = globalObject.__dict__['_expandos_'] = globalNamespace self._remember_object(globalObject) ns['window'] = globalObject # we can't fetch 'document' and stash it now - there may not be one # at this instant (ie, it may be in the process of being attached) # Poke some other utilities etc into the namespace. ns['dump'] = dump
def __repr__(self): iface_desc = self._get_classinfo_repr_() outer = _nsdom.IsOuterWindow(self._comobj_) return "<GlobalWindow outer=%s %s>" % (outer, iface_desc)