[Python-checkins] python/dist/src/Lib/plat-mac aetools.py,1.7,1.8 gensuitemodule.py,1.8,1.9

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Fri, 13 Jun 2003 07:27:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv32513

Modified Files:
	aetools.py gensuitemodule.py 
Log Message:
- 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)



Index: aetools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/aetools.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** aetools.py	9 Apr 2003 13:25:42 -0000	1.7
--- aetools.py	13 Jun 2003 14:27:35 -0000	1.8
***************
*** 155,159 ****
          return 1
      __ensure_WMAvailable = classmethod(__ensure_WMAvailable)
! 
      def __init__(self, signature=None, start=0, timeout=0):
          """Create a communication channel with a particular application.
--- 155,159 ----
          return 1
      __ensure_WMAvailable = classmethod(__ensure_WMAvailable)
!     
      def __init__(self, signature=None, start=0, timeout=0):
          """Create a communication channel with a particular application.
***************
*** 285,288 ****
--- 285,300 ----
      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
  

Index: gensuitemodule.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/gensuitemodule.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** gensuitemodule.py	16 Apr 2003 13:10:53 -0000	1.8
--- gensuitemodule.py	13 Jun 2003 14:27:35 -0000	1.9
***************
*** 524,527 ****
--- 524,528 ----
  
      # 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")
***************
*** 530,535 ****
--- 531,539 ----
              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]))
***************
*** 539,542 ****
--- 543,549 ----
          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()
  
***************
*** 967,978 ****
                  self.fp.write('    want = %s\n' % `code`)
          self.namemappers[0].addnamecode('class', pname, code)
          properties.sort()
          for prop in properties:
!             self.compileproperty(prop)
          elements.sort()
          for elem in elements:
              self.compileelement(elem)
      
!     def compileproperty(self, prop):
          [name, code, what] = prop
          if code == 'c@#!':
--- 974,986 ----
                  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, is_application_class)
          elements.sort()
          for elem in elements:
              self.compileelement(elem)
      
!     def compileproperty(self, prop, is_application_class=False):
          [name, code, what] = prop
          if code == 'c@#!':
***************
*** 994,997 ****
--- 1002,1007 ----
                  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):