[Pythonmac-SIG] FBAs with bundlebuilder?

has hengist.podd at virgin.net
Mon Sep 13 01:26:49 CEST 2004


Hi folks,

Just had a cracking idea for stealth-selling MacPython to 
AppleScripters: provide an easy way to create scriptable faceless 
background applications in Python. Far faster than executing Python 
scripts via 'do shell script', far easier than writing C-based 
osaxen. Basically a terminology-driven wrapper around aem.receive 
that allows users to define their own application commands and 
enumerations in a bundlebuilder-based FBA that they can then drop 
into their ScriptingAdditions folder and call from AppleScripts. 
AppleScripters are perenially starved for decent language extension 
mechanisms, so I can see them potentially going nuts for something 
like this - and once we've got that first hook into them we can 
gradually start selling them on Python as a general alternative to 
AppleScript. Subverting and stealing their users by the back door, if 
you like. ;)

I'm working on the API at the moment, mostly trying to figure the 
best way to incorporate scripting terminology - I'm thinking 
decorators might be a good way to provide callbacks with metadata 
that can be retrieved automatically via introspection, allowing users 
to write stuff like:

__name__ = 'Foo.app'

class ae_SomeSuite:
	ae_suiteinfo = '????', 'Some Suite', 'Various commands and stuff.'

	@ae_handler('Pyth', 'Mult', 'multiply_string', 'Multiply a string',
			('The result.', 'TEXT'),
			('----', 'direct', 'The string to multiply.', 'TEXT'),
			('Cnte', 'by', 'Number of times to multiply 
the string (default=2).', 'long', kOptional))
	def ae_multiply(self, direct, by=2):
		try:
			return AEResult(direct * by)
		except:
			return AEError(-1700)


The can then drag-n-drop this script onto an applet that 
automatically generates an FBA titled 'Foo.app' ready for use.

The app generates an aete on demand when it receives an <<event 
ascrgdte>>, so users don't need to create their own terminology 
resources; e.g. the above example would produce the following 
terminology:

	Some Suite : Various commands and stuff.

	multiply string : Multiply a string.
		multiply string string -- The string to multiply.
			[by : integer] -- Number of times to multiply 
the string (default=2).
		Result : string -- The result.


What I mostly need right at the moment is a way to create FBAs from 
bundlebuilder, or something similar in Cocoa/ObjC would do just as 
well (though I'd want to avoid PyObjC to keep the number of 3rd-party 
dependencies down). If anyone knows how to do this, or can provide me 
with something suitable, it'd be a great help. Once I've finalised 
the API (won't be long), I can hammer out some examples and 
propaganda and we can start selling it to the AS community.

Cheers,

has
-- 
http://freespace.virgin.net/hamish.sanderson/


More information about the Pythonmac-SIG mailing list