ZEO and COM

Discussion in 'Python' started by drs, Jul 11, 2003.

  1. drs

    drs Guest

    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()
    #-----------------
     
    drs, Jul 11, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. drs

    More ZEO/ZODB issues

    drs, Jul 12, 2003, in forum: Python
    Replies:
    0
    Views:
    329
  2. Almad

    IndexedCatalog and ZEO

    Almad, Mar 6, 2005, in forum: Python
    Replies:
    4
    Views:
    384
    Almad
    Mar 7, 2005
  3. Paul Boots
    Replies:
    0
    Views:
    337
    Paul Boots
    Jun 21, 2005
  4. Paul Boots
    Replies:
    0
    Views:
    282
    Paul Boots
    Jun 21, 2005
  5. Almad
    Replies:
    0
    Views:
    297
    Almad
    Jun 24, 2005
Loading...

Share This Page