comparison markup/template.py @ 222:37b56b48a00e

`BadDirectiveError` no longer expects a `QName` as the directive name; a regular string should do.
author cmlenz
date Tue, 05 Sep 2006 20:36:39 +0000
parents c448cf114c30
children e4dad1145f84
comparison
equal deleted inserted replaced
221:c448cf114c30 222:37b56b48a00e
60 An unknown directive is any attribute using the namespace for directives, 60 An unknown directive is any attribute using the namespace for directives,
61 with a local name that doesn't match any registered directive. 61 with a local name that doesn't match any registered directive.
62 """ 62 """
63 63
64 def __init__(self, name, filename='<string>', lineno=-1): 64 def __init__(self, name, filename='<string>', lineno=-1):
65 message = 'bad directive "%s"' % name.localname 65 message = 'bad directive "%s"' % name
66 TemplateSyntaxError.__init__(self, message, filename, lineno) 66 TemplateSyntaxError.__init__(self, message, filename, lineno)
67 67
68 68
69 class TemplateNotFound(TemplateError): 69 class TemplateNotFound(TemplateError):
70 """Exception raised when a specific template file could not be found.""" 70 """Exception raised when a specific template file could not be found."""
809 strip = False 809 strip = False
810 810
811 if tag in self.NAMESPACE: 811 if tag in self.NAMESPACE:
812 cls = self._dir_by_name.get(tag.localname) 812 cls = self._dir_by_name.get(tag.localname)
813 if cls is None: 813 if cls is None:
814 raise BadDirectiveError(tag, pos[0], pos[1]) 814 raise BadDirectiveError(tag.localname, pos[0], pos[1])
815 value = attrib.get(getattr(cls, 'ATTRIBUTE', None), '') 815 value = attrib.get(getattr(cls, 'ATTRIBUTE', None), '')
816 directives.append(cls(value, *pos)) 816 directives.append(cls(value, *pos))
817 strip = True 817 strip = True
818 818
819 new_attrib = [] 819 new_attrib = []
820 for name, value in attrib: 820 for name, value in attrib:
821 if name in self.NAMESPACE: 821 if name in self.NAMESPACE:
822 cls = self._dir_by_name.get(name.localname) 822 cls = self._dir_by_name.get(name.localname)
823 if cls is None: 823 if cls is None:
824 raise BadDirectiveError(name, pos[0], pos[1]) 824 raise BadDirectiveError(name.localname, pos[0],
825 pos[1])
825 directives.append(cls(value, *pos)) 826 directives.append(cls(value, *pos))
826 else: 827 else:
827 if value: 828 if value:
828 value = list(self._interpolate(value, *pos)) 829 value = list(self._interpolate(value, *pos))
829 if len(value) == 1 and value[0][0] is TEXT: 830 if len(value) == 1 and value[0][0] is TEXT:
Copyright (C) 2012-2017 Edgewall Software