dabo Commit
Revision 4941
Date: 2009-01-21 06:27:18 -0800 (Wed, 21 Jan 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/4941
Changed:
U trunk/dabo/lib/eventMixin.py
Log:
This should fix the bug in auto-binding that was reported by Roger Lovelock.
Apparently we had a mechanism to stop looking up the parent hierarchy, but were
not using it!
Diff:
Modified: trunk/dabo/lib/eventMixin.py
===================================================================
--- trunk/dabo/lib/eventMixin.py 2009-01-20 07:00:01 UTC (rev 4940)
+++ trunk/dabo/lib/eventMixin.py 2009-01-21 14:27:18 UTC (rev 4941)
@@ -205,7 +205,7 @@
stop = False
while parent:
lastParent = parent
- self._autoBindEvents(context=parent, force=force)
+ stop = self._autoBindEvents(context=parent, force=force)
if stop:
break
try:
@@ -216,15 +216,17 @@
def _autoBindEvents(self, context, force=False):
- import dabo.dEvents as dEvents
-
+ """This tries to do the actual auto-binding. If returns a bool
to indicate
+ whether the calling process should stop searching for objects
auto-bind
+ opportunities.
+ """
if not (force or dabo.autoBindEvents):
# autobinding is switched off globally
- return
+ return True
if context is None:
# context could be None if during the setting of RegID
property,
# self.Form evaluates to None.
- return
+ return True
regid = None
contextText = ""
@@ -236,9 +238,11 @@
## classes derive directly from dObject.
dColumn, for example.
regid = None
if regid is None or regid == "":
- return
+ return False
contextText = "_%s" % regid
-
+
+ # Do the import here; putting it at the top throws errors while
Dabo is starting up.
+ import dabo.dEvents as dEvents
funcNames = [i for i in dir(context) if i[:2] == "on"]
for funcName in funcNames:
# if funcName is onActivate, then parsedEvtName ==
"Activate" and parsedRegID=""
@@ -260,9 +264,9 @@
continue
# If we got this far, we have a match.
-
# Get the object reference to the function:
funcObj = None
+ retVal = False
### Paul: this is the major change I propose: looking
### in the 'context' object first, instead of its
__class__
try:
@@ -284,6 +288,8 @@
evtObj = dEvents.__dict__[parsedEvtName]
funcObj = eval("context.%s" % funcName)
## (can't use __class__.dict...)
self.bindEvent(evtObj, funcObj,
_auto=True)
+ retVal = True
+ return retVal
def getEventList(cls):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]