Thread: [Pyobjc-dev] PyObjC newbie questions
Brought to you by:
ronaldoussoren
From: Gary R. <gro...@tr...> - 2003-05-03 21:21:06
|
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? 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. 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? Thank you in advance for any and all insight... --Gary -- [http://ThisURLEnablesEmailToGetThroughOverzealousSpamFilters.org] Gary Robinson CEO Transpose, LLC gro...@tr... 207-942-3463 http://www.transpose.com http://radio.weblogs.com/0101454 |
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 |
From: Gary R. <gro...@tr...> - 2003-05-04 01:07:06
|
Ronald, Many thanks for your input! I think the AppleScript part shouldn't be a problem because I believe Cocoa supplies the means to create AppleEvents, so I should be use Cocoa for that part... Another thing, though. What about people who are running 10.1? Is it possible to include the Python interpreter itself in the app using buildapp.py so that such a user doesn't need to already have Python? --Gary -- [http://ThisURLEnablesEmailToGetThroughOverzealousSpamFilters.org] Gary Robinson CEO Transpose, LLC gro...@tr... 207-942-3463 http://www.transpose.com http://radio.weblogs.com/0101454 > From: Ronald Oussoren <ous...@ci...> > Date: Sun, 4 May 2003 01:10:02 +0200 > To: Gary Robinson <gro...@tr...> > Cc: <pyo...@li...> > Subject: Re: [Pyobjc-dev] PyObjC newbie questions > > > 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 > |
From: Ronald O. <ous...@ci...> - 2003-05-04 08:41:58
|
On Sunday, May 4, 2003, at 03:06 Europe/Amsterdam, Gary Robinson wrote: > Ronald, > > Many thanks for your input! > > I think the AppleScript part shouldn't be a problem because I believe > Cocoa > supplies the means to create AppleEvents, so I should be use Cocoa for > that > part... > > Another thing, though. What about people who are running 10.1? Is it > possible to include the Python interpreter itself in the app using > buildapp.py so that such a user doesn't need to already have Python? builapp.py uses the bundlebuilder module which supports creating standalone applications ('buildapp.py --standalone build'). The bad news is that PyObjC currently doesn't work on 10.1, mostly because none of the developers have access to a 10.1 system. Ronald |
From: Gary R. <gro...@tr...> - 2003-05-04 13:38:04
|
> The bad > news is that PyObjC currently doesn't work on 10.1, mostly because none > of the developers have access to a 10.1 system. Hmm. Too bad it didn't happen to work on 10.1 anyway. But it is hard to keep extra machines around with obsolete OS's. If I don't use PyObjC for this app I'll definitely look forward to using it when more of the user base can access such apps. But for this application I think I can't afford to lose the 10.1 user base... Let me ask a quick somewhat off-topic question. Online I saw an example, I think from Apple, of an AppleScript Studio application that invoked a Perl daemon to do stuff that Perl was more capable of doing... communication was via SOAP (using AppleScript's SOAP calls on the AppleScript Studio side). It seemed quite easy. That seems like an approach I could take for this, except using a Python app as the daemon. The AppleScript Studio app would invoke it and tell it to shut itself down when it isn't needed. Do you know if I can write a Python app of that nature and bundle it with the Python interpreter into a single executable under 10.1 and 10.2? Would other python installations the user may have interfere in any way? Any problem with making such an app "faceless" in the sense of having no presence in the dock? Many thanks for all your help! --Gary -- [http://ThisURLEnablesEmailToGetThroughOverzealousSpamFilters.org] Gary Robinson CEO Transpose, LLC gro...@tr... 207-942-3463 http://www.transpose.com http://radio.weblogs.com/0101454 |