CVS: anygui/lib/anygui Attribs.py,1.16,1.17 Proxies.py,1.20,1.21

Samuele Pedroni <[email protected]> Tue, 10 Sep 2002 18:03:09 -0700
Newsgroups gmane.comp.python.anygui.cvs
Message-ID <[email protected]>
Update of /cvsroot/anygui/anygui/lib/anygui
In directory usw-pr-cvs1:/tmp/cvs-serv1705

Modified Files:
	Attribs.py Proxies.py 
Log Message:
proxy.wrapper moved outside state, now just a plain attribute.

Added support for plain attributes in Attrib, through rawDictSet,
self.__dict__.has_key[attr_name] logic in __setattr__.



Index: Attribs.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Attribs.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** Attribs.py	10 Sep 2002 20:17:20 -0000	1.16
--- Attribs.py	11 Sep 2002 01:03:06 -0000	1.17
***************
*** 2,7 ****
  from Utils import getGetter,getSetter,getterName
  
! # FIXME: Add mechanism for internal attributes (not in state[]). Uses
! # _foo naming convention for now...
  
  # New functionality: if methods set<Attrib> or get<Attrib> are
--- 2,12 ----
  from Utils import getGetter,getSetter,getterName
  
! # DONE: Add mechanism for internal attributes (not in state[]). Uses
! # _foo naming convention for now...::
! # @@@ use rawDictSet('attr',val) (put attr in __dict__) in subclass __init__
! # then attrib.attr will get the right value
! # and __setattr__ logic has been changed so that attrib.attr = val
! # will do the right thing (check whether attr in __dict__)
! 
  
  # New functionality: if methods set<Attrib> or get<Attrib> are
***************
*** 24,29 ****
      def pull(self,*names): pass
  
      def __setattr__(self, name, value):
!         if name == 'state' or name[0] == '_':
              self.__dict__[name] = value
          else:
--- 29,37 ----
      def pull(self,*names): pass
  
+     def rawDictSet(self,name,value):
+         self.__dict__[name] = value
+ 
      def __setattr__(self, name, value):
!         if name == 'state' or name[0] == '_'or self.__dict__.has_key(name):
              self.__dict__[name] = value
          else:
***************
*** 49,52 ****
--- 57,61 ----
                  self._getstack.append(name)
                  try:
+                     #print "attrib-pull",name # @@@ debug
                      self.pull(*(name,))
                  finally:
***************
*** 54,57 ****
--- 63,67 ----
          except (AttributeError,KeyError):
              pass
+         #print "attrib-from-state",name # @@@ debug
          return self.state[name]
  

Index: Proxies.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Proxies.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** Proxies.py	10 Sep 2002 20:17:20 -0000	1.20
--- Proxies.py	11 Sep 2002 01:03:06 -0000	1.21
***************
*** 5,16 ****
      # TBD: Add docstring for class
  
!     _wrapper_set = 0 # FIXME: if set get refactored out from Attrib.__init__
!                      # it would be no longer necessary
  
      def __init__(self, *args, **kwds):
          Attrib.__init__(self, *args, **kwds)
          self.rawSet(container=None)
!         self.rawSet(wrapper=self.wrapperFactory()) # wrapper in state ?
!         self._wrapper_set = 1 # FIXME
          self.push() # Hm... Move to wrapper.internalProd?
  
--- 5,15 ----
      # TBD: Add docstring for class
  
!     wrapper = None # so self.wrapper is always OK
  
      def __init__(self, *args, **kwds):
          Attrib.__init__(self, *args, **kwds)
          self.rawSet(container=None)
!         # this way we have a plain wrapper attribute
!         self.rawDictSet('wrapper',self.wrapperFactory())
          self.push() # Hm... Move to wrapper.internalProd?
  
***************
*** 54,58 ****
          with the result.
          """
!         if not self._wrapper_set: return
          # Never pull if our widget is non-existent - we need
          # to keep all proxy state until a real widget
--- 53,57 ----
          with the result.
          """
!         if not self.wrapper: return
          # Never pull if our widget is non-existent - we need
          # to keep all proxy state until a real widget
***************
*** 84,91 ****
            
          """
          # We may need to modify names, so...
          names = list(names)
          ## @@@ unused self.internalPush(names) # @@@ May no longer be needed
-         if not self._wrapper_set: return
          self.wrapper.push(self._partialState(*names,**kwds))
  
--- 83,90 ----
            
          """
+         if not self.wrapper: return
          # We may need to modify names, so...
          names = list(names)
          ## @@@ unused self.internalPush(names) # @@@ May no longer be needed
          self.wrapper.push(self._partialState(*names,**kwds))
  
***************
*** 112,116 ****
          # FIXME: try/except not really acceptable... (Create backlog?
          # Rearrange __init__ stuff to avoid loop?
!         if not self._wrapper_set: return
          self.wrapper.enableEvent(event)
  
--- 111,115 ----
          # FIXME: try/except not really acceptable... (Create backlog?
          # Rearrange __init__ stuff to avoid loop?
!         if not self.wrapper: return
          self.wrapper.enableEvent(event)
  
***************
*** 122,125 ****
          where a native widget must be explicitly destroyed.
          """
!         assert self._wrapper_set,"?! absent wrapper in proxy" # @@@ can wrapper be absent/non set?
          self.wrapper.destroy()
--- 121,125 ----
          where a native widget must be explicitly destroyed.
          """
!         assert self.wrapper,"?! absent wrapper in proxy"
          self.wrapper.destroy()
+         # @@@ do we need del self.wrapper here ?



-------------------------------------------------------
In remembrance
www.osdn.com/911/