Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed class attributes and made them instance-level instead in Navi…

…gationNode
  • Loading branch information...
commit 1104e5c2e925dd3621f9ff693b9684db6d32c46f 1 parent fc35b42
@chrisglass chrisglass authored
Showing with 6 additions and 10 deletions.
  1. +6 −10 menus/base.py
View
16 menus/base.py
@@ -22,26 +22,22 @@ def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
pass
class NavigationNode(object):
- title = None
- url = None
- attr = {}
- namespace = None
- id = None
- parent_id = None
- parent_namespace = None
- parent = None # do not touch
- visible = True
def __init__(self, title, url, id, parent_id=None, parent_namespace=None, attr=None, visible=True):
self.children = [] # do not touch
+ self.parent = None # do not touch, code depends on this
+ self.namespace = None # TODO: Assert why we need this and above
self.title = title
self.url = self._remove_current_root(url)
self.id = id
self.parent_id = parent_id
self.parent_namespace = parent_namespace
self.visible = visible
+
if attr:
self.attr = attr
+ else:
+ self.attr = {} # To avoid declaring a dict in defaults...
def __repr__(self):
return "<Navigation Node: %s>" % smart_str(self.title)
@@ -70,7 +66,7 @@ def get_descendants(self):
def get_ancestors(self):
nodes = []
- if self.parent:
+ if getattr(self, 'parent', None):
nodes.append(self.parent)
nodes += self.parent.get_ancestors()
return nodes
Please sign in to comment.
Something went wrong with that request. Please try again.