Re: [Pyobjc-dev] Re: FYI: Open Source Scripting Layer For Cocoa
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-06-13 09:26:00
|
Ronald Oussoren wrote: > > Ok, that's nice for a more involved example, but not for "embedding > > Python in ObjC 101". Too ba, I'll try and come up with something > > else:-) > > There is an XML-RPC library in 2.2 and 2.3, xmlrpc.org lists a number > of public services (from a currentTime function at Userland to Meercat > at O'Reilly). The WebServicesTool example demonstrates xmlrpc already quite well. However, it's a rather elaborate demo, so a simpler one would be very useful as well. That said, I feel quite strongly that any networking Cocoa app should either use asynchronous I/O or threads, which complicates the matter quite a bit. It's possible to run a twisted reactor (= twisted event loop) in a different thread (I've briefly played with that, works like a charm). It *might* be possible to build a twisted reactor that's integrated with the main Cocoa event loop, but that is likely quite hard. The WebServicesTool demo uses xmlrpclib in a worker thread (in CVS at least, I recently did a lot of work on it), but the complicatated thing about it is that as soon as you use Cocoa stuff from a different thread, you have to deal with autorelease pools. I've found it impossible to do even the simplest Cocoa things (eg obj.performSelectorOnMainThread_etc.) in PyObjC without implicitly creating autoreleased objects, so you don't really get around wrapping your code in NSAutoreleasePool.pyobjcPushPool() / NSAutoreleasePool.pyobjcPopPool() blocks. See WebServicesTool for how that's done. Just |