コード例 #1
0
 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("setting expando %s.%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)
コード例 #2
0
 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)
コード例 #3
0
 def __init__(self, context, obj, iid):
     # Store our context - but our context doesn't keep a reference
     # to us until someone calls self._remember_object() on the context -
     # which sets up all kinds of cycles!
     self.__dict__['_context_'] = context
     # We store expandos in a seperate dict rather than directly in our
     # __dict__.  No real need for this other than to prevent these
     # attributes clobbering ones we need to work!
     self.__dict__['_expandos_'] = {}
     Component.__init__(self, obj, iid)
コード例 #4
0
 def __init__(self, context, obj, iid):
     # Store our context - but our context doesn't keep a reference
     # to us until someone calls self._remember_object() on the context -
     # which sets up all kinds of cycles!
     self.__dict__['_context_'] = context
     # We store expandos in a separate dict rather than directly in our
     # __dict__.  No real need for this other than to prevent these
     # attributes clobbering ones we need to work!
     self.__dict__['_expandos_'] = {}
     Component.__init__(self, obj, iid)
コード例 #5
0
 def _build_all_supported_interfaces_(self):
     # Generally called as pyxpcom is finding an attribute, overridden to
     # work around lack of class info for xbl bindings.
     Component._build_all_supported_interfaces_(self)
     # Now hard-code certain element names we know about, as the XBL
     # implemented interfaces are not exposed by this.
     ii = self.__dict__['_interface_infos_']
     if ii.has_key(IID_nsIDOMXULElement):
         # Is a DOM element - see if in our map.
         tagName = self.tagName
         interfaces = xul_element_interfaces.get(tagName, [])
         for interface in interfaces:
             if not ii.has_key(interface):
                 self._remember_interface_info(interface)
     else:
         logger.info("Not a DOM element - not hooking extra interfaces")
コード例 #6
0
 def _build_all_supported_interfaces_(self):
     # Generally called as pyxpcom is finding an attribute, overridden to
     # work around lack of class info for xbl bindings.
     Component._build_all_supported_interfaces_(self)
     # Now hard-code certain element names we know about, as the XBL
     # implemented interfaces are not exposed by this.
     ii = self.__dict__['_interface_infos_']
     if ii.has_key(IID_nsIDOMXULElement):
         # Is a DOM element - see if in our map.
         tagName = self.tagName
         interfaces = xul_element_interfaces.get(tagName, [])
         for interface in interfaces:
             if not ii.has_key(interface):
                     self._remember_interface_info(interface)
     else:
         logger.info("Not a DOM element - not hooking extra interfaces")
コード例 #7
0
 def __getattr__(self, attr):
     # If it exists in expandos, always return it.
     if attr.startswith("__"):
         raise AttributeError, attr
     # expandos come before interface attributes (which may be wrong.  If
     # we do this, why not just store it in __dict__?)
     expandos = self._expandos_
     if expandos.has_key(attr):
         return expandos[attr]
     return Component.__getattr__(self, attr)
コード例 #8
0
 def __getattr__(self, attr):
     # If it exists in expandos, always return it.
     if attr.startswith("__"):
         raise AttributeError, attr
     # expandos come before interface attributes (which may be wrong.  If
     # we do this, why not just store it in __dict__?)
     expandos = self._expandos_
     if expandos.has_key(attr):
         return expandos[attr]
     return Component.__getattr__(self, attr)
コード例 #9
0
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

# regxpcom.py - basically the standard regxpcom.cpp ported to Python.
# In general, you should use regxpcom.exe instead of this.

from xpcom import components, _xpcom
from xpcom.client import Component
import sys
import os

registrar = Component(_xpcom.GetComponentRegistrar(),
                      components.interfaces.nsIComponentRegistrar)

def ProcessArgs(args):

    unregister = 0
    for arg in args:
        spec = components.classes['@mozilla.org/file/local;1'].createInstance()
        spec = spec.QueryInterface(components.interfaces.nsILocalFile)
        spec.initWithPath(os.path.abspath(arg))
        if arg == "-u":
            registrar.autoUnregister(spec)
            print "Successfully unregistered", spec.path
        else:
            registrar.autoRegister(spec)
            print "Successfully registered", spec.path
コード例 #10
0
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

# regxpcom.py - basically the standard regxpcom.cpp ported to Python.
# In general, you should use regxpcom.exe instead of this.

from xpcom import components, _xpcom
from xpcom.client import Component
import sys
import os

registrar = Component(_xpcom.GetComponentRegistrar(),
                      components.interfaces.nsIComponentRegistrar)


def ProcessArgs(args):

    unregister = 0
    for arg in args:
        spec = components.classes['@mozilla.org/file/local;1'].createInstance()
        spec = spec.QueryInterface(components.interfaces.nsILocalFile)
        spec.initWithPath(os.path.abspath(arg))
        if arg == "-u":
            registrar.autoUnregister(spec)
            print "Successfully unregistered", spec.path
        else:
            registrar.autoRegister(spec)
            print "Successfully registered", spec.path