[Pythonmac-SIG] advanced newbie questions

steve harley garbanzito at mac.com
Tue Jan 27 13:58:48 EST 2004


i'm learning Python, evaluating it for replacing a workflow that is now  
half in Visual FoxPro, half in UserLand Frontier (running in Virtual PC  
& Classic respectively under Mac OS X 10.3.2).. given that i find both  
of those environments very fluid and powerful, but dislike having to  
use VPC and Classic, Python looks very promising.. it has a coding feel  
much like Frontier, though i miss coding in an outliner; has anyone  
found a way to do this for Python, which is so obviously suited?

since the Frontier part of this workflow heavily exercises the AE  
capabilities of publishing apps, i was curious to see how Python  
stacked up.. i read through the recent thread on abstracting the AE  
functionality, and a few other threads, and got the impression that  
there are multiple paths, and all are essentially in beta.. by the way,  
coming from strong familiarity with Mac scripting, that thread really  
helped me grasp the richness of Python, as it touched on several  
under-the-hood aspects that intro texts ignore

anyhow, AppScript looked like the easiest transition from Frontier's  
object model, so i got the latest version and installed it.. i  
immediately found a dependency on launchservices.py, so i installed the  
latest SourceForge version

now i'm stuck just instantiating an application object.. test.py  
contains:

  import AppScripting as AS
  Finder = AS.app ("Finder")

and gives this error when i run it:

% pythonw test.py
Traceback (most recent call last):
   File "test.py", line 2, in ?
     Finder = AS.app ("Finder")
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/Main.py", line 141, in app
     targetDesc, aeteList, aeTable = _prepareApp(appPathOrName)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/Main.py", line 122, in _prepareApp
     appPath = _fullPathToApp(appPathOrName)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/Main.py", line 18, in  
_fullPathToApp
     return LaunchServices.FindApplicationPath(name=appPathOrName)
AttributeError: 'module' object has no attribute 'FindApplicationPath'

seeing a path problem, i tried "/Applications/Finder.app" and got a  
somewhat similar error:

% pythonw test.py
Traceback (most recent call last):
   File "test.py", line 2, in ?
     Finder = AS.app ("/Applications/Finder.app")
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/Main.py", line 141, in app
     targetDesc, aeteList, aeTable = _prepareApp(appPathOrName)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/Main.py", line 123, in _prepareApp
     targetDesc = AEInterface.establishConnection(appPath)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/AEInterface.py", line 81, in  
establishConnection
     targetDesc = _makeAEAddressDesc(appPath)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/AEInterface.py", line 32, in  
_makeAEAddressDesc
     return _makeAddressDescByAppSig(appPath) # TO DO: other ways of  
creating AEAddressDescs
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/AppScripting/AEInterface.py", line 37, in  
_makeAddressDescByAppSig
     sig = LS.GetInfoForPath(appPath,  
LS.LSRequestedInfo.kLSRequestTypeCreator)['creator']
AttributeError: 'module' object has no attribute 'GetInfoForPath'

in both cases it looks like the problem is in a LaunchServices call..  
can someone tell me what's going wrong here? should i be using some  
kind of package management tool?

assuming i can get past this i have some other questions:

i see some people have trouble getting the dictionary from iTunes.. is
AppScript able to do this? if not which AE package should i use? (i'm  
using a small iTunes-related project as an evaluation tool)

i need some practical advice for persistent storage needs..  
unfortunately my workflow depends heavily on both relational and object  
paradigms (SQL in Visual FoxPro, object databases in Frontier; both  
*highly* integrated)

for relational purposes, easiest for me would be SQL back end; bearing  
in mind i'm used to completely integrated, inline SQL, with little  
fiddling or setup required, are there any gotchas or strong positives  
(from the Python on Mac OS X perspective) for MySQL or Postgres? is  
there some other approach which would let me do complex joins and  
many-to-many relations?

for object storage, i get the impression there are various "object  
serialization" approaches.. since i'd probably eventually use PyObjC to  
build interfaces, i'd also consider a Cocoa-based approach.. from  
either the pure Python or Cocoa sides, is there one that stands out?  
what are the performance considerations? (most of my objects are  
probably smaller than 10KB)

for either of these storage needs, are there good abstraction libraries  
so that i could switch storage types later if needed?

thanks very much




More information about the Pythonmac-SIG mailing list