On Feb 16, 2007, at 1:19 PM, Mike Orr wrote:

>
> It would be nice if 'c', 'g', 'h', and 'request' had an
> easier-to-remember way to inspect their contents than:
>
>     pprint.pprint(vars(request._current_obj()))
> Al these other ways do this:
>
> pprint.pprint(request);  pprint.pprint(g)
> <paste.wsgiwrappers.WSGIRequest object at 0xb763a30c>
> <inews2.lib.app_globals.Globals object at 0xb760fbec>

We need to add __repr__ to these classes -- WSGIRequest, the c  
classes, and the Beaker objects. I've logged a ticket:

http://pylonshq.com/project/pylonshq/ticket/202

The stock Globals class just extends object, so we can't give all  
projects' Globals a __repr__. This might be a good reason to  
establish a base Globals class for new projects (Globals used to have  
a base class in older Pylons versions).

>
> pprint.pprint(vars(request);  pprint.pprint(vars(g))
> {'____local__': <thread._local object at 0xb795ac98>, '____name__':  
> 'Request'}
> {'____local__': <thread._local object at 0xb795acc8>, '____name__':  
> 'G'}
>
> pprint.pprint(request.items()); pprint.pprint(g.items())
> exceptions.AttributeError: 'WSGIRequest' object has no attribute  
> 'items'
>
> pprint.pprint(g.items())
> exceptions.AttributeError: 'Globals' object has no attribute 'items'
>
> pprint.pprint(dir(request))
> # Lists a bunch of underscored methods.
>

dir and vars are pretty much just going to suck for Proxy objects --  
at least until Python 2.6. 2.6 will add a __dir__ method that allows  
customization of dir(). I don't know if it will apply to vars() too,  
though.

--
Philip Jenvey



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to