def deconstruct(response_data):
    """
    Deconstruct the supplied C{response_data} into its constituent
    web-related elements.

    Returns a tuple of the form:

        C{(<view_name(string)>, <model(dict)>, <(HTTP) status_code(int)>)}

    @param response_data: that which is returned by a Controller; must not be
    C{None}.
    @return: the constituent web-related elements as a tuple; never C{None}.
    """

    assert response_data is not None, 'The response data is required.'

    if is_stringy(response_data):
        return deconstruct_string(response_data)
    elif isinstance(response_data, (tuple, list)):
        return deconstruct_list(response_data)
    elif isinstance(response_data, dict):
        return deconstruct_dict(response_data)
def required_view_name(view_name):
    if not is_stringy(view_name):
        raise KrumpException('Required view name must be a string.')
    if not has_text(view_name):
        raise KrumpException('Required view name is empty.')
    return view_name
Exemple #3
0
 def test_is_stringy_with_string(self):
     self.assertTrue(is_stringy(''))
Exemple #4
0
 def test_is_stringy_with_other_object(self):
     self.assertFalse(is_stringy([]))
Exemple #5
0
 def test_is_stringy_with_none(self):
     self.assertFalse(is_stringy(None))
Exemple #6
0
 def test_is_stringy_with_unicode(self):
     self.assertTrue(is_stringy(u''))