ZEO and COM

D

drs

please let me know if there is a better place to post this ...

I am trying to create a shared dictionary which can be accessed via COM. To
that end, I have written the code below (at the end).

So far this works from a single computer, but if another computer tries to
share the data it is unable to see changes, and throws exceptions when it
tries to rewrite data.

Does anyone know how I can make all connections aware of changes?

Any ideas?

Thanks

This is w/ ZODB3 3.1.2, Python 2.2, win2k

-doug

#-----------------
from ZEO import ClientStorage
from ZODB import DB

class ecp_ZEOCOM:

_reg_clsid_ = '{F7B8D35F-7B24-4B84-A8B6-34880132A854}'
_public_methods_ = [
'open',
'keys',
'has_key',
'get_item',
'set_item',
'del_item'
]
_reg_progid_ = 'ecp.ZEOCOM'

def open(self, IP, Port):
addr = (str(IP), int(Port))
self.storage = ClientStorage.ClientStorage(addr)
dbl = DB(self.storage)
conn = dbl.open()
self.db = conn.root()

def get_item(self, key):
self.storage.sync()
try: return self.db[str(key)]
except: return ''

def set_item(self, key, value):
self.storage.sync()
self.db[str(key)] = value
get_transaction().commit()

def del_item(self, key):
self.storage.sync()
del self.db[str(key)]
get_transaction().commit()

def keys(self):
self.storage.sync()
x = self.db.keys()
x.sort()
return x

def has_key(self, key):
self.storage.sync()
return self.db.has_key(key)

def register():
import win32com.server.register
win32com.server.register.UseCommandLine(ecp_ZEOCOM)

if __name__ == '__main__': register()
#-----------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top