20 Aug 2003 (updated 20 Aug 2003 at 17:21 UTC)
»
Okay, so it's been a while, and I've got an entry from ages ago that I was going to post, but that'll have to wait...
Isn't it always the way...
Heh, unbelievable, I've just spent a huge chunk of time trying to work out how to access Mac OS X Rendezvous (ZeroConf) functionality via Apple Cocoa APIs with pyobjc. Anyway, between trying to learn to read Objective-C, working out how pyobjc interacts with it and understanding the Rendezvous API I wasn't making much progress...
In fact, it turns out I wasn't too far off.
I just needed to discover NSRunLoop.currentRunLoop().run() (yeah, okay so I needed to walk before I tried to run... (excuse the pun)) and an underscore character.
An underscore character? Yep, my object instance had a method named netServiceBrowserWillSearch but it should have been netServiceBrowserWillSearch_.
I must find out if there's a way to find out what methods are attempting to be called. With Objective-C's use of ':' and subsequent conversion for Python to '_' it all gets somewhat confusing...
Oh, and how did I discover all this in the end? Oh, that's easy, I just looked at rendezvous.py a sample that can be found in the examples directory of the pyobjc distribution! I do have a little bit of an excuse since I installed pyobjc via the MacPython Package Manager, and I don't think it installs the examples... Still, I should have looked in the pyobjc cvs reposistory earlier...
I think I've learned a bit in the process though.
Unfortunately I couldn't get the Python Rendevouz implementation I found to run successfully, despite trying it on Linux, Windows 98 and XP. I also couldn't use it on Mac OS X because it can't cooperate with the implementation that's already there.
All I really wanted was to be able to browse things, in a somewhat cross-platform Python way, but it looks like more work is required.
I also could not get jrendezvous to work successfully between machines. In the end I used the sample mDNSPosix code from Apple successfully under Linux to publish details of services that my Mac OS X machine could find.
Update...
Google-bait: In pyobjc if the string representation of an object is of the following form:
<native-selector name of <NSNetService objective-c instance 0x134780>>
it means (as far as I've figured it...) that you are accessing something (in this case name) incorrectly as an attribute instead of as a method. (So I assume a "native-selector" is Objective-C speak for something like a Python method.)
It probably also means you should get some sleep... :-)