Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.support.werkzeug.debug.render Namespace Reference

Functions

def get_template
def load_resource
def code_table
def var_table
def debug_page

Variables

tuple t_body = get_template('body.tmpl')
tuple t_codetable = get_template('codetable.tmpl')
tuple t_vartable = get_template('vartable.tmpl')

Function Documentation

Definition at line 38 of file render.py.

00038 
00039 def code_table(frame):
00040     from werkzeug.debug.util import Namespace
00041     lines = []
00042     lineno = frame['context_lineno']
00043     if lineno is not None:
00044         lineno += 1
00045         for l in frame['pre_context']:
00046             lines.append(Namespace(mode='pre', lineno=lineno, code=l))
00047             lineno += 1
00048         lines.append(Namespace(mode='cur', lineno=lineno,
00049                                code=frame['context_line']))
00050         lineno += 1
00051         for l in frame['post_context']:
00052             lines.append(Namespace(mode='post', lineno=lineno, code=l))
00053             lineno += 1
00054     else:
00055         lines.append(Namespace(mode='cur', lineno=1,
00056                                code='Sourcecode not available'))
00057 
00058     return t_codetable.render(lines=lines)
00059 

Definition at line 99 of file render.py.

00099 
00100 def debug_page(context):
00101     tc = context.to_dict()
00102     tc['var_table'] = var_table
00103     tc['code_table'] = code_table
00104     return t_body.render(tc)

Definition at line 17 of file render.py.

00017 
00018 def get_template(name):
00019     return Template.from_file(join(dirname(__file__), 'shared', name),
00020                               unicode_mode=False, errors='ignore')
00021 

Definition at line 22 of file render.py.

00022 
00023 def load_resource(res):
00024     try:
00025         f = file(join(dirname(__file__), 'shared', res))
00026     except IOError:
00027         return ''
00028     try:
00029         return f.read()
00030     finally:
00031         f.close()
00032 

Definition at line 60 of file render.py.

00060 
00061 def var_table(var):
00062     def safe_pformat(x):
00063         try:
00064             lines = pprint.pformat(x).splitlines()
00065         except:
00066             return '?'
00067         tmp = []
00068         for line in lines:
00069             if len(line) > 79:
00070                 line = line[:79] + '...'
00071             tmp.append(line)
00072         return '\n'.join(tmp)
00073 
00074     # dicts
00075     if isinstance(var, dict) or hasattr(var, 'items'):
00076         value = var.items()
00077         if not value:
00078             typ = 'empty'
00079         else:
00080             typ = 'dict'
00081             value.sort()
00082             value = [(repr(key), safe_pformat(val)) for key, val in value]
00083 
00084     # lists
00085     elif isinstance(var, list):
00086         if not var:
00087             typ = 'empty'
00088         else:
00089             typ = 'list'
00090         value = [safe_pformat(item) for item in var]
00091 
00092     # others
00093     else:
00094         typ = 'simple'
00095         value = repr(var)
00096 
00097     return t_vartable.render(type=typ, value=value)
00098 


Variable Documentation

Definition at line 33 of file render.py.

Definition at line 34 of file render.py.

Definition at line 35 of file render.py.