[Pythonmac-SIG] just one apple event

Bill Bedford billpy@mousa.demon.co.uk
Wed, 15 Dec 1999 13:56:38 +0000

At 11:06 am +0100 14/12/99, Jack Jansen wrote:

>>  A word of caution. Python only allocates/can use one transaction
>>  number per session. So if your script calls do_script more than once
>>  it will fail. So far I have only found this to be a problem scripting
>>  Hypercard, where there are lots of alternatives, but YMMV
>this message has a serious sound to it, but that may be because I don't
>understand it:-)

I know the feeling :-)

>Should Python allocate more transaction numbers? Can you give an Inside Mac
>(or other) reference for how this should be done?

I've had a look through Inside Mac: Interactive Communications and 
there are a number of passages like this. (page 3-29)

>  You can specify two other attributes with the AECreateAppleEvent 
>function: the
>  reply ID and the transaction ID. For the reply ID attribute, you 
>usually specify the
>' kAutoGenerateReturnID' constant to the AECreateAppleEvent function. This
>  constant ensures that the Apple Event Manager generates a unique 
>return ID for the
>  reply Apple event returned from the server. For the transaction ID 
>attribute, you usually
>  specify the 'kAnyTransactionID' constant, which indicates that this 
>Apple event is not
>  one of a series of interdependent Apple events.

And this is what Python does class TalkTo() has

	def newevent(self, code, subcode, parameters = {}, attributes = {}):
		"""Create a complete structure for an apple event"""

		event = AE.AECreateAppleEvent(code, subcode, self.target,
		packevent(event, parameters, attributes)
		return event

which looks OK. The problem is the actual appleevent. Capturing the 
same event from Applescript and Python with CaptureAE you get

with applescript:

Process("HyperCard").SendAE "WILD,GO  ,'----':obj {form:name, 
want:type(cSTK), seld:"Suppliers Invoices", from:'null'()}, 

And with Python

Process("HyperCard").SendAE "WILD,GO  ,'----':obj {form:name, 
want:type(cSTK), from:'null'(), seld:"Suppliers Invoices"}, 

Python should be passing a null pointer but isn't. My guess that 
there is a problem with the type of transactionID in the C code -- it 
should be a long int

Is this serious? I don't really think so -- most applications ignore 
the transactionID. It is just a few like Hypercard that seem to check 
it and throw errors when they don't like what they find.

Bill Bedford                            mailto://billb@mousa.demon.co.uk