Mark Greenbank said:
> Has anyone successfully used the LISTEN/NOTIFY constructs with a
> PyGreSQL client?

I've hacked the pgdb module slightly to support notify:

--------------------- module pgdb_extended --------------------
#"from _ import" needed to override member of pgdb.
from pgdb import *

def getnotify(self):
        # Sigh -- this does break the official Python DB-API...
        return self._pgdbCnx__cnx.getnotify()

pgdbCnx.getnotify = getnotify
-------------------------------------------------------------

Then just import pgdb_extended instead of pgdb.

This getnotify function just *gets* notify info if it has been sent
by the server.  This only happens after a commit(as I understand it).
I'm running a pygtk GUI app, so I do something like:

def alerted(notify_tag, wid=mainwindow.menu, name=r.name):
        pigdb.commit()
        notify = pigdb.db_conn().getnotify()
        if notify and notify[1] != pigdb.backend_pid:
                do_something(notify_tag)

notify_poll_frequency = 15  # seconds between polls.
gobject.timeout_add(1000 * notify_poll_frequency, alerted, 'notify')


I hope this helps,

-- George Young
-- 
"Are the gods not just?"  "Oh no, child.
What would become of us if they were?" (CSL)
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to