added __nonzero__ method to XPathSelector

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40298
This commit is contained in:
Pablo Hoffman 2008-10-05 06:58:39 +00:00
parent ac4688dabb
commit acebe63d0a
1 changed files with 3 additions and 0 deletions

View File

@ -84,6 +84,9 @@ class XPathSelector(object):
"""Register namespace so that it can be used in XPath queries"""
self.doc.xpathContext.xpathRegisterNs(prefix, uri)
def __nonzero__(self):
return bool(self.extract())
def __str__(self):
return "<%s (%s) xpath=%s>" % (type(self).__name__, getattr(self.xmlNode, 'name', type(self.xmlNode).__name__), self.expr)