Esempio n. 1
0
 def _toHtml(self, oObject):
     """Translate some object to HTML."""
     if isinstance(oObject, WuiHtmlBase):
         return oObject.toHtml();
     if db.isDbTimestamp(oObject):
         return webutils.escapeElem(self.formatTsShort(oObject));
     if db.isDbInterval(oObject):
         return webutils.escapeElem(self.formatIntervalShort(oObject));
     if utils.isString(oObject):
         return webutils.escapeElem(oObject);
     return webutils.escapeElem(str(oObject));
Esempio n. 2
0
 def _toHtml(self, oObject):
     """Translate some object to HTML."""
     if isinstance(oObject, WuiHtmlBase):
         return oObject.toHtml()
     if db.isDbTimestamp(oObject):
         return webutils.escapeElem(self.formatTsShort(oObject))
     if db.isDbInterval(oObject):
         return webutils.escapeElem(self.formatIntervalShort(oObject))
     if utils.isString(oObject):
         return webutils.escapeElem(oObject)
     return webutils.escapeElem(str(oObject))
Esempio n. 3
0
    def _formatListEntryHtml(self, iEntry):
        """
        Formats the specified list entry as HTML.
        Returns HTML for a table row.

        The child class can override this to
        """
        if (iEntry + 1) & 1:
            sRow = u'  <tr class="tmodd">\n'
        else:
            sRow = u'  <tr class="tmeven">\n'

        aoValues = self._formatListEntry(iEntry)
        assert len(aoValues) == len(
            self._asColumnHeaders), '%s vs %s' % (len(aoValues),
                                                  len(self._asColumnHeaders))

        for i in range(len(aoValues)):
            if i < len(self._asColumnAttribs) and len(
                    self._asColumnAttribs[i]) > 0:
                sRow += u'    <td ' + self._asColumnAttribs[i] + '>'
            else:
                sRow += u'    <td>'

            if isinstance(aoValues[i], WuiHtmlBase):
                sRow += aoValues[i].toHtml()
            elif isinstance(aoValues[i], list):
                if len(aoValues[i]) > 0:
                    for oElement in aoValues[i]:
                        if isinstance(oElement, WuiHtmlBase):
                            sRow += oElement.toHtml()
                        elif db.isDbTimestamp(oElement):
                            sRow += webutils.escapeElem(
                                self.formatTsShort(oElement))
                        else:
                            sRow += webutils.escapeElem(unicode(oElement))
                        sRow += ' '
            elif db.isDbTimestamp(aoValues[i]):
                sRow += webutils.escapeElem(self.formatTsShort(aoValues[i]))
            elif db.isDbInterval(aoValues[i]):
                sRow += webutils.escapeElem(
                    self.formatIntervalShort(aoValues[i]))
            elif aoValues[i] is not None:
                sRow += webutils.escapeElem(unicode(aoValues[i]))

            sRow += u'</td>\n'

        return sRow + u'  </tr>\n'
Esempio n. 4
0
    def _formatListEntryHtml(self, iEntry):
        """
        Formats the specified list entry as HTML.
        Returns HTML for a table row.

        The child class can override this to
        """
        if (iEntry + 1) & 1:
            sRow = u'  <tr class="tmodd">\n';
        else:
            sRow = u'  <tr class="tmeven">\n';

        aoValues = self._formatListEntry(iEntry);
        assert len(aoValues) == len(self._asColumnHeaders), '%s vs %s' % (len(aoValues), len(self._asColumnHeaders));

        for i, _ in enumerate(aoValues):
            if i < len(self._asColumnAttribs) and len(self._asColumnAttribs[i]) > 0:
                sRow += u'    <td ' + self._asColumnAttribs[i] + '>';
            else:
                sRow += u'    <td>';

            if isinstance(aoValues[i], WuiHtmlBase):
                sRow += aoValues[i].toHtml();
            elif isinstance(aoValues[i], list):
                if len(aoValues[i]) > 0:
                    for oElement in aoValues[i]:
                        if isinstance(oElement, WuiHtmlBase):
                            sRow += oElement.toHtml();
                        elif db.isDbTimestamp(oElement):
                            sRow += webutils.escapeElem(self.formatTsShort(oElement));
                        else:
                            sRow += webutils.escapeElem(unicode(oElement));
                        sRow += ' ';
            elif db.isDbTimestamp(aoValues[i]):
                sRow += webutils.escapeElem(self.formatTsShort(aoValues[i]));
            elif db.isDbInterval(aoValues[i]):
                sRow += webutils.escapeElem(self.formatIntervalShort(aoValues[i]));
            elif aoValues[i] is not None:
                sRow += webutils.escapeElem(unicode(aoValues[i]));

            sRow += u'</td>\n';

        return sRow + u'  </tr>\n';