diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-06-13 14:27:35 +0000 |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-06-13 14:27:35 +0000 |
commit | c8882b10c490298c670cec8ad6239acfaf14a66a (patch) | |
tree | 71720a8fb0344f58045743bee501a2925951b990 /Lib/plat-mac | |
parent | SF bug #753602: random.sample not properly documented (diff) | |
download | cpython-c8882b10c490298c670cec8ad6239acfaf14a66a.tar.gz cpython-c8882b10c490298c670cec8ad6239acfaf14a66a.tar.bz2 cpython-c8882b10c490298c670cec8ad6239acfaf14a66a.zip |
- Allow access to poperties of the "application" OSA class directly from
the toplevel package. This already worked for elements, but now for
properties too. Fixes #753925.
- Even better, the toplevel class (such as Finder.Finder) now inherits
the element and property dictionaries of its application class and has
the necessary glue to allow you to say
f = Finder.Finder()
f.get(f.name)
Diffstat (limited to 'Lib/plat-mac')
-rw-r--r-- | Lib/plat-mac/aetools.py | 14 | ||||
-rw-r--r-- | Lib/plat-mac/gensuitemodule.py | 14 |
2 files changed, 25 insertions, 3 deletions
diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py index 79b806964c0..92d6ec90e40 100644 --- a/Lib/plat-mac/aetools.py +++ b/Lib/plat-mac/aetools.py @@ -154,7 +154,7 @@ class TalkTo: Evt.WaitNextEvent(0,0) return 1 __ensure_WMAvailable = classmethod(__ensure_WMAvailable) - + def __init__(self, signature=None, start=0, timeout=0): """Create a communication channel with a particular application. @@ -284,6 +284,18 @@ class TalkTo: set = _set + # Magic glue to allow suite-generated classes to function somewhat + # like the "application" class in OSA. + + def __getattr__(self, name): + if self._elemdict.has_key(name): + cls = self._elemdict[name] + return DelayedComponentItem(cls, None) + if self._propdict.has_key(name): + cls = self._propdict[name] + return cls() + raise AttributeError, name + # Tiny Finder class, for local use only class _miniFinder(TalkTo): diff --git a/Lib/plat-mac/gensuitemodule.py b/Lib/plat-mac/gensuitemodule.py index a5a994cd5d1..0667e9f2eea 100644 --- a/Lib/plat-mac/gensuitemodule.py +++ b/Lib/plat-mac/gensuitemodule.py @@ -523,14 +523,18 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None, fp.write("getbaseclasses(%s)\n" % v) # Generate a code-to-name mapper for all of the types (classes) declared in this module + application_class = None if allprecompinfo: fp.write("\n#\n# Indices of types declared in this module\n#\n") fp.write("_classdeclarations = {\n") for codenamemapper in allprecompinfo: for k, v in codenamemapper.getall('class'): fp.write(" %s : %s,\n" % (`k`, v)) + if k == 'capp': + application_class = v fp.write("}\n") + if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) for code, modname in suitelist[1:]: @@ -538,6 +542,9 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None, fp.write(",\n aetools.TalkTo):\n") fp.write(" _signature = %s\n\n"%`creatorsignature`) fp.write(" _moduleName = '%s'\n\n"%packagename) + if application_class: + fp.write(" _elemdict = %s._elemdict\n" % application_class) + fp.write(" _propdict = %s._propdict\n" % application_class) fp.close() class SuiteCompiler: @@ -966,14 +973,15 @@ class ObjectCompiler: self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(desc))) self.fp.write(' want = %s\n' % `code`) self.namemappers[0].addnamecode('class', pname, code) + is_application_class = (code == 'capp') properties.sort() for prop in properties: - self.compileproperty(prop) + self.compileproperty(prop, is_application_class) elements.sort() for elem in elements: self.compileelement(elem) - def compileproperty(self, prop): + def compileproperty(self, prop, is_application_class=False): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. @@ -993,6 +1001,8 @@ class ObjectCompiler: self.fp.write(" which = %s\n" % `code`) self.fp.write(" want = %s\n" % `what[0]`) self.namemappers[0].addnamecode('property', pname, code) + if is_application_class and self.fp: + self.fp.write("%s = _Prop_%s()\n" % (pname, pname)) def compileelement(self, elem): [code, keyform] = elem |