Esempio n. 1
0
 def __unicode__(self):
     if self.filename:
         base = 'file:%s:%s' % (self.filename, self.function_name)
     else:
         base = '%s:%s' % (self.module_name, self.function_name)
     parts = ['%s="%s"' % (self.attr_name, html_quote(base))]
     for name, value in sorted(self.args.items()):
         parts.append('pyarg-%s="%s"' % (name, html_quote(value)))
     return ' '.join(parts)
Esempio n. 2
0
 def __unicode__(self):
     if self.filename:
         base = 'file:%s:%s' % (self.filename, self.function_name)
     else:
         base = '%s:%s' % (self.module_name, self.function_name)
     parts = ['%s="%s"' % (self.attr_name, html_quote(base))]
     for name, value in sorted(self.args.items()):
         parts.append('pyarg-%s="%s"' % (name, html_quote(value)))
     return ' '.join(parts)
Esempio n. 3
0
 def obj_as_html(self, el):
     """
     Returns the object formatted as HTML.  This is used to show
     the context in log messages.
     """
     ## FIXME: another magic method?
     if hasattr(el, 'log_description'):
         return el.log_description(self)
     elif isinstance(el, _Element):
         return html_quote(tostring(el))
     else:
         return html_quote(str(el))
Esempio n. 4
0
 def obj_as_html(self, el):
     """
     Returns the object formatted as HTML.  This is used to show
     the context in log messages.
     """
     ## FIXME: another magic method?
     if hasattr(el, 'log_description'):
         return el.log_description(self)
     elif isinstance(el, _Element):
         return html_quote(tostring(el))
     else:
         return html_quote(unicode(el))
Esempio n. 5
0
 def log_description(self, log=None):
     """The text to show when this is the context of a log message"""
     parts = ['<wsgi']
     if self.app_string:
         parts.append('app="%s"' % html_quote(self.app_string))
     parts.append('/>')
     return ' '.join(parts)
Esempio n. 6
0
 def log_description(self, log=None):
     """The text to show when this is the context of a log message"""
     parts = ['<wsgi']
     if self.app_string:
         parts.append('app="%s"' % html_quote(self.app_string))
     parts.append('/>')
     return ' '.join(parts)
Esempio n. 7
0
 def log_description(self, log=None):
     """The text to show when this is the context of a log message"""
     parts = ['<dest']
     if self.href:
         if log is not None:
             parts.append('href="%s"' % html_quote(html_quote(self.href)))
         else:
             ## FIXME: definite security issue with the link through here:
             ## FIXME: Should this be source=True?
             parts.append('href="<a href="%s" target="_blank">%s</a>"' %
                          (html_quote(log.link_to(self.href)),
                           html_quote(html_quote(self.href))))
     if self.pyref:
         parts.append('pref="%s"' % html_quote(self.pyref))
     if self.__next__:
         parts.append('next="1"')
     parts.append('/&gt;')
     return ' '.join(parts)
Esempio n. 8
0
 def log_description(self, log=None):
     """The text to show when this is the context of a log message"""
     parts = ["&lt;dest"]
     if self.href:
         if log is not None:
             parts.append('href="%s"' % html_quote(html_quote(self.href)))
         else:
             ## FIXME: definite security issue with the link through here:
             ## FIXME: Should this be source=True?
             parts.append(
                 'href="<a href="%s" target="_blank">%s</a>"'
                 % (html_quote(log.link_to(self.href)), html_quote(html_quote(self.href)))
             )
     if self.pyref:
         parts.append('pref="%s"' % html_quote(self.pyref))
     if self.next:
         parts.append('next="1"')
     parts.append("/&gt;")
     return " ".join(parts)
Esempio n. 9
0
def nl2br(s):
    if not isinstance(s, html_literal):
        s = html_quote(s)
    s = s.replace('\n', '<br>\n')
    return html_literal(s)
Esempio n. 10
0
 def _format_args(args):
     """Formats the pyargs dict as XML attributes"""
     return ' '.join('%s="%s"' % (name, html_quote(value))
                     for name, value in sorted(args.items()))
Esempio n. 11
0
 def _format_args(args):
     """Formats the pyargs dict as XML attributes"""
     return ' '.join(
         '%s="%s"' % (name, html_quote(value))
         for name, value in sorted(args.items()))