Kairen Tan wrote:

I’m trying to write some python to consume events from an Event Handler….without much success.

I’m using a class created using makepy, and on inspecting the file, there is a block of commented code like:

# Event Handlers
# If you create handlers, they should have the following prototypes:
#def OnBeforeOpen(self, oRecord=defaultNamedNotOptArg):
#def OnBeforeSave(self, oRecord=defaultNamedNotOptArg, bCancel=defaultNamedNotOptArg):
#def OnAfterSave(self, oRecord=defaultNamedNotOptArg):
#def OnBeforeDelete(self, oRecord=defaultNamedNotOptArg, bCancel=defaultNamedNotOptArg):
#def OnCloseRecord(self):
#def OnAfterDelete(self, lDatabaseID=defaultNamedNotOptArg, sImportID=defaultNamedNotOptArg):

*My question is simply, how do I implement this? *
*
*
I’ve tried using win32com.server.register.RegisterServer, but I’m stumped as to what comes after that.

It would have been helpful if you had told us what server you were trying to work with here.

You don't need to register yourself as a server.  Registration is only needed if someone else is going to look for your object by its CLSID, but that's not the case here.  There's really no such thing as an "event handler" in COM.  I'm guessing that the server you're working with wants you to hand it a COM interface, and it will call methods of that COM interface when certain events occur.

So, you need to use the magic _reg_ names so that win32com recognizes you as a COM object, but after that, all you should need to do is create an instance of your object, and pass it to whatever method your server uses to register the callback object.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to