Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
xpcom.client.WeakReference Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Private Attributes


Detailed Description

A weak-reference object.  You construct a weak reference by passing
any COM object you like.  If the object does not support weak
refs, you will get a standard NS_NOINTERFACE exception.

Once you have a weak-reference, you can "call" the object to get
back a strong reference.  Eg:

>>> some_ob = components.classes['...']
>>> weak_ref = WeakReference(some_ob)
>>> new_ob = weak_ref() # new_ob is effectively "some_ob" at this point
>>> # EXCEPT: new_ob may be None of some_ob has already died - a
>>> # weak reference does not keep the object alive (that is the point)

You should never hold onto this resulting strong object for a long time,
or else you defeat the purpose of the weak-reference.

Definition at line 445 of file

Constructor & Destructor Documentation

def xpcom.client.WeakReference.__init__ (   self,
  iid = None 

Definition at line 462 of file

00463     def __init__(self, ob, iid = None):
00464         swr = Component(ob._comobj_, IID_nsISupportsWeakReference)
00465         self._comobj_ = Component(swr.GetWeakReference()._comobj_, IID_nsIWeakReference)
00466         if iid is None:
00467             try:
00468                 iid = ob.IID
00469             except AttributeError:
00470                 iid = IID_nsISupports
        self._iid_ = iid

Member Function Documentation

def xpcom.client.WeakReference.__call__ (   self,
  iid = None 

Definition at line 471 of file

00472     def __call__(self, iid = None):
00473         if iid is None: iid = self._iid_
00474         try:
00475             return Component(self._comobj_.QueryReferent(iid)._comobj_, iid)
00476         except COMException, details:
00477             if details.errno != nsError.NS_ERROR_NULL_POINTER:
00478                 raise
00479             return None

Member Data Documentation

Definition at line 464 of file

Definition at line 470 of file

The documentation for this class was generated from the following file: