Skip to content

Commit

Permalink
Make sure that we are referecning the right element during error repo…
Browse files Browse the repository at this point in the history
…rting.
  • Loading branch information
strichter committed Dec 3, 2013
1 parent c5ab7fa commit d683215
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/z3c/rml/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def DeprecatedDirective(iface, reason):
iface.setTaggedValue('deprecatedReason', reason)
return iface

def getFileInfo(directive):
def getFileInfo(directive, element=None):
root = directive
while root.parent:
root = root.parent
return '(file %s, line %i)' %(root.filename, directive.element.sourceline)
if element is None:
element = directive.element
return '(file %s, line %i)' %(root.filename, element.sourceline)

class RMLDirective(object):
zope.interface.implements(interfaces.IRMLDirective)
Expand Down Expand Up @@ -104,7 +106,7 @@ def processSubDirectives(self, select=None, ignore=None):
# Raise an error/log any unknown directive.
if element.tag not in self.factories:
msg = "Directive %r could not be processed and was " \
"ignored. %s" %(element.tag, getFileInfo(self))
"ignored. %s" %(element.tag, getFileInfo(self, element))
# Record any tags/elements that could not be processed.
logger.warn(msg)
if ABORT_ON_INVALID_DIRECTIVE:
Expand Down

0 comments on commit d683215

Please sign in to comment.