Skip to content

Commit

Permalink
another fix in routers
Browse files Browse the repository at this point in the history
  • Loading branch information
lsbardel committed Jul 14, 2015
1 parent 704f85a commit 8113f1a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pulsar/apps/wsgi/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class RouterType(type):
''':class:`Router` metaclass.'''
def __new__(cls, name, bases, attrs):
rule_methods = get_roule_methods(attrs.items())
defaults = set()
defaults = {}
for key, value in list(attrs.items()):
if isinstance(value, RouterParam):
defaults.add(key)
attrs[key] = value.value
defaults[key] = attrs.pop(key).value

no_rule = set(attrs) - set((x[0] for x in rule_methods))
base_rules = []
for base in reversed(bases):
Expand Down Expand Up @@ -325,12 +325,22 @@ def __getattr__(self, name):
If the ``name`` is not available, retrieve it from the
:attr:`parent` :class:`Router` if it exists.
'''
if self._parent:
available = False
value = None

if name in self.defaults:
available = True
value = self.defaults[name]

if self._parent and value is None:
try:
return _get_default(self._parent, name)
except AttributeError:
pass

if available:
return value

raise AttributeError("'%s' object has no attribute '%s'" %
(self.__class__.__name__, name))

Expand Down

0 comments on commit 8113f1a

Please sign in to comment.