On Sun, Jul 13, 2008 at 6:16 AM, Alberto Valverde <[EMAIL PROTECTED]> wrote: > > Justin Tulloss wrote: >> (....) >> In addition, >> it's very difficult to inspect the object that an SOP refers to since >> it obfuscates the object's __dict__. > > This trick can help: > req = pylons.request._current_obj() # get current request object wrapped > by SOP > print dir(req) > > Again, it's just a matter of documentation IMHO.
It's not "just" documentation. Fundamentally it behaves differently from a normal Python object, so you have to memorize not only the ._current_obj() syntax but also which methods require it and which don't. So it's not a very good proxy. But at least it follows the 80/20 rule of proxying ordinary access if you know what you're looking for. But it falls apart when you don't know what you're looking for, which is why you typed dir(request). You get a bunch of unfamiliar methods instead of what you were expecting. So you call help(request) and find out it's a StackedObjectProxy... but nowhere does it say to call request._current_obj() to get the real object. Somehow help(config) prints help for the real object while help(request) doesn't. I wonder why that is. > [1] By pseudo WSGI middleware I mean middleware that is not really WSGI > middleware since middleware should be transparent to the application it > wraps, that is, if it's missing from the stack then the application > could not care less about it. These are more like a fancy function > decorator which usually sets setup some context for some library > downstream that needs it, for example: toscawidgets, beaker, etc... In other words, the most useful middleware. It's much too late to call these "framework component objects" when thousands of people have learned that a middleware is anything that uses the WSGI protocol on both ends. It's hard even to think of a "true" middleware that would be useful, just the gzip one and TransLogger. "Pseudo" middleware provides a generic service to any application, and that should be lauded, not disparaged as the proponents of true vs false middleware tend to do. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---