Config: Prevent variable creation when trying to get the value of a channel-specific variable for a non-channel.

This commit is contained in:
Valentin Lorentz 2014-05-31 20:44:56 +02:00
parent fd2ecf0dec
commit b14ed2c5d9
2 changed files with 9 additions and 6 deletions

View File

@ -54,12 +54,12 @@ def getWrapper(name):
raise registry.InvalidRegistryName(name)
group = getattr(conf, parts.pop(0))
while parts:
try:
group = group.get(parts.pop(0))
# We'll catch registry.InvalidRegistryName and re-raise it here so
# that we have a useful error message for the user.
except (registry.NonExistentRegistryEntry,
registry.InvalidRegistryName):
part = parts.pop(0)
if group.__hasattr__(part):
group = group.get(part)
else:
# We'll raise registry.InvalidRegistryName here so
# that we have a useful error message for the user.
raise registry.InvalidRegistryName(name)
return group

View File

@ -214,6 +214,9 @@ class Group(object):
self.register(attr, v)
return v
def __hasattr__(self, attr):
return attr in self._children
def __getattr__(self, attr):
if attr in self._children:
return self._children[attr]