Package trac :: Package versioncontrol :: Package web_ui

Package web_ui

source code

Submodules

Functions
 
datetime_now(...)
[tz] -> new datetime with tz's local day and time.
source code
Markup
escape(text, quotes=True)
Create a Markup instance from a string and escape special characters it may contain (<, >, & and ").
source code
Variables
  CHUNK_SIZE = 4096
  CRLF = '\r\n'
  __package__ = 'trac.versioncontrol.web_ui'
  tag = <genshi.builder.ElementFactory object at 0x7f4932e45810>
  utc = <FixedOffset "UTC" 0:00:00>

Imports: AnyDiffModule, BlameAnnotator, BoolOption, BrowserModule, Changeset, ChangesetModule, Chrome, Component, DefaultPropertyDiffRenderer, DefaultPropertyRenderer, ExtensionPoint, IHTMLPreviewAnnotator, INavigationContributor, IPermissionRequestor, IPropertyDiffRenderer, IPropertyRenderer, IRequestHandler, ISearchSource, ITimelineEventProvider, IWikiMacroProvider, IWikiSyntaxProvider, IntOption, Interface, ListOption, LogModule, Markup, Mimeview, NoSuchChangeset, Node, Option, PermissionError, Ranges, RenderedProperty, RepositoryManager, RequestDone, Resource, ResourceNotFound, RevRanges, TimeRange, TracBaseError, TracError, TracValueError, WikiParser, WikiPropertyRenderer, add_ctxtnav, add_link, add_script, add_script_data, add_stylesheet, as_bool, auth_link, browser, changeset, cleandoc_, content_closing, content_disposition, datetime, diff_blocks, embedded_numbers, exception_to_unicode, fnmatchcase, format_to, format_to_html, format_to_oneliner, from_utimestamp, get_allowed_node, get_changes, get_diff_options, get_existing_node, get_path_links, groupby, http_date, implements, is_binary, log, make_log_graph, ngettext, os, parse_args, partial, pathjoin, posixpath, pretty_timedelta, prevnext_nav, re, render_zip, search_to_sql, shorten_line, shorten_result, tag_, tests, timedelta, to_datetime, to_json, to_unicode, unicode_urlencode, unified_diff, util, web_context, wrap


Function Details

escape(text, quotes=True)

source code 

Create a Markup instance from a string and escape special characters it may contain (<, >, & and ").

>>> escape('"1 < 2"')
<Markup u'&#34;1 &lt; 2&#34;'>

If the quotes parameter is set to False, the " character is left as is. Escaping quotes is generally only required for strings that are to be used in attribute values.

>>> escape('"1 < 2"', quotes=False)
<Markup u'"1 &lt; 2"'>
Parameters:
  • text - the text to escape
  • quotes - if True, double quote characters are escaped in addition to the other special characters
Returns: Markup
the escaped Markup string