Hi,
not sure, whether I get your problem.
> connections which can be closed or
What happens, when a connection is 'closed' ?
When you keep the object reference in your zope server, the connection
to your worker office can only be destroyed when
- oood restarts
- the worker office crashes.
oood won't touch exported connections.
You may try to check, whether the desktop object is still reachable by
invoking a call on the object, e.g.
from com.sun.star.uno import RuntimeException
def isAlive( con ):
ret = True
try:
# (getImplementationId() is always implemented
con.getImplementationId()
except RuntimeException,e:
ret = False
return ret
Bye,
Joerg
Marco Bizzarri wrote:
Hi all.
My setup is as following:
I've a Zope server, with 4 threads, and the same number of oood
processes running. In order to avoid problems of connections which can
be closed or not, I'm using a dictionary to associate a zope thread
with a connection to oood, so that each thread always reuse the same
connection.
The problem is when oood restarts its connection because, at that
time, my connection is no longer valid.
Is there a way to check if a connection is still good? I'm including
the (python) code in order to explain me:
def openOODoc(path):
desktop = getOODesktop()
url = systemPathToFileUrl(path)
doc = desktop.loadComponentFromURL(url, '_blank', 0, ())
return doc
oood_connections = {}
def getOODesktop():
thread_id = get_ident()
_oood_lock.acquire()
if oood_connections.has_key(thread_id):
connection = oood_connections[thread_id]
_oood_lock.release()
return connection
try:
localContext = getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
'com.sun.star.bridge.UnoUrlResolver', localContext)
ctx = resolver.resolve(
'uno:socket,host=localhost,port=2002;'
'urp;StarOffice.ComponentContext')
connection =
ctx.ServiceManager.createInstanceWithContext('com.sun.star.frame.Desktop',
ctx)
oood_connections[thread_id] = connection
finally:
_oood_lock.release()
return connection
Inside zope I will use the getOODoc() to open a (file system) document
inside OOo. I would like to be able to try something on the
connection, so that I check if it is still open.
Thanks!
Regards
Marco
--
Icube Srl
http://www.icube.it/
m dot bizzarri at icube dot it
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]