I am working on an application in Python/PyUNO (to which I am very new) and am 
having a heck of a time creating an XTerminateListener for the desktop.

The connection to OpenOffice is extablised as follows, where OO is already 
listening on the 'fax-gw' pipe:

I have reviewed 
http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XTerminateListener.html
 
and 
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Using_the_Desktop
but am having difficulty translating this to python and what I get for an 
error is:
2009-10-24 15:40:19,748 [CALL,tid 1]: except  py-
>uno[0x7f9db15dcb30].addTerminateListener = 
(com.sun.star.uno.RuntimeException){ (com.sun.star.uno.Exception){ Message = 
(string)"<type 'exceptions.AttributeError'>: TerminateListener instance has no 
attribute 'getTypes', traceback follows
no traceback available", Context = (com.sun.star.uno.XInterface)0x0 } }
Traceback (most recent call last):
  File "/home/amessina/devel/fax-gw.git/pyuno/test.py", line 178, in <module>
    oo.desktop.addTerminateListener(terminateListener)
uno.RuntimeException: <type 'exceptions.AttributeError'>: TerminateListener 
instance has no attribute 'getTypes', traceback follows
no traceback available


This is the relevant code so far:

class TerminateListener(XTerminateListener):
    def disposing(EventObject, eventObject):
        pass

    def notifyTermination(EventObject, eventObject):
        return

    def queryTermination(EventObject, eventObject):
        raise TerminationVetoException
        return   

class Connect:
    def __init__(self):
        localContext = uno.getComponentContext()
        remoteContext = None
        resolver = 
localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",
 
localContext)
        timeout = 0
        while timeout <= 60:
            try:
                remoteContext = resolver.resolve("uno:pipe,name=fax-
gw;urp;StarOffice.ComponentContext")
                break
            except NoConnectException:
                time.sleep(5)
                timeout = timeout + 5

        if not remoteContext:
            raise Exception, "Failed to connect to OpenOffice.org on IPC pipe: 
fax-gw."

        self.desktop = 
remoteContext.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",
 
remoteContext)

        if not self.desktop:
            raise Exception, "Failed to create OpenOffice.org desktop on IPC 
pipe: fax-gw"

### do the work ###
oo = Connect()

terminateListener = TerminateListener()
oo.desktop.addTerminateListener(terminateListener)


Thank you in advance for your assistance.
-- 
Anthony - http://messinet.com - http://messinet.com/~amessina/gallery
8F89 5E72 8DF0 BCF0 10BE 9967 92DC 35DC B001 4A4E

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to