[Pythonmac-SIG] package structure for OSA interfaces

Michael J. Barber mjb@uma.pt
Mon, 21 Jan 2002 17:40:23 +0000


I've been taking a closer look at the structure of the packages produced 
by gensuitemodule. I'm a bit confused about the logic of the Standard 
Suites package. The StdSuites package is used to build packages for 
other applications, so is a fundamental part of gensuitemodule. As far 
as I can tell, the structure is suboptimal; hopefully someone can let me 
know what I'm missing, if anything.

The modules I'm concerned with are StdSuites.Required_Suite and 
StdSuites.Standard_Suite. The required events are open, run, print, and 
quit. These four events are defined in Pythonic terms in 
StdSuites.Standard_Suite rather than StdSuites.Required_Suite. Apps that 
define the required events in their 'AppleScript Dictionary' work fine 
with this approach.

However, many apps don't specify the required events, just relying on 
the default behavior (how that's done in terms of the apps' resources, I 
don't know) for AppleScript. For Python, gensuitemodule overlooks these 
four events, so that basic functionality is missing. One way to get that 
functionality is to copy the definitions for the required events from 
StdSuites.Standard_Suite into the Required_Suite for the app. It is also 
necessary to copy the _Enum_savo dictionary and the _enumdeclaration for 
'savo' in order to get quit to work properly.

I learned this trick from this list some time ago, and have applied it 
myself to a couple of apps since. It works, but I think there is a 
better way. If those definitions are in StdSuites.Required_Suite, then 
every app has them, no editing needed. It doesn't matter if the required 
events are also defined in StdSuites.Standard_Suite - no harm done 
either way. I've tried this out some, and it seems to work just fine.

Another advantage to this set up is that we could easily generate 
interfaces for 'unscriptable' apps (which respond to the four required 
events regardless). All that would be needed is to include a skeleton 
for the __init__.py file, which can be changed to get the correct 
application signature, and maybe a 'friendlier' name for the main class.

The only downside that I can see to defining the required events in 
StdSuites.Required_Suite is that gensuitemodule doesn't currently 
generate the appropriate structure, so if someone were to rebuild 
StdSuites, they'd have a problem. I've briefly looked through the source 
for gensuitemodule.py to see if that could be changed, but do not yet 
understand it well enough to say. Given a little more free time, I'll 
dig deeper.

Does this make sense? Am I missing something important, or would this be 
a real improvement?

--
Michael