[Pythonmac-SIG] Re: NotificationCenter, NSConnection, distributed notifications

Jack Jansen Jack.Jansen at cwi.nl
Tue Sep 23 06:34:48 EDT 2003


Are you running from a .app bundle?

I've never used NSConnection, so I'm not sure whether it requires all 
the magic that .app bundles set up,
but if there is anything in it that could need access to the window 
manager you want to run from a .app
bundle.

An easy way to test this is to turn the Python script that uses this 
into an applet with BuildApplet,
and if that magically makes it work then this is the answer.

And, of course, as a final note, you shouldn't write this in ObjC to 
start with, but do everything in
Python with PyObjC:-)

On Tuesday, September 23, 2003, at 06:30 AM, Python Development wrote:

> Hi,
>
> I was wondering if anyone knew anything about what I am about to 
> describe.
>
> I have a python program that has a c module which interfaces with 
> objective-C code.  Yes, it can be done.
>
> The purpose of this program is to interface with UIs built by third 
> parties and use distributed objects for messaging.  With a defined 
> protocol, the UI is able to setup a NotificationCenter and hoped to 
> communicate with our python/c module/Objective-C app.  While we have 
> tested our UI with two different objective-C test programs, we have 
> yet to get the Objective-C test app to communicate with the python/c 
> module/Objective-C app.
>
> Currently, we have found that  the following code does create a 
> TESTServer.  In fact, if we try to run the other Objective-C program 
> which registers a TESTServer, we get the error "Error registering 
> PACEServer".
>
>
> @interface MYTestServer : NSObject <aProtocol> {
> }
> @end
> MYTestServer		*server;
> NSConnection		*defaultConnection;
> NSAutoreleasePool	*pool;
>
>
> 	server = [[MYTestServer alloc] init];
> 	pool = [[NSAutoreleasePool alloc] init];
>
> 	defaultConnection = [NSConnection defaultConnection];
> 	[[NSNotificationCenter defaultCenter] addObserver:server
> 		selector:@selector(connectionDidDie:)
> 		name:NSConnectionDidDieNotification
> 		object:nil];
>
> 	[defaultConnection setRootObject:server];
> 	if ([defaultConnection registerName:@"TESTServer"] == NO) {
> 		NSLog(@"Error registering PACEServer");
> 	}
>
> However, the TestUI  fails when it reaches the following line when the 
> python/c module/Objective-C app server is running.  It works, with the 
> other non-python test program.
>
> server = [[NSConnection 
> rootProxyForConnectionWithRegisteredName:@"TESTServer" host:nil] 
> retain];
>
>
>
>
> Question:
>
> 1) has anyone ever got something like this to work?
> 2) is it even possible? -- so I can tell my boss and work from a 
> backup plan.
> 3) what am I doing wrong?
> 4) are you going to vote for the CA recall?
>
>
> Thank you in advance,
> Randy
>
>
>
>
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman




More information about the Pythonmac-SIG mailing list