[Pythonmac-SIG] Re: FileMaker Pro and Python
Jack Jansen
jack@oratrix.nl
Wed, 04 Apr 2001 10:59:33 +0200
> > listOitems = dataPuller.database ##doesn't work, Can't even get
> >access to the database
>
> For the equivalent of the AppleScript
> set myVar to cell 21 of record 1 of database 1
>
> try in Python
> from FileMaker import cell, record, database
> myVar = dataPuller._get(cell(21, record(1, database())))
>
> This MIGHT also work
> myVar = dataPuller._get(database().record(1).cell(21))
I would really really like this last line to be written as
myVar = dataPuller.database.record[1].cell[21]._get()
I think that the current Python OSA setup has enough information to pull this
off, in almost the right form. If the main class for an application (the one
that is defined in the __init__.py module in the package) would include the
"application" class (usually defined in the Standard_Suite submodule, I think)
then we're half-way there.
The one extra thing we need is a mixin class which allows attribute access to
objects. It would have a __getattr__ method which would lookup the
attributename in self._propdict. If the attribute is found it would
instantiate the class (which will be a subclass of ObjectSpecifier and this
same mixin class) with self as the "fr" parameter (which stands for "from").
If it isn't found it would retry the lookup in self._elemdict, and if the
attribute was found there it would instantiate an ElementSelector object (this
class is yet to be written) with parameters element class and self. The
ElementSelector provides a __getitem__ method, which instantiates the element
class object.
All this would allow something like
objref = dataPuller.database.record[1].cell[21]
myVar = dataPuller._get(objref)
To go the final bit the ObjectSpecifier class would also need a __getattr__
method. It would traverse the self.fr links up to the application object
(dataPuller, in our case), lookup the attribute there and create a callable
object that will pass self as first argument upon __call__.
But as AppleScript isn't my primary focus right now if y'all wait for me to
write this stuff it can be a while. Anyone care to step in?
--
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm