dabo Commit
Revision 1270
Date: 2005-09-08 14:43:33 -0700 (Thu, 08 Sep 2005)
Author: ed
Changed:
U trunk/dabo/ui/uiwx/dFormMixin.py
U trunk/dabo/ui/uiwx/dPemMixin.py
Log:
Corrects the name conflict problem pointed out by Donnal Walter. Now, names
that conflict with existing attributes will also not be allowed.
Diff:
Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py 2005-09-08 20:59:40 UTC (rev 1269)
+++ trunk/dabo/ui/uiwx/dFormMixin.py 2005-09-08 21:43:33 UTC (rev 1270)
@@ -352,7 +352,7 @@
if self._objectRegistry.has_key(id):
raise KeyError, _("Duplicate RegID '%s' found")
% id
self._objectRegistry[id] = obj
- if self.__dict__.has_key(id):
+ if hasattr(self, id) or self.__dict__.has_key(id):
dabo.errorLog.write(_("RegID '%s' conflicts
with existing name") % id)
else:
self.__dict__[id] = obj
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2005-09-08 20:59:40 UTC (rev 1269)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2005-09-08 21:43:33 UTC (rev 1270)
@@ -1079,6 +1079,10 @@
# Parent could be None, or currentName
wasn't bound yet (init)
pass
+ # Make sure that the name isn't already used
+ if self.Parent:
+ if hasattr(self.Parent, name):
+ raise NameError, "Name '%s' is
already in use." % name
try:
self.Parent.__dict__[name] = self
except AttributeError:
@@ -1093,16 +1097,16 @@
# the name if necessary to make it
unique (we don't want a NameError).
i = 0
while True:
- nameError = False
if i == 0:
candidate = name
else:
candidate = "%s%s" %
(name, i)
-
- for window in
parent.GetChildren():
- if window.GetName() ==
candidate and window != self:
- nameError = True
- break
+ nameError = hasattr(parent,
name)
+ if not nameError:
+ for window in
parent.GetChildren():
+ if
window.GetName() == candidate and window != self:
+
nameError = True
+ break
if nameError:
i += 1
else:
@@ -1111,9 +1115,12 @@
else:
# the user is explicitly setting the
Name. If another object already
# has the name, we must raise an
exception immediately.
- for window in parent.GetChildren():
- if str(window.GetName()) ==
str(name) and window != self:
- raise NameError, "Name
'%s' is already in use." % name
+ if hasattr(parent, name):
+ raise NameError, "Name '%s' is
already in use." % name
+ else:
+ for window in
parent.GetChildren():
+ if
str(window.GetName()) == str(name) and window != self:
+ raise
NameError, "Name '%s' is already in use." % name
else:
# Can't do the name check for siblings, so
allow it for now.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev