def renderBaseAttrs(self): buf = '<' + self.tagName attributes = self.getAttributes() for key in attributes: val = attributes[key] if val is not None and val is not False: buf += ' ' + htmlspecialchars(key) + '="' +\ htmlspecialchars(val, True) + '"' return buf
def escape(self, txt): return htmlspecialchars(txt)
def getAttribute(self, attr): raise NotImplementedError('not implemented!') def setAttribute(self, attr, val): raise NotImplementedError('not implemented!') def categoryOf(self, cat): raise NotImplementedError('not implemented!') @classmethod def renderChild(cls, child): if isinstance(child, :x:base): return unicode(child) if isinstance(child, list): raise XHPyRenderListException('Can not render list!') return htmlspecialchars(unicode(child)) class :x:composable-element(:x:base): def _init(self): pass def __init__(self, attributes={}, children=[], source=None): self.source = source if attributes and ENABLE_VALIDATION: for key in attributes: attributes[key] =\ self._validator.validateAttributeValue(self, key, attributes[key]) self._attributes = attributes self._children = [] for child in children: self.appendChild(child)
def getAttribute(self, attr): raise NotImplementedError('not implemented!') def setAttribute(self, attr, val): raise NotImplementedError('not implemented!') def categoryOf(self, cat): raise NotImplementedError('not implemented!') @classmethod def renderChild(cls, child): if isinstance(child, :x:base): return str(child) if isinstance(child, list): raise XHPyRenderListException('Can not render list!') return htmlspecialchars(str(child)) class :x:composable-element(:x:base): def _init(self): pass def __init__(self, attributes={}, children=[], source=None): self.source = source if attributes and ENABLE_VALIDATION: for key in attributes: attributes[key] =\ self._validator.validateAttributeValue(self, key, attributes[key]) self._attributes = attributes self._children = [] for child in children: self.appendChild(child)