Problems with debugging Lists

S

Sancar Saran

Hello again.

I wrote small class for generating and accessing globalized Dictionary.

And of course I want to add some kind of debug ability to check what is
inside...

In php we had print_r function to see entire array structure. After some
search I found some equal module named pprint.

And some how this module wont work with mod_wsgi it was something about
mod_wsgi portability standards.

After some research there where some thing about putting some variables in
apache config to disable this.

And now I can see some dictionary structure in my apache log and I got some
errors like
r += pprint.pprint(self.data)
TypeError: cannot concatenate 'str' and 'NoneType' objects

So is there any way to get dictionary structure in string format ?

Another question is. When I import a module from top is it available for later
imported modules

# -*- coding: utf-8 -*-

import os, sys, cgi, pprint
import cgitb
cgitb.enable()


def application(environ, start_response):
sys.path.append(environ['DOCUMENT_ROOT']+"core")
#sys.path.append(environ['DOCUMENT_ROOT']+"util")
import registry, k5
#from print_r import print_r

# new registry

r = registry.Registry(environ)
r.set_entry('hede','hodo')

#response_headers = [('Content-type',k5.headers['content-type']+';
charset='+k5.headers['charset'])]
#start_response(kk5.headers['status'], response_headers)

# build the response body possibly using the environ dictionary
response_body = 'The request method was %s' % environ['REQUEST_METHOD']
response_body += '<br/>'
response_body += str(r.debug())

# HTTP response code and message
status = '200 OK'

# These are HTTP headers expected by the client.
# They must be wrapped as a list of tupled pairs:
# [(Header name, Header value)].
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(response_body)))]

# Send them to the server using the supplied function
start_response(status, response_headers)

# Return the response body.
# Notice it is wrapped in a list although it could be any iterable.



return [response_body]



Following script was not working. I have to re import pprint from registry.

Is it normal or what is my problem :)

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top