def test_custom_processors(self):
     variables = get_variables(
         self._get_context(self.request, {}, processors=[]))
     self.assertTrue('custom_processor_var' not in variables)
     variables = get_variables(
         self._get_context(self.request, {}, processors=[test_processor]))
     self.assertTrue('custom_processor_var' in variables)
Esempio n. 2
0
 def test_returned_variable(self):
     """
     Assure get_variables returns variables unique to the context
     """
     variables = get_variables(self._get_context(self.request, {}))
     self.assertTrue('a' not in variables)
     variables = get_variables(self._get_context(self.request, {'a': 3}))
     self.assertTrue('a' in variables)
 def test_returned_variable(self):
     """
     Assure get_variables returns variables unique to the context
     """
     variables = get_variables(self._get_context(self.request, {}))
     self.assertTrue('a' not in variables)
     variables = get_variables(self._get_context(self.request, {'a': 3}))
     self.assertTrue('a' in variables)
Esempio n. 4
0
 def test_custom_processors(self):
     variables = get_variables(self._get_context(
         self.request, {}, processors=[])
     )
     self.assertTrue('custom_processor_var' not in variables)
     variables = get_variables(self._get_context(
         self.request, {}, processors=[test_processor])
     )
     self.assertTrue('custom_processor_var' in variables)
Esempio n. 5
0
def variables(context):
    """
    Given a context, return a flat list of variables available in the context.
    """
    availables = get_variables(context)
    pprint(availables)
    return availables
def variables(context):
    """
    Given a context, return a flat list of variables available in the context.
    """
    availables = get_variables(context)
    pprint(availables)
    return availables
Esempio n. 7
0
 def test_global_context_processors(self):
     """
     Assure get_variables contains known global context processors such as
     request and user
     """
     variables = set(get_variables(self._get_context(self.request)))
     self.assertTrue(variables.issuperset(set(self.known_globals)))
 def test_global_context_processors(self):
     """
     Assure get_variables contains known global context processors such as
     request and user
     """
     variables = set(get_variables(self._get_context(self.request)))
     self.assertTrue(variables.issuperset(set(self.known_globals)))
def set_trace(context):
    """
    Start a pdb set_trace inside of the template with the context available as
    'context'. Uses ipdb if available.
    """
    print("For best results, pip install ipdb.")
    print("Variables that are available in the current context:")
    availables = get_variables(context)
    pprint(availables)
    print('Type `availables` to show this list.')
    print('Type <variable_name> to access one.')
    for var in availables:
        locals()[var] = context[var]
    pdb.set_trace()
    return ''
Esempio n. 10
0
def pydevd(context):
    """
    Start a pydev settrace
    """
    global pdevd_not_available
    if pdevd_not_available:
        return ''
    try:
        import pydevd
    except ImportError:
        pdevd_not_available = True
        return ''
    availables = get_variables(context)
    for var in availables:
        locals()[var] = context[var]
    #catch the case where no client is listening
    try:
        pydevd.settrace()
    except socket.error:
        pdevd_not_available = True
    return ''
Esempio n. 11
0
def set_trace(context):
    """
    Start a pdb set_trace inside of the template with the context available as
    'context'. Uses ipdb if available.
    """
    try:
        import ipdb as pdb
    except ImportError:
        import pdb
        print("For best results, pip install ipdb.")
    print("Variables that are available in the current context:")
    render = lambda s: template.Template(s).render(context)
    availables = get_variables(context)
    pprint(availables)
    print('Type `availables` to show this list.')
    print('Type <variable_name> to access one.')
    print('Use render("template string") to test template rendering')
    # Cram context variables into the local scope
    for var in availables:
        locals()[var] = context[var]
    pdb.set_trace()
    return ''
Esempio n. 12
0
def pydevd(context):
    """
    Start a pydev settrace
    """
    global pdevd_not_available
    if pdevd_not_available:
        return ''
    try:
        import pydevd
    except ImportError:
        pdevd_not_available = True
        return ''
    render = lambda s: template.Template(s).render(context)
    availables = get_variables(context)
    for var in availables:
        locals()[var] = context[var]
    #catch the case where no client is listening
    try:
        pydevd.settrace()
    except socket.error:
        pdevd_not_available = True
    return ''
def set_trace(context):
    """
    Start a pdb set_trace inside of the template with the context available as
    'context'. Uses ipdb if available.
    """
    try:
        import ipdb as pdb
    except ImportError:
        import pdb
        print("For best results, pip install ipdb.")
    print("Variables that are available in the current context:")
    render = lambda s: template.Template(s).render(context)
    availables = get_variables(context)
    pprint(availables)
    print('Type `availables` to show this list.')
    print('Type <variable_name> to access one.')
    print('Use render("template string") to test template rendering')
    # Cram context variables into the local scope
    for var in availables:
        locals()[var] = context[var]
    pdb.set_trace()
    return ''