PageRenderTime 155ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Lib/site-packages/django/views/debug.py

https://gitlab.com/areema/myproject
Python | 1245 lines | 1145 code | 42 blank | 58 comment | 71 complexity | facfe96e3a75c5dc6f44b0f3788b3b73 MD5 | raw file
  1. from __future__ import unicode_literals
  2. import re
  3. import sys
  4. import types
  5. from django.conf import settings
  6. from django.core.urlresolvers import Resolver404, resolve
  7. from django.http import HttpResponse, HttpResponseNotFound
  8. from django.template import Context, Engine, TemplateDoesNotExist
  9. from django.template.defaultfilters import force_escape, pprint
  10. from django.utils import lru_cache, six, timezone
  11. from django.utils.datastructures import MultiValueDict
  12. from django.utils.encoding import force_bytes, smart_text
  13. from django.utils.module_loading import import_string
  14. from django.utils.translation import ugettext as _
  15. # Minimal Django templates engine to render the error templates
  16. # regardless of the project's TEMPLATES setting.
  17. DEBUG_ENGINE = Engine(debug=True)
  18. HIDDEN_SETTINGS = re.compile('API|TOKEN|KEY|SECRET|PASS|SIGNATURE')
  19. CLEANSED_SUBSTITUTE = '********************'
  20. class CallableSettingWrapper(object):
  21. """ Object to wrap callable appearing in settings
  22. * Not to call in the debug page (#21345).
  23. * Not to break the debug page if the callable forbidding to set attributes (#23070).
  24. """
  25. def __init__(self, callable_setting):
  26. self._wrapped = callable_setting
  27. def __repr__(self):
  28. return repr(self._wrapped)
  29. def cleanse_setting(key, value):
  30. """Cleanse an individual setting key/value of sensitive content.
  31. If the value is a dictionary, recursively cleanse the keys in
  32. that dictionary.
  33. """
  34. try:
  35. if HIDDEN_SETTINGS.search(key):
  36. cleansed = CLEANSED_SUBSTITUTE
  37. else:
  38. if isinstance(value, dict):
  39. cleansed = {k: cleanse_setting(k, v) for k, v in value.items()}
  40. else:
  41. cleansed = value
  42. except TypeError:
  43. # If the key isn't regex-able, just return as-is.
  44. cleansed = value
  45. if callable(cleansed):
  46. # For fixing #21345 and #23070
  47. cleansed = CallableSettingWrapper(cleansed)
  48. return cleansed
  49. def get_safe_settings():
  50. "Returns a dictionary of the settings module, with sensitive settings blurred out."
  51. settings_dict = {}
  52. for k in dir(settings):
  53. if k.isupper():
  54. settings_dict[k] = cleanse_setting(k, getattr(settings, k))
  55. return settings_dict
  56. def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
  57. """
  58. Create a technical server error response. The last three arguments are
  59. the values returned from sys.exc_info() and friends.
  60. """
  61. reporter = ExceptionReporter(request, exc_type, exc_value, tb)
  62. if request.is_ajax():
  63. text = reporter.get_traceback_text()
  64. return HttpResponse(text, status=status_code, content_type='text/plain')
  65. else:
  66. html = reporter.get_traceback_html()
  67. return HttpResponse(html, status=status_code, content_type='text/html')
  68. @lru_cache.lru_cache()
  69. def get_default_exception_reporter_filter():
  70. # Instantiate the default filter for the first time and cache it.
  71. return import_string(settings.DEFAULT_EXCEPTION_REPORTER_FILTER)()
  72. def get_exception_reporter_filter(request):
  73. default_filter = get_default_exception_reporter_filter()
  74. return getattr(request, 'exception_reporter_filter', default_filter)
  75. class ExceptionReporterFilter(object):
  76. """
  77. Base for all exception reporter filter classes. All overridable hooks
  78. contain lenient default behaviors.
  79. """
  80. def get_post_parameters(self, request):
  81. if request is None:
  82. return {}
  83. else:
  84. return request.POST
  85. def get_traceback_frame_variables(self, request, tb_frame):
  86. return list(tb_frame.f_locals.items())
  87. class SafeExceptionReporterFilter(ExceptionReporterFilter):
  88. """
  89. Use annotations made by the sensitive_post_parameters and
  90. sensitive_variables decorators to filter out sensitive information.
  91. """
  92. def is_active(self, request):
  93. """
  94. This filter is to add safety in production environments (i.e. DEBUG
  95. is False). If DEBUG is True then your site is not safe anyway.
  96. This hook is provided as a convenience to easily activate or
  97. deactivate the filter on a per request basis.
  98. """
  99. return settings.DEBUG is False
  100. def get_cleansed_multivaluedict(self, request, multivaluedict):
  101. """
  102. Replaces the keys in a MultiValueDict marked as sensitive with stars.
  103. This mitigates leaking sensitive POST parameters if something like
  104. request.POST['nonexistent_key'] throws an exception (#21098).
  105. """
  106. sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', [])
  107. if self.is_active(request) and sensitive_post_parameters:
  108. multivaluedict = multivaluedict.copy()
  109. for param in sensitive_post_parameters:
  110. if param in multivaluedict:
  111. multivaluedict[param] = CLEANSED_SUBSTITUTE
  112. return multivaluedict
  113. def get_post_parameters(self, request):
  114. """
  115. Replaces the values of POST parameters marked as sensitive with
  116. stars (*********).
  117. """
  118. if request is None:
  119. return {}
  120. else:
  121. sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', [])
  122. if self.is_active(request) and sensitive_post_parameters:
  123. cleansed = request.POST.copy()
  124. if sensitive_post_parameters == '__ALL__':
  125. # Cleanse all parameters.
  126. for k, v in cleansed.items():
  127. cleansed[k] = CLEANSED_SUBSTITUTE
  128. return cleansed
  129. else:
  130. # Cleanse only the specified parameters.
  131. for param in sensitive_post_parameters:
  132. if param in cleansed:
  133. cleansed[param] = CLEANSED_SUBSTITUTE
  134. return cleansed
  135. else:
  136. return request.POST
  137. def cleanse_special_types(self, request, value):
  138. try:
  139. # If value is lazy or a complex object of another kind, this check
  140. # might raise an exception. isinstance checks that lazy
  141. # MultiValueDicts will have a return value.
  142. is_multivalue_dict = isinstance(value, MultiValueDict)
  143. except Exception as e:
  144. return '{!r} while evaluating {!r}'.format(e, value)
  145. if is_multivalue_dict:
  146. # Cleanse MultiValueDicts (request.POST is the one we usually care about)
  147. value = self.get_cleansed_multivaluedict(request, value)
  148. return value
  149. def get_traceback_frame_variables(self, request, tb_frame):
  150. """
  151. Replaces the values of variables marked as sensitive with
  152. stars (*********).
  153. """
  154. # Loop through the frame's callers to see if the sensitive_variables
  155. # decorator was used.
  156. current_frame = tb_frame.f_back
  157. sensitive_variables = None
  158. while current_frame is not None:
  159. if (current_frame.f_code.co_name == 'sensitive_variables_wrapper'
  160. and 'sensitive_variables_wrapper' in current_frame.f_locals):
  161. # The sensitive_variables decorator was used, so we take note
  162. # of the sensitive variables' names.
  163. wrapper = current_frame.f_locals['sensitive_variables_wrapper']
  164. sensitive_variables = getattr(wrapper, 'sensitive_variables', None)
  165. break
  166. current_frame = current_frame.f_back
  167. cleansed = {}
  168. if self.is_active(request) and sensitive_variables:
  169. if sensitive_variables == '__ALL__':
  170. # Cleanse all variables
  171. for name, value in tb_frame.f_locals.items():
  172. cleansed[name] = CLEANSED_SUBSTITUTE
  173. else:
  174. # Cleanse specified variables
  175. for name, value in tb_frame.f_locals.items():
  176. if name in sensitive_variables:
  177. value = CLEANSED_SUBSTITUTE
  178. else:
  179. value = self.cleanse_special_types(request, value)
  180. cleansed[name] = value
  181. else:
  182. # Potentially cleanse the request and any MultiValueDicts if they
  183. # are one of the frame variables.
  184. for name, value in tb_frame.f_locals.items():
  185. cleansed[name] = self.cleanse_special_types(request, value)
  186. if (tb_frame.f_code.co_name == 'sensitive_variables_wrapper'
  187. and 'sensitive_variables_wrapper' in tb_frame.f_locals):
  188. # For good measure, obfuscate the decorated function's arguments in
  189. # the sensitive_variables decorator's frame, in case the variables
  190. # associated with those arguments were meant to be obfuscated from
  191. # the decorated function's frame.
  192. cleansed['func_args'] = CLEANSED_SUBSTITUTE
  193. cleansed['func_kwargs'] = CLEANSED_SUBSTITUTE
  194. return cleansed.items()
  195. class ExceptionReporter(object):
  196. """
  197. A class to organize and coordinate reporting on exceptions.
  198. """
  199. def __init__(self, request, exc_type, exc_value, tb, is_email=False):
  200. self.request = request
  201. self.filter = get_exception_reporter_filter(self.request)
  202. self.exc_type = exc_type
  203. self.exc_value = exc_value
  204. self.tb = tb
  205. self.is_email = is_email
  206. self.template_info = getattr(self.exc_value, 'template_debug', None)
  207. self.template_does_not_exist = False
  208. self.postmortem = None
  209. # Handle deprecated string exceptions
  210. if isinstance(self.exc_type, six.string_types):
  211. self.exc_value = Exception('Deprecated String Exception: %r' % self.exc_type)
  212. self.exc_type = type(self.exc_value)
  213. def get_traceback_data(self):
  214. """Return a dictionary containing traceback information."""
  215. if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
  216. self.template_does_not_exist = True
  217. self.postmortem = self.exc_value.chain or [self.exc_value]
  218. frames = self.get_traceback_frames()
  219. for i, frame in enumerate(frames):
  220. if 'vars' in frame:
  221. frame_vars = []
  222. for k, v in frame['vars']:
  223. v = pprint(v)
  224. # The force_escape filter assume unicode, make sure that works
  225. if isinstance(v, six.binary_type):
  226. v = v.decode('utf-8', 'replace') # don't choke on non-utf-8 input
  227. # Trim large blobs of data
  228. if len(v) > 4096:
  229. v = '%s... <trimmed %d bytes string>' % (v[0:4096], len(v))
  230. frame_vars.append((k, force_escape(v)))
  231. frame['vars'] = frame_vars
  232. frames[i] = frame
  233. unicode_hint = ''
  234. if self.exc_type and issubclass(self.exc_type, UnicodeError):
  235. start = getattr(self.exc_value, 'start', None)
  236. end = getattr(self.exc_value, 'end', None)
  237. if start is not None and end is not None:
  238. unicode_str = self.exc_value.args[1]
  239. unicode_hint = smart_text(
  240. unicode_str[max(start - 5, 0):min(end + 5, len(unicode_str))],
  241. 'ascii', errors='replace'
  242. )
  243. from django import get_version
  244. c = {
  245. 'is_email': self.is_email,
  246. 'unicode_hint': unicode_hint,
  247. 'frames': frames,
  248. 'request': self.request,
  249. 'filtered_POST': self.filter.get_post_parameters(self.request),
  250. 'settings': get_safe_settings(),
  251. 'sys_executable': sys.executable,
  252. 'sys_version_info': '%d.%d.%d' % sys.version_info[0:3],
  253. 'server_time': timezone.now(),
  254. 'django_version_info': get_version(),
  255. 'sys_path': sys.path,
  256. 'template_info': self.template_info,
  257. 'template_does_not_exist': self.template_does_not_exist,
  258. 'postmortem': self.postmortem,
  259. }
  260. # Check whether exception info is available
  261. if self.exc_type:
  262. c['exception_type'] = self.exc_type.__name__
  263. if self.exc_value:
  264. c['exception_value'] = smart_text(self.exc_value, errors='replace')
  265. if frames:
  266. c['lastframe'] = frames[-1]
  267. return c
  268. def get_traceback_html(self):
  269. "Return HTML version of debug 500 HTTP error page."
  270. t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEMPLATE)
  271. c = Context(self.get_traceback_data(), use_l10n=False)
  272. return t.render(c)
  273. def get_traceback_text(self):
  274. "Return plain text version of debug 500 HTTP error page."
  275. t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEXT_TEMPLATE)
  276. c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  277. return t.render(c)
  278. def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None):
  279. """
  280. Returns context_lines before and after lineno from file.
  281. Returns (pre_context_lineno, pre_context, context_line, post_context).
  282. """
  283. source = None
  284. if loader is not None and hasattr(loader, "get_source"):
  285. try:
  286. source = loader.get_source(module_name)
  287. except ImportError:
  288. pass
  289. if source is not None:
  290. source = source.splitlines()
  291. if source is None:
  292. try:
  293. with open(filename, 'rb') as fp:
  294. source = fp.read().splitlines()
  295. except (OSError, IOError):
  296. pass
  297. if source is None:
  298. return None, [], None, []
  299. # If we just read the source from a file, or if the loader did not
  300. # apply tokenize.detect_encoding to decode the source into a Unicode
  301. # string, then we should do that ourselves.
  302. if isinstance(source[0], six.binary_type):
  303. encoding = 'ascii'
  304. for line in source[:2]:
  305. # File coding may be specified. Match pattern from PEP-263
  306. # (http://www.python.org/dev/peps/pep-0263/)
  307. match = re.search(br'coding[:=]\s*([-\w.]+)', line)
  308. if match:
  309. encoding = match.group(1).decode('ascii')
  310. break
  311. source = [six.text_type(sline, encoding, 'replace') for sline in source]
  312. lower_bound = max(0, lineno - context_lines)
  313. upper_bound = lineno + context_lines
  314. pre_context = source[lower_bound:lineno]
  315. context_line = source[lineno]
  316. post_context = source[lineno + 1:upper_bound]
  317. return lower_bound, pre_context, context_line, post_context
  318. def get_traceback_frames(self):
  319. def explicit_or_implicit_cause(exc_value):
  320. explicit = getattr(exc_value, '__cause__', None)
  321. implicit = getattr(exc_value, '__context__', None)
  322. return explicit or implicit
  323. # Get the exception and all its causes
  324. exceptions = []
  325. exc_value = self.exc_value
  326. while exc_value:
  327. exceptions.append(exc_value)
  328. exc_value = explicit_or_implicit_cause(exc_value)
  329. frames = []
  330. # No exceptions were supplied to ExceptionReporter
  331. if not exceptions:
  332. return frames
  333. # In case there's just one exception (always in Python 2,
  334. # sometimes in Python 3), take the traceback from self.tb (Python 2
  335. # doesn't have a __traceback__ attribute on Exception)
  336. exc_value = exceptions.pop()
  337. tb = self.tb if six.PY2 or not exceptions else exc_value.__traceback__
  338. while tb is not None:
  339. # Support for __traceback_hide__ which is used by a few libraries
  340. # to hide internal frames.
  341. if tb.tb_frame.f_locals.get('__traceback_hide__'):
  342. tb = tb.tb_next
  343. continue
  344. filename = tb.tb_frame.f_code.co_filename
  345. function = tb.tb_frame.f_code.co_name
  346. lineno = tb.tb_lineno - 1
  347. loader = tb.tb_frame.f_globals.get('__loader__')
  348. module_name = tb.tb_frame.f_globals.get('__name__') or ''
  349. pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(
  350. filename, lineno, 7, loader, module_name,
  351. )
  352. if pre_context_lineno is not None:
  353. frames.append({
  354. 'exc_cause': explicit_or_implicit_cause(exc_value),
  355. 'exc_cause_explicit': getattr(exc_value, '__cause__', True),
  356. 'tb': tb,
  357. 'type': 'django' if module_name.startswith('django.') else 'user',
  358. 'filename': filename,
  359. 'function': function,
  360. 'lineno': lineno + 1,
  361. 'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
  362. 'id': id(tb),
  363. 'pre_context': pre_context,
  364. 'context_line': context_line,
  365. 'post_context': post_context,
  366. 'pre_context_lineno': pre_context_lineno + 1,
  367. })
  368. # If the traceback for current exception is consumed, try the
  369. # other exception.
  370. if six.PY2:
  371. tb = tb.tb_next
  372. elif not tb.tb_next and exceptions:
  373. exc_value = exceptions.pop()
  374. tb = exc_value.__traceback__
  375. else:
  376. tb = tb.tb_next
  377. return frames
  378. def format_exception(self):
  379. """
  380. Return the same data as from traceback.format_exception.
  381. """
  382. import traceback
  383. frames = self.get_traceback_frames()
  384. tb = [(f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames]
  385. list = ['Traceback (most recent call last):\n']
  386. list += traceback.format_list(tb)
  387. list += traceback.format_exception_only(self.exc_type, self.exc_value)
  388. return list
  389. def technical_404_response(request, exception):
  390. "Create a technical 404 error response. The exception should be the Http404."
  391. try:
  392. error_url = exception.args[0]['path']
  393. except (IndexError, TypeError, KeyError):
  394. error_url = request.path_info[1:] # Trim leading slash
  395. try:
  396. tried = exception.args[0]['tried']
  397. except (IndexError, TypeError, KeyError):
  398. tried = []
  399. else:
  400. if (not tried # empty URLconf
  401. or (request.path == '/'
  402. and len(tried) == 1 # default URLconf
  403. and len(tried[0]) == 1
  404. and getattr(tried[0][0], 'app_name', '') == getattr(tried[0][0], 'namespace', '') == 'admin')):
  405. return default_urlconf(request)
  406. urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
  407. if isinstance(urlconf, types.ModuleType):
  408. urlconf = urlconf.__name__
  409. caller = ''
  410. try:
  411. resolver_match = resolve(request.path)
  412. except Resolver404:
  413. pass
  414. else:
  415. obj = resolver_match.func
  416. if hasattr(obj, '__name__'):
  417. caller = obj.__name__
  418. elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
  419. caller = obj.__class__.__name__
  420. if hasattr(obj, '__module__'):
  421. module = obj.__module__
  422. caller = '%s.%s' % (module, caller)
  423. t = DEBUG_ENGINE.from_string(TECHNICAL_404_TEMPLATE)
  424. c = Context({
  425. 'urlconf': urlconf,
  426. 'root_urlconf': settings.ROOT_URLCONF,
  427. 'request_path': error_url,
  428. 'urlpatterns': tried,
  429. 'reason': force_bytes(exception, errors='replace'),
  430. 'request': request,
  431. 'settings': get_safe_settings(),
  432. 'raising_view_name': caller,
  433. })
  434. return HttpResponseNotFound(t.render(c), content_type='text/html')
  435. def default_urlconf(request):
  436. "Create an empty URLconf 404 error response."
  437. t = DEBUG_ENGINE.from_string(DEFAULT_URLCONF_TEMPLATE)
  438. c = Context({
  439. "title": _("Welcome to Django"),
  440. "heading": _("It worked!"),
  441. "subheading": _("Congratulations on your first Django-powered page."),
  442. "instructions": _("Of course, you haven't actually done any work yet. "
  443. "Next, start your first app by running <code>python manage.py startapp [app_label]</code>."),
  444. "explanation": _("You're seeing this message because you have <code>DEBUG = True</code> in your "
  445. "Django settings file and you haven't configured any URLs. Get to work!"),
  446. })
  447. return HttpResponse(t.render(c), content_type='text/html')
  448. #
  449. # Templates are embedded in the file so that we know the error handler will
  450. # always work even if the template loader is broken.
  451. #
  452. TECHNICAL_500_TEMPLATE = ("""
  453. <!DOCTYPE html>
  454. <html lang="en">
  455. <head>
  456. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  457. <meta name="robots" content="NONE,NOARCHIVE">
  458. <title>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}"""
  459. """{% if request %} at {{ request.path_info|escape }}{% endif %}</title>
  460. <style type="text/css">
  461. html * { padding:0; margin:0; }
  462. body * { padding:10px 20px; }
  463. body * * { padding:0; }
  464. body { font:small sans-serif; }
  465. body>div { border-bottom:1px solid #ddd; }
  466. h1 { font-weight:normal; }
  467. h2 { margin-bottom:.8em; }
  468. h2 span { font-size:80%; color:#666; font-weight:normal; }
  469. h3 { margin:1em 0 .5em 0; }
  470. h4 { margin:0 0 .5em 0; font-weight: normal; }
  471. code, pre { font-size: 100%; white-space: pre-wrap; }
  472. table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
  473. tbody td, tbody th { vertical-align:top; padding:2px 3px; }
  474. thead th {
  475. padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
  476. font-weight:normal; font-size:11px; border:1px solid #ddd;
  477. }
  478. tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
  479. table.vars { margin:5px 0 2px 40px; }
  480. table.vars td, table.req td { font-family:monospace; }
  481. table td.code { width:100%; }
  482. table td.code pre { overflow:hidden; }
  483. table.source th { color:#666; }
  484. table.source td { font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }
  485. ul.traceback { list-style-type:none; color: #222; }
  486. ul.traceback li.frame { padding-bottom:1em; color:#666; }
  487. ul.traceback li.user { background-color:#e0e0e0; color:#000 }
  488. div.context { padding:10px 0; overflow:hidden; }
  489. div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; }
  490. div.context ol li { font-family:monospace; white-space:pre; color:#777; cursor:pointer; padding-left: 2px; }
  491. div.context ol li pre { display:inline; }
  492. div.context ol.context-line li { color:#505050; background-color:#dfdfdf; padding: 3px 2px; }
  493. div.context ol.context-line li span { position:absolute; right:32px; }
  494. .user div.context ol.context-line li { background-color:#bbb; color:#000; }
  495. .user div.context ol li { color:#666; }
  496. div.commands { margin-left: 40px; }
  497. div.commands a { color:#555; text-decoration:none; }
  498. .user div.commands a { color: black; }
  499. #summary { background: #ffc; }
  500. #summary h2 { font-weight: normal; color: #666; }
  501. #explanation { background:#eee; }
  502. #template, #template-not-exist { background:#f6f6f6; }
  503. #template-not-exist ul { margin: 0 0 10px 20px; }
  504. #template-not-exist .postmortem-section { margin-bottom: 3px; }
  505. #unicode-hint { background:#eee; }
  506. #traceback { background:#eee; }
  507. #requestinfo { background:#f6f6f6; padding-left:120px; }
  508. #summary table { border:none; background:transparent; }
  509. #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }
  510. #requestinfo h3 { margin-bottom:-1em; }
  511. .error { background: #ffc; }
  512. .specific { color:#cc3300; font-weight:bold; }
  513. h2 span.commands { font-size:.7em;}
  514. span.commands a:link {color:#5E5694;}
  515. pre.exception_value { font-family: sans-serif; color: #666; font-size: 1.5em; margin: 10px 0 10px 0; }
  516. .append-bottom { margin-bottom: 10px; }
  517. </style>
  518. {% if not is_email %}
  519. <script type="text/javascript">
  520. //<!--
  521. function getElementsByClassName(oElm, strTagName, strClassName){
  522. // Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com
  523. var arrElements = (strTagName == "*" && document.all)? document.all :
  524. oElm.getElementsByTagName(strTagName);
  525. var arrReturnElements = new Array();
  526. strClassName = strClassName.replace(/\-/g, "\\-");
  527. var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
  528. var oElement;
  529. for(var i=0; i<arrElements.length; i++){
  530. oElement = arrElements[i];
  531. if(oRegExp.test(oElement.className)){
  532. arrReturnElements.push(oElement);
  533. }
  534. }
  535. return (arrReturnElements)
  536. }
  537. function hideAll(elems) {
  538. for (var e = 0; e < elems.length; e++) {
  539. elems[e].style.display = 'none';
  540. }
  541. }
  542. window.onload = function() {
  543. hideAll(getElementsByClassName(document, 'table', 'vars'));
  544. hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
  545. hideAll(getElementsByClassName(document, 'ol', 'post-context'));
  546. hideAll(getElementsByClassName(document, 'div', 'pastebin'));
  547. }
  548. function toggle() {
  549. for (var i = 0; i < arguments.length; i++) {
  550. var e = document.getElementById(arguments[i]);
  551. if (e) {
  552. e.style.display = e.style.display == 'none' ? 'block': 'none';
  553. }
  554. }
  555. return false;
  556. }
  557. function varToggle(link, id) {
  558. toggle('v' + id);
  559. var s = link.getElementsByTagName('span')[0];
  560. var uarr = String.fromCharCode(0x25b6);
  561. var darr = String.fromCharCode(0x25bc);
  562. s.innerHTML = s.innerHTML == uarr ? darr : uarr;
  563. return false;
  564. }
  565. function switchPastebinFriendly(link) {
  566. s1 = "Switch to copy-and-paste view";
  567. s2 = "Switch back to interactive view";
  568. link.innerHTML = link.innerHTML.trim() == s1 ? s2: s1;
  569. toggle('browserTraceback', 'pastebinTraceback');
  570. return false;
  571. }
  572. //-->
  573. </script>
  574. {% endif %}
  575. </head>
  576. <body>
  577. <div id="summary">
  578. <h1>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}"""
  579. """{% if request %} at {{ request.path_info|escape }}{% endif %}</h1>
  580. <pre class="exception_value">"""
  581. """{% if exception_value %}{{ exception_value|force_escape }}{% else %}No exception message supplied{% endif %}"""
  582. """</pre>
  583. <table class="meta">
  584. {% if request %}
  585. <tr>
  586. <th>Request Method:</th>
  587. <td>{{ request.META.REQUEST_METHOD }}</td>
  588. </tr>
  589. <tr>
  590. <th>Request URL:</th>
  591. <td>{{ request.get_raw_uri|escape }}</td>
  592. </tr>
  593. {% endif %}
  594. <tr>
  595. <th>Django Version:</th>
  596. <td>{{ django_version_info }}</td>
  597. </tr>
  598. {% if exception_type %}
  599. <tr>
  600. <th>Exception Type:</th>
  601. <td>{{ exception_type }}</td>
  602. </tr>
  603. {% endif %}
  604. {% if exception_type and exception_value %}
  605. <tr>
  606. <th>Exception Value:</th>
  607. <td><pre>{{ exception_value|force_escape }}</pre></td>
  608. </tr>
  609. {% endif %}
  610. {% if lastframe %}
  611. <tr>
  612. <th>Exception Location:</th>
  613. <td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
  614. </tr>
  615. {% endif %}
  616. <tr>
  617. <th>Python Executable:</th>
  618. <td>{{ sys_executable|escape }}</td>
  619. </tr>
  620. <tr>
  621. <th>Python Version:</th>
  622. <td>{{ sys_version_info }}</td>
  623. </tr>
  624. <tr>
  625. <th>Python Path:</th>
  626. <td><pre>{{ sys_path|pprint }}</pre></td>
  627. </tr>
  628. <tr>
  629. <th>Server time:</th>
  630. <td>{{server_time|date:"r"}}</td>
  631. </tr>
  632. </table>
  633. </div>
  634. {% if unicode_hint %}
  635. <div id="unicode-hint">
  636. <h2>Unicode error hint</h2>
  637. <p>The string that could not be encoded/decoded was: <strong>{{ unicode_hint|force_escape }}</strong></p>
  638. </div>
  639. {% endif %}
  640. {% if template_does_not_exist %}
  641. <div id="template-not-exist">
  642. <h2>Template-loader postmortem</h2>
  643. {% if postmortem %}
  644. <p class="append-bottom">Django tried loading these templates, in this order:</p>
  645. {% for entry in postmortem %}
  646. <p class="postmortem-section">Using engine <code>{{ entry.backend.name }}</code>:</p>
  647. <ul>
  648. {% if entry.tried %}
  649. {% for attempt in entry.tried %}
  650. <li><code>{{ attempt.0.loader_name }}</code>: {{ attempt.0.name }} ({{ attempt.1 }})</li>
  651. {% endfor %}
  652. </ul>
  653. {% else %}
  654. <li>This engine did not provide a list of tried templates.</li>
  655. {% endif %}
  656. </ul>
  657. {% endfor %}
  658. {% else %}
  659. <p>No templates were found because your 'TEMPLATES' setting is not configured.</p>
  660. {% endif %}
  661. </div>
  662. {% endif %}
  663. {% if template_info %}
  664. <div id="template">
  665. <h2>Error during template rendering</h2>
  666. <p>In template <code>{{ template_info.name }}</code>, error at line <strong>{{ template_info.line }}</strong></p>
  667. <h3>{{ template_info.message }}</h3>
  668. <table class="source{% if template_info.top %} cut-top{% endif %}
  669. {% if template_info.bottom != template_info.total %} cut-bottom{% endif %}">
  670. {% for source_line in template_info.source_lines %}
  671. {% if source_line.0 == template_info.line %}
  672. <tr class="error"><th>{{ source_line.0 }}</th>
  673. <td>{{ template_info.before }}"""
  674. """<span class="specific">{{ template_info.during }}</span>"""
  675. """{{ template_info.after }}</td>
  676. </tr>
  677. {% else %}
  678. <tr><th>{{ source_line.0 }}</th>
  679. <td>{{ source_line.1 }}</td></tr>
  680. {% endif %}
  681. {% endfor %}
  682. </table>
  683. </div>
  684. {% endif %}
  685. {% if frames %}
  686. <div id="traceback">
  687. <h2>Traceback <span class="commands">{% if not is_email %}<a href="#" onclick="return switchPastebinFriendly(this);">
  688. Switch to copy-and-paste view</a></span>{% endif %}
  689. </h2>
  690. {% autoescape off %}
  691. <div id="browserTraceback">
  692. <ul class="traceback">
  693. {% for frame in frames %}
  694. {% ifchanged frame.exc_cause %}{% if frame.exc_cause %}
  695. <li><h3>
  696. {% if frame.exc_cause_explicit %}
  697. The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:
  698. {% else %}
  699. During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:
  700. {% endif %}
  701. </h3></li>
  702. {% endif %}{% endifchanged %}
  703. <li class="frame {{ frame.type }}">
  704. <code>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code>
  705. {% if frame.context_line %}
  706. <div class="context" id="c{{ frame.id }}">
  707. {% if frame.pre_context and not is_email %}
  708. <ol start="{{ frame.pre_context_lineno }}" class="pre-context" id="pre{{ frame.id }}">
  709. {% for line in frame.pre_context %}
  710. <li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>{{ line|escape }}</pre></li>
  711. {% endfor %}
  712. </ol>
  713. {% endif %}
  714. <ol start="{{ frame.lineno }}" class="context-line">
  715. <li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>
  716. """ """{{ frame.context_line|escape }}</pre>{% if not is_email %} <span>...</span>{% endif %}</li></ol>
  717. {% if frame.post_context and not is_email %}
  718. <ol start='{{ frame.lineno|add:"1" }}' class="post-context" id="post{{ frame.id }}">
  719. {% for line in frame.post_context %}
  720. <li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>{{ line|escape }}</pre></li>
  721. {% endfor %}
  722. </ol>
  723. {% endif %}
  724. </div>
  725. {% endif %}
  726. {% if frame.vars %}
  727. <div class="commands">
  728. {% if is_email %}
  729. <h2>Local Vars</h2>
  730. {% else %}
  731. <a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a>
  732. {% endif %}
  733. </div>
  734. <table class="vars" id="v{{ frame.id }}">
  735. <thead>
  736. <tr>
  737. <th>Variable</th>
  738. <th>Value</th>
  739. </tr>
  740. </thead>
  741. <tbody>
  742. {% for var in frame.vars|dictsort:"0" %}
  743. <tr>
  744. <td>{{ var.0|force_escape }}</td>
  745. <td class="code"><pre>{{ var.1 }}</pre></td>
  746. </tr>
  747. {% endfor %}
  748. </tbody>
  749. </table>
  750. {% endif %}
  751. </li>
  752. {% endfor %}
  753. </ul>
  754. </div>
  755. {% endautoescape %}
  756. <form action="http://dpaste.com/" name="pasteform" id="pasteform" method="post">
  757. {% if not is_email %}
  758. <div id="pastebinTraceback" class="pastebin">
  759. <input type="hidden" name="language" value="PythonConsole">
  760. <input type="hidden" name="title"
  761. value="{{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %}">
  762. <input type="hidden" name="source" value="Django Dpaste Agent">
  763. <input type="hidden" name="poster" value="Django">
  764. <textarea name="content" id="traceback_area" cols="140" rows="25">
  765. Environment:
  766. {% if request %}
  767. Request Method: {{ request.META.REQUEST_METHOD }}
  768. Request URL: {{ request.get_raw_uri|escape }}
  769. {% endif %}
  770. Django Version: {{ django_version_info }}
  771. Python Version: {{ sys_version_info }}
  772. Installed Applications:
  773. {{ settings.INSTALLED_APPS|pprint }}
  774. Installed Middleware:
  775. {{ settings.MIDDLEWARE_CLASSES|pprint }}
  776. {% if template_does_not_exist %}Template loader postmortem
  777. {% if postmortem %}Django tried loading these templates, in this order:
  778. {% for entry in postmortem %}
  779. Using engine {{ entry.backend.name }}:
  780. {% if entry.tried %}{% for attempt in entry.tried %}"""
  781. """ * {{ attempt.0.loader_name }}: {{ attempt.0.name }} ({{ attempt.1 }})
  782. {% endfor %}{% else %} This engine did not provide a list of tried templates.
  783. {% endif %}{% endfor %}
  784. {% else %}No templates were found because your 'TEMPLATES' setting is not configured.
  785. {% endif %}{% endif %}{% if template_info %}
  786. Template error:
  787. In template {{ template_info.name }}, error at line {{ template_info.line }}
  788. {{ template_info.message }}"""
  789. "{% for source_line in template_info.source_lines %}"
  790. "{% if source_line.0 == template_info.line %}"
  791. " {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}"
  792. "{% else %}"
  793. " {{ source_line.0 }} : {{ source_line.1 }}"
  794. """{% endif %}{% endfor %}{% endif %}
  795. Traceback:{% for frame in frames %}
  796. {% ifchanged frame.exc_cause %}{% if frame.exc_cause %}{% if frame.exc_cause_explicit %}
  797. The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:
  798. {% else %}
  799. During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:
  800. {% endif %}{% endif %}{% endifchanged %}
  801. File "{{ frame.filename|escape }}" in {{ frame.function|escape }}
  802. {% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line|escape }}{% endif %}{% endfor %}
  803. Exception Type: {{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %}
  804. Exception Value: {{ exception_value|force_escape }}
  805. </textarea>
  806. <br><br>
  807. <input type="submit" value="Share this traceback on a public website">
  808. </div>
  809. </form>
  810. </div>
  811. {% endif %}
  812. {% endif %}
  813. <div id="requestinfo">
  814. <h2>Request information</h2>
  815. {% if request %}
  816. <h3 id="get-info">GET</h3>
  817. {% if request.GET %}
  818. <table class="req">
  819. <thead>
  820. <tr>
  821. <th>Variable</th>
  822. <th>Value</th>
  823. </tr>
  824. </thead>
  825. <tbody>
  826. {% for var in request.GET.items %}
  827. <tr>
  828. <td>{{ var.0 }}</td>
  829. <td class="code"><pre>{{ var.1|pprint }}</pre></td>
  830. </tr>
  831. {% endfor %}
  832. </tbody>
  833. </table>
  834. {% else %}
  835. <p>No GET data</p>
  836. {% endif %}
  837. <h3 id="post-info">POST</h3>
  838. {% if filtered_POST %}
  839. <table class="req">
  840. <thead>
  841. <tr>
  842. <th>Variable</th>
  843. <th>Value</th>
  844. </tr>
  845. </thead>
  846. <tbody>
  847. {% for var in filtered_POST.items %}
  848. <tr>
  849. <td>{{ var.0 }}</td>
  850. <td class="code"><pre>{{ var.1|pprint }}</pre></td>
  851. </tr>
  852. {% endfor %}
  853. </tbody>
  854. </table>
  855. {% else %}
  856. <p>No POST data</p>
  857. {% endif %}
  858. <h3 id="files-info">FILES</h3>
  859. {% if request.FILES %}
  860. <table class="req">
  861. <thead>
  862. <tr>
  863. <th>Variable</th>
  864. <th>Value</th>
  865. </tr>
  866. </thead>
  867. <tbody>
  868. {% for var in request.FILES.items %}
  869. <tr>
  870. <td>{{ var.0 }}</td>
  871. <td class="code"><pre>{{ var.1|pprint }}</pre></td>
  872. </tr>
  873. {% endfor %}
  874. </tbody>
  875. </table>
  876. {% else %}
  877. <p>No FILES data</p>
  878. {% endif %}
  879. <h3 id="cookie-info">COOKIES</h3>
  880. {% if request.COOKIES %}
  881. <table class="req">
  882. <thead>
  883. <tr>
  884. <th>Variable</th>
  885. <th>Value</th>
  886. </tr>
  887. </thead>
  888. <tbody>
  889. {% for var in request.COOKIES.items %}
  890. <tr>
  891. <td>{{ var.0 }}</td>
  892. <td class="code"><pre>{{ var.1|pprint }}</pre></td>
  893. </tr>
  894. {% endfor %}
  895. </tbody>
  896. </table>
  897. {% else %}
  898. <p>No cookie data</p>
  899. {% endif %}
  900. <h3 id="meta-info">META</h3>
  901. <table class="req">
  902. <thead>
  903. <tr>
  904. <th>Variable</th>
  905. <th>Value</th>
  906. </tr>
  907. </thead>
  908. <tbody>
  909. {% for var in request.META.items|dictsort:"0" %}
  910. <tr>
  911. <td>{{ var.0 }}</td>
  912. <td class="code"><pre>{{ var.1|pprint }}</pre></td>
  913. </tr>
  914. {% endfor %}
  915. </tbody>
  916. </table>
  917. {% else %}
  918. <p>Request data not supplied</p>
  919. {% endif %}
  920. <h3 id="settings-info">Settings</h3>
  921. <h4>Using settings module <code>{{ settings.SETTINGS_MODULE }}</code></h4>
  922. <table class="req">
  923. <thead>
  924. <tr>
  925. <th>Setting</th>
  926. <th>Value</th>
  927. </tr>
  928. </thead>
  929. <tbody>
  930. {% for var in settings.items|dictsort:"0" %}
  931. <tr>
  932. <td>{{ var.0 }}</td>
  933. <td class="code"><pre>{{ var.1|pprint }}</pre></td>
  934. </tr>
  935. {% endfor %}
  936. </tbody>
  937. </table>
  938. </div>
  939. {% if not is_email %}
  940. <div id="explanation">
  941. <p>
  942. You're seeing this error because you have <code>DEBUG = True</code> in your
  943. Django settings file. Change that to <code>False</code>, and Django will
  944. display a standard page generated by the handler for this status code.
  945. </p>
  946. </div>
  947. {% endif %}
  948. </body>
  949. </html>
  950. """)
  951. TECHNICAL_500_TEXT_TEMPLATE = (""""""
  952. """{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %}
  953. {% firstof exception_value 'No exception message supplied' %}
  954. {% if request %}
  955. Request Method: {{ request.META.REQUEST_METHOD }}
  956. Request URL: {{ request.get_raw_uri }}{% endif %}
  957. Django Version: {{ django_version_info }}
  958. Python Executable: {{ sys_executable }}
  959. Python Version: {{ sys_version_info }}
  960. Python Path: {{ sys_path }}
  961. Server time: {{server_time|date:"r"}}
  962. Installed Applications:
  963. {{ settings.INSTALLED_APPS|pprint }}
  964. Installed Middleware:
  965. {{ settings.MIDDLEWARE_CLASSES|pprint }}
  966. {% if template_does_not_exist %}Template loader postmortem
  967. {% if postmortem %}Django tried loading these templates, in this order:
  968. {% for entry in postmortem %}
  969. Using engine {{ entry.backend.name }}:
  970. {% if entry.tried %}{% for attempt in entry.tried %}"""
  971. """ * {{ attempt.0.loader_name }}: {{ attempt.0.name }} ({{ attempt.1 }})
  972. {% endfor %}{% else %} This engine did not provide a list of tried templates.
  973. {% endif %}{% endfor %}
  974. {% else %}No templates were found because your 'TEMPLATES' setting is not configured.
  975. {% endif %}
  976. {% endif %}{% if template_info %}
  977. Template error:
  978. In template {{ template_info.name }}, error at line {{ template_info.line }}
  979. {{ template_info.message }}
  980. {% for source_line in template_info.source_lines %}"""
  981. "{% if source_line.0 == template_info.line %}"
  982. " {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}"
  983. "{% else %}"
  984. " {{ source_line.0 }} : {{ source_line.1 }}"
  985. """{% endif %}{% endfor %}{% endif %}{% if frames %}
  986. Traceback:"""
  987. "{% for frame in frames %}"
  988. "{% ifchanged frame.exc_cause %}"
  989. " {% if frame.exc_cause %}" """
  990. {% if frame.exc_cause_explicit %}
  991. The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:
  992. {% else %}
  993. During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:
  994. {% endif %}
  995. {% endif %}
  996. {% endifchanged %}
  997. File "{{ frame.filename }}" in {{ frame.function }}
  998. {% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line }}{% endif %}
  999. {% endfor %}
  1000. {% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %}
  1001. {% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %}
  1002. {% if request %}Request information:
  1003. GET:{% for k, v in request.GET.items %}
  1004. {{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %}
  1005. POST:{% for k, v in filtered_POST.items %}
  1006. {{ k }} = {{ v|stringformat:"r" }}{% empty %} No POST data{% endfor %}
  1007. FILES:{% for k, v in request.FILES.items %}
  1008. {{ k }} = {{ v|stringformat:"r" }}{% empty %} No FILES data{% endfor %}
  1009. COOKIES:{% for k, v in request.COOKIES.items %}
  1010. {{ k }} = {{ v|stringformat:"r" }}{% empty %} No cookie data{% endfor %}
  1011. META:{% for k, v in request.META.items|dictsort:"0" %}
  1012. {{ k }} = {{ v|stringformat:"r" }}{% endfor %}
  1013. {% else %}Request data not supplied
  1014. {% endif %}
  1015. Settings:
  1016. Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in settings.items|dictsort:"0" %}
  1017. {{ k }} = {{ v|stringformat:"r" }}{% endfor %}
  1018. {% if not is_email %}
  1019. You're seeing this error because you have DEBUG = True in your
  1020. Django settings file. Change that to False, and Django will
  1021. display a standard page generated by the handler for this status code.
  1022. {% endif %}
  1023. """)
  1024. TECHNICAL_404_TEMPLATE = """
  1025. <!DOCTYPE html>
  1026. <html lang="en">
  1027. <head>
  1028. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  1029. <title>Page not found at {{ request.path_info|escape }}</title>
  1030. <meta name="robots" content="NONE,NOARCHIVE">
  1031. <style type="text/css">
  1032. html * { padding:0; margin:0; }
  1033. body * { padding:10px 20px; }
  1034. body * * { padding:0; }
  1035. body { font:small sans-serif; background:#eee; }
  1036. body>div { border-bottom:1px solid #ddd; }
  1037. h1 { font-weight:normal; margin-bottom:.4em; }
  1038. h1 span { font-size:60%; color:#666; font-weight:normal; }
  1039. table { border:none; border-collapse: collapse; width:100%; }
  1040. td, th { vertical-align:top; padding:2px 3px; }
  1041. th { width:12em; text-align:right; color:#666; padding-right:.5em; }
  1042. #info { background:#f6f6f6; }
  1043. #info ol { margin: 0.5em 4em; }
  1044. #info ol li { font-family: monospace; }
  1045. #summary { background: #ffc; }
  1046. #explanation { background:#eee; border-bottom: 0px none; }
  1047. </style>
  1048. </head>
  1049. <body>
  1050. <div id="summary">
  1051. <h1>Page not found <span>(404)</span></h1>
  1052. <table class="meta">
  1053. <tr>
  1054. <th>Request Method:</th>
  1055. <td>{{ request.META.REQUEST_METHOD }}</td>
  1056. </tr>
  1057. <tr>
  1058. <th>Request URL:</th>
  1059. <td>{{ request.build_absolute_uri|escape }}</td>
  1060. </tr>
  1061. {% if raising_view_name %}
  1062. <tr>
  1063. <th>Raised by:</th>
  1064. <td>{{ raising_view_name }}</td>
  1065. </tr>
  1066. {% endif %}
  1067. </table>
  1068. </div>
  1069. <div id="info">
  1070. {% if urlpatterns %}
  1071. <p>
  1072. Using the URLconf defined in <code>{{ urlconf }}</code>,
  1073. Django tried these URL patterns, in this order:
  1074. </p>
  1075. <ol>
  1076. {% for pattern in urlpatterns %}
  1077. <li>
  1078. {% for pat in pattern %}
  1079. {{ pat.regex.pattern }}
  1080. {% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %}
  1081. {% endfor %}
  1082. </li>
  1083. {% endfor %}
  1084. </ol>
  1085. <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p>
  1086. {% else %}
  1087. <p>{{ reason }}</p>
  1088. {% endif %}
  1089. </div>
  1090. <div id="explanation">
  1091. <p>
  1092. You're seeing this error because you have <code>DEBUG = True</code> in
  1093. your Django settings file. Change that to <code>False</code>, and Django
  1094. will display a standard 404 page.
  1095. </p>
  1096. </div>
  1097. </body>
  1098. </html>
  1099. """
  1100. DEFAULT_URLCONF_TEMPLATE = """
  1101. <!DOCTYPE html>
  1102. <html lang="en"><head>
  1103. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  1104. <meta name="robots" content="NONE,NOARCHIVE"><title>{{ title }}</title>
  1105. <style type="text/css">
  1106. html * { padding:0; margin:0; }
  1107. body * { padding:10px 20px; }
  1108. body * * { padding:0; }
  1109. body { font:small sans-serif; }
  1110. body>div { border-bottom:1px solid #ddd; }
  1111. h1 { font-weight:normal; }
  1112. h2 { margin-bottom:.8em; }
  1113. h2 span { font-size:80%; color:#666; font-weight:normal; }
  1114. h3 { margin:1em 0 .5em 0; }
  1115. h4 { margin:0 0 .5em 0; font-weight: normal; }
  1116. table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
  1117. tbody td, tbody th { vertical-align:top; padding:2px 3px; }
  1118. thead th {
  1119. padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
  1120. font-weight:normal; font-size:11px; border:1px solid #ddd;
  1121. }
  1122. tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
  1123. #summary { background: #e0ebff; }
  1124. #summary h2 { font-weight: normal; color: #666; }
  1125. #explanation { background:#eee; }
  1126. #instructions { background:#f6f6f6; }
  1127. #summary table { border:none; background:transparent; }
  1128. </style>
  1129. </head>
  1130. <body>
  1131. <div id="summary">
  1132. <h1>{{ heading }}</h1>
  1133. <h2>{{ subheading }}</h2>
  1134. </div>
  1135. <div id="instructions">
  1136. <p>
  1137. {{ instructions|safe }}
  1138. </p>
  1139. </div>
  1140. <div id="explanation">
  1141. <p>
  1142. {{ explanation|safe }}
  1143. </p>
  1144. </div>
  1145. </body></html>
  1146. """