[visionegg] Minor patch to VisionEgg.__init__.py
- From: Simeon Fitch <simeon.fitch@xxxxxxxxxxxxx>
- To: visionegg <visionegg@xxxxxxxxxxxxx>
- Date: Mon, 5 Dec 2005 11:35:53 -0500
In the defaults resolution code in "ClassWithParameters", there is a
minor attribute resolution bug if you (gasp!) use multiple inheritance
and one of your intermediate classes doesn't have a
"parameters_and_defaults" and/or a "constant_parameters_and_defaults"
attribute.
My fix is just to check for the attribute before enumerating its values:
Index: __init__.py
===================================================================
--- __init__.py (revision 1344)
+++ __init__.py (working copy)
@@ -322,7 +322,7 @@
# otherwise to default value.
#
# If a class didn't override base class's
parameters_and_defaults dictionary, don't deal with it twice
- if klass.parameters_and_defaults not in
done_parameters_and_defaults:
+ if hasattr(klass, 'parameters_and_defaults') and
klass.parameters_and_defaults not in done_parameters_and_defaults:
for parameter_name in klass.parameters_and_defaults.keys():
# Make sure this parameter key/value pair doesn't
exist already
if hasattr(self.parameters,parameter_name):
@@ -357,7 +357,7 @@
# otherwise to default value.
#
# If a class didn't override base class's
parameters_and_defaults dictionary, don't deal with it twice
- if klass.constant_parameters_and_defaults not in
done_constant_parameters_and_defaults:
+ if hasattr(klass, 'constant_parameters_and_defaults') and
klass.constant_parameters_and_defaults not in
done_constant_parameters_and_defaults:
for parameter_name in
klass.constant_parameters_and_defaults.keys():
# Make sure this parameter key/value pair doesn't
exist already
if hasattr(self.parameters,parameter_name):
- Follow-Ups:
- [visionegg] Re: Minor patch to VisionEgg.__init__.py
- From: Andrew Straw
Other related posts:
- » [visionegg] Minor patch to VisionEgg.__init__.py
- » [visionegg] Re: Minor patch to VisionEgg.__init__.py
- [visionegg] Re: Minor patch to VisionEgg.__init__.py
- From: Andrew Straw