Re: [Pyobjc-dev] PyObjC newbie questions
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-05-03 23:11:10
|
On Saturday, May 3, 2003, at 23:20 Europe/Amsterdam, Gary Robinson wrote: > Hello everyone, > > I'm a PyObjC newbie hoping to get some info. > > I have a couple decade's worth of programming experience plus solid > experience in Python development on Solaris. > > I have no experience with Cocoa or Objective C. > > I am interested in using PyObjC to create a small Cocoa application, > mostly > because I want to get it done quickly and don't want to have to master > Objective C, and in particular, don't want to deal with reference > counting > etc. Also, I very much like Python's syntax and the libraries that > come with > it. > > It sounds like PyObjC could allow me to do what I want to do, but I > have > some concerns. I am hoping that someone here can address them for me. > > 1) refcounts.html in the PyObjC docs files says "Other than in very > special > situations you should never have to worry about reference counts. Those > special methods mostly seem to involve zombie objects that are no > longer > reachable from normal code, but will perform some action before really > dying > at the end of the current pass through the event loop." > > OK, but does that mean I can do things in such a way that I KNOW that > Python > is handling them? That is, is there a programming style I can use such > that, > if I rigorously follow it, I will know I am not creating the kind of > zombie > object mentioned above, and am not creating other violations the > python-handles-it capability? > > In other words, if I don't take the time to develop a deep > understanding of > Objective C's memory management, can I rely on something other than > random > chance to keep me out of trouble? Or is that knowledge actually > required? You don't have to know about Objective-C's memory management, the bridge performs all memory management you need. The sentence you quote has to do with some deep Objective-C magic, which is nothing you should run in to (it's like metaclasses in Python, they are there but you probably shouldn't tell newbies about them). > > 2) tutorial.html in the docs file says: "It is even possible to > include all > of Python (or, if you are using Apple's Python 2.2, all the bits of > Python > that are non-standard), this gives you an application that is > distributable > to anyone in the world (as long as they have Mac OS X 10.2)! > Unfortunately, > the exact details of this procedure are not streamlined enough for > inclusion > in this tutorial at this point in time." > > OK, but is there a way I can find out how to do it? I would be > creating an > app that I will be hoping a lot of non-developers will download and > run. Some of the example applications include a script named buildapp.py. This will build the application without using Project Builder. If you copy the contents of /usr/lib/python2.2/site-packages/PyObjC into the Resources directory of the application bundle (such as TableModel.app/Contents/Resources for the TableModel example), you'll end up with a standalone application. The same thing should be possible with the Project Builder templates. If I recall correctly those will create standalone applications if you build the install target. > > 3) While I've done an solid amount of Python programming on Solaris, I > have > used it only minimally on the Mac. This app would need to control a > separate > standard OS X app locally via AppleEvents, receive XML-RPC requests > from > other machines, and send XML-RPC requests to other machines. > > Any forseeable problems doing all that with Python's standard > libraries and > PyObjC? XML-RPC should not be a problem, see the example 'WebServicesTool'. I've never used AppleEvents before, I can't say anything about that. I do know that MacPython contains AppleScript related modules, but to use those you probably need to use Python 2.3. Ronald |