Changeset 317:81bfcb29ef3b
- Timestamp:
- 2007-09-02 16:37:54
(1 year ago)
- Author:
- Stefan Schwarzer <sschwarzer@sschwarzer.net>
- branch:
- default
- Message:
Removed code to measure rendering times with and without Pygments
cache. This should be investigated (profiled) more thouroughly anyway.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r316 |
r317 |
|
| 173 | 173 | Handle HTTP GET request. |
|---|
| 174 | 174 | """ |
|---|
| 175 | | start_time = time.time() |
|---|
| 176 | | self._time = None |
|---|
| 177 | 175 | # reject forbidden clients |
|---|
| 178 | 176 | if config.allowed_clients is not config.ALL_CLIENTS and \ |
|---|
| … | … | |
| 235 | 233 | h1_class=h1_class, |
|---|
| 236 | 234 | use_header_and_footer=use_header_and_footer) |
|---|
| 237 | | print "Render time:", time.time() - start_time, "s" |
|---|
| 238 | 235 | |
|---|
| 239 | 236 | # |
|---|
| r316 |
r317 |
|
| 199 | 199 | return u"\n".join(('<pre>', cgi.escape(text), '</pre>')) |
|---|
| 200 | 200 | |
|---|
| 201 | | def text_to_html(text, path, _cache={}): |
|---|
| | 201 | def text_to_html(text, path): |
|---|
| 202 | 202 | """ |
|---|
| 203 | 203 | Convert the unicode string `text` to HTML and return the HTML |
|---|
| … | … | |
| 207 | 207 | if not pygmentsfinder.found_pygments: |
|---|
| 208 | 208 | return dumb_text_to_html(text) |
|---|
| 209 | | #TODO make cache handling threadsafe when Websourcebrowser |
|---|
| 210 | | # works multithreaded |
|---|
| 211 | | if (text, path) in _cache: |
|---|
| 212 | | return _cache[text, path] |
|---|
| 213 | 209 | try: |
|---|
| 214 | 210 | # assume the link doesn't point to a link or at least has |
|---|
| … | … | |
| 227 | 223 | linenos=config.line_numbers) |
|---|
| 228 | 224 | html = pygmentsfinder.pygments.highlight(text, lexer, formatter) |
|---|
| 229 | | _cache[text, path] = html |
|---|
| 230 | 225 | return html |
|---|
| 231 | 226 | |
|---|