On May 24, 2:57 pm, Alireza Savand <
alireza.sav...@gmail.com> wrote:
> On Thursday, May 24, 2012 4:46:34 PM UTC+4, bruno desthuilliers wrote:
>
>
> > Uhu... What if I'm running my code from the shell or a command ?
>
> By the way, there is also *set_request*(*request*) for that situation.
Yes. In Zope/Plone too, and then you have to setup a fake request for
each and every "no-web" interaction, and then it still manage to fail
one way or another. Been here, done that, have the tee-shirt.
Logging... Well, you know you do have a whole traceback in your logs
using logger.exception in a try/except block ? You can as well let
exceptions propagate up until your view (or exception handling
middleware) and log relevant request data from there.
I don't mean you don't have a use case, but your solution leads to
other problems that from experience are possibly worse. FWIW, I wonder
if you couldn't just hack the root logger from a middleware to inject
relevant request data from the logging itself instead.