CVS: anygui/lib/anygui Models.py,1.19,1.20 Proxies.py,1.22,1.23
"Dallas T. Johnston" <[email protected]> Tue, 24 Sep 2002 08:28:31 -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-serv26679/lib/anygui
Modified Files:
Models.py Proxies.py
Log Message:
Fixed *most* of the bugs... Only the BooleanModel doesn't want to work because of recursion when updating the model in pull/push.
Index: Models.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Models.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Models.py 24 Sep 2002 01:25:42 -0000 1.19
--- Models.py 24 Sep 2002 15:28:29 -0000 1.20
***************
*** 9,12 ****
--- 9,14 ----
class Assignee:
+ _locked = 0
+
def __init__(self):
self.names = []
***************
*** 25,31 ****
self.names.remove(name)
def send(self, **kwds):
! for object in self.objects:
! object.push(names=self.names)
send(self, **kwds)
--- 27,40 ----
self.names.remove(name)
+ def lockPush(self):
+ self._locked = 1
+
+ def unlockPush(self):
+ self._locked = 0
+
def send(self, **kwds):
! if self._locked == 0:
! for object in self.objects:
! object.push(names=self.names)
send(self, **kwds)
***************
*** 65,68 ****
--- 74,78 ----
def setValue(self, value):
self.data[:] = list(value)
+ self.send()
def getValue(self):
Index: Proxies.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Proxies.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** Proxies.py 24 Sep 2002 01:25:42 -0000 1.22
--- Proxies.py 24 Sep 2002 15:28:29 -0000 1.23
***************
*** 7,11 ****
wrapper = None # so self.wrapper is always OK
! installedModels = {}
def __init__(self, *args, **kwds):
--- 7,11 ----
wrapper = None # so self.wrapper is always OK
! _installedModels = {}
def __init__(self, *args, **kwds):
***************
*** 64,77 ****
# ==== MODEL SUPPORT ==== #
- # This is the logic that needs to go into ModelDelegate,
- # but that might break encapsulation...
- # -----------------------------------------------------
# After we have pulled the actual values from the widget,
# We need to update all installed models with them.
for prop in state:
try:
! model = self.installedModels[prop]
! # lazy update of model... should this be done??
! # model.setValue(state[prop])
state[prop] = model
except:
--- 64,77 ----
# ==== MODEL SUPPORT ==== #
# After we have pulled the actual values from the widget,
# We need to update all installed models with them.
for prop in state:
try:
! model = self._installedModels[prop]
! # locked update of model, this keeps model
! # from calling proxy.push
! model.lockPush()
! model.setValue(state[prop])
! model.unlockPush()
state[prop] = model
except:
***************
*** 107,120 ****
# ==== MODEL SUPPORT ==== #
- # This is the logic that needs to go into ModelDelegate,
- # but that might break encapsulation...
- # -----------------------------------------------------
- # After we have pulled the actual values from the widget,
- # We need to update all installed models with them.
state = self._partialState(*names,**kwds)
for prop in state:
try:
! model = self.installedModels[prop]
! model.setValue(state[prop])
state[prop] = model
except:
--- 107,120 ----
# ==== MODEL SUPPORT ==== #
state = self._partialState(*names,**kwds)
for prop in state:
try:
! model = self._installedModels[prop]
! # if state[prop] is not the model, this means that rawSet
! # has changed the value, thus we need to sync model
! if state[prop] is not model:
! model.lockPush()
! model.setValue(state[prop])
! model.unlockPush()
state[prop] = model
except:
***************
*** 163,171 ****
def installModel(self, obj, name, model):
! self.installedModels[name] = model
model.installed(obj, name)
def removeModel(self, obj, name):
! self.installedModels[name].removed(obj, name)
! del self.installedModels[name]
--- 163,179 ----
def installModel(self, obj, name, model):
! if self._installedModels.has_key(name):
! self.removeModel(obj, name)
! self._installedModels[name] = model
! # need to call rawSet to avoid use of default when
! # wrapper doesn't exist and user manipulates the model
! self.rawSet(**{name:model})
model.installed(obj, name)
def removeModel(self, obj, name):
! try:
! self._installedModels[name].removed(obj, name)
! del self._installedModels[name]
! except:
! pass
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf