On 10/04/2010 10:50 AM, mart wrote:
Sorry, bad typing day....

I need to display some dictionaries, these are generated according to
DATA provided by the user. I would like to display them on a page, but
need to display them pretty (like with pprint). I am wrapping this
part of the app in plugin_wiki: I have 4 types of data that that get
inserted in to a DB once generated that I can use for for this (i
couldn't decide, so gave myself options):

Do you kow fo the module called pprint (pretty-print). It comes with Python, and does a decent job with dictionaries (even nested ones) right out of the box:
    from pprint import pprint
    pprint(...)
If you want further control, you can investigate the module beyond the simple shortcut pprint function.


1) a dictionary (containing other dictionaries embedded within)
2) the same dict, but inserted as_string
3) the same dict, but wrapped up like an object
4) an xml representation of the same dict

I can write any of these 4 very nicely to the terminal output, or a
file, but it seems not on a web2py app page... Once displayed, the
user will understand the 'semantics. does anybody have a trick  for
displaying like this on a webApp page?

here is an example of what I am looking for (not sure how this will
look here, but, apologies in advance if it does look garbled):


{'resources': {'fileSets': {'fileSet': [{'files': {'file':
[{'installPath': '${installRoot}',
                                                              'source':
'../file001.txt'},

{'installPath': '${installRoot}',
                                                              'source':
'../file002.txt'}]},
                                          'rules': {'and': {'include':
{'attribute': 'os',

'match': 'symbian'},
                                                            'or':
{'include': [{'attribute': 'osver',

'match': 's60'},

{'attribute': 'os',

'match': 's60fp3'}]}},
                                                    'exclude':
{'attribute': 'osver',

'macth': 'DontIncludeMe'}}},
                                         {'files': {'file':
[{'installPath': '${installRoot}',
                                                              'source':
'../file003.txt'},

{'installPath': '${installRoot}',
                                                              'source':
'../file004.txt'}]},
                                          'rules': {'and': {'include':
{'attribute': 'os',

'match': 'symbian'},
                                                            'or':
{'include': {'attribute': 'os',

'match': 's60fp3'}}}}}]},
                'includeFiles': {'_text': '/',
                                 'includeFile': {'path': '../aFolder/
file_man.xml'}},
                'packages': {'package': [{'deviceModel': 'Nokia6630',
                                          'installRoot': '/mart/private/
20008421/mo',
                                          'name': 'package001',
                                          'os': 'symbian',
                                          'osver': 's60'},
                                         {'deviceModel': 'Nokia6630',
                                          'installRoot': '/mart/private/
20008421/mo',
                                          'name': 'package002',
                                          'os': 'symbian',
                                          'osver': 's60




On Oct 4, 9:29 am, mart<msenecal...@gmail.com>  wrote:
Hi,


--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

Reply via email to