Commit 1a59e3be authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rewrite buggy getDomainByPath.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8499 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a262cf45
......@@ -118,9 +118,11 @@ class Domain(Predicate, MetaNode, MetaResource):
domain = domain.__of__(self)
return domain
def getChildDomainValueList(self, *args, **kw):
def getChildDomainValueList(self, parent = None, **kw):
"""
Return child domain objects already present or me may generate
dynamically childs.
"""
return self.portal_domains.getChildDomainValueList(self, *args, **kw)
if parent is None:
parent = self
return self.portal_domains.getChildDomainValueList(parent, **kw)
......@@ -225,7 +225,7 @@ class DomainTool(BaseTool):
def getChildDomainValueList(self, parent,**kw):
def getChildDomainValueList(self, parent, **kw):
"""
Return child domain objects already present adn thois generetaded dynamically
"""
......@@ -239,14 +239,17 @@ class DomainTool(BaseTool):
"""
Return the domain object for a given path
"""
domain = None
for subdomain in path.split('/'):
if domain is None:
domain = self[subdomain]
domains = self.getChildDomainValueList(domain)
for d in domains:
path = path.split('/')
base_domain_id = path[0]
domain = self[base_domain_id]
for depth, subdomain in enumerate(path[1:]):
domain_list = self.getChildDomainValueList(domain, depth=depth)
for d in domain_list:
if d.getId() == subdomain:
domain = d
break
else:
raise KeyError, subdomain
return domain
InitializeClass(DomainTool)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment