Example #1
0
 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
Example #2
0
 def escape(self, txt):
   return htmlspecialchars(txt)
Example #3
0
  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)
Example #4
0
  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)