CVS: Products/ParsedXML/NodePath - NodePath.py:1.3
Martijn Faassen <[email protected]> Wed, 24 Apr 2002 09:43:53 -0400
| Newsgroups | gmane.comp.web.zope.parsed-xml |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs-repository/Products/ParsedXML/NodePath
In directory cvs.zope.org:/tmp/cvs-serv9037
Modified Files:
NodePath.py
Log Message:
Allow empty nodepaths.
=== Products/ParsedXML/NodePath/NodePath.py 1.2 => 1.3 ===
"""Resolve path.
"""
+ if not path:
+ return top_node
steps = string.split(path, ',')
# get scheme as first element of path
scheme_name, steps = steps[0], steps[1:]
@@ -33,15 +35,15 @@
def create_steps(self, top_node, node, scheme_name):
"""Construct steps tuple to node.
"""
- scheme = self._schemes[scheme_name]
- steps = [scheme_name]
- steps.extend(scheme.create_steps(top_node, node))
- return steps
+ return self._schemes[scheme_name].create_steps(top_node, node)
def create_path(self, top_node, node, scheme_name):
"""Construct path to node according to scheme_name.
"""
- return string.join(self.create_steps(top_node, node, scheme_name), ',')
+ steps = self.create_steps(top_node, node, scheme_name)
+ if not steps:
+ return ''
+ return '%s,%s' % (scheme_name, string.join(steps, ','))
class BaseNodePathScheme:
def __init__(self, scheme_name):