On Tue, Mar 1, 2011 at 8:09 AM, Chris Withers <ch...@simplistix.co.uk> wrote: > On 28/02/2011 18:42, Tres Seaver wrote: >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On 02/28/2011 12:53 PM, Chris Withers wrote: >>> >>> On 28/02/2011 16:58, Tres Seaver wrote: >>>>> >>>>> I'm worried that I'm being evil. Am I being evil? >>>>> How else can I get hold of Pyramid's notion of the current user id >>>>> inside a SessionExtension? >>>> >>>> The "approved" way to share request-specific information is to just pass >>>> the request: in this case, the obvious candidate is to make the request >>>> an attribute of the event. >>> >>> What event are you referring to? >> >> The one published to your listener. > > What listener? > > I'm using a SessionExtension: > > http://www.sqlalchemy.org/docs/orm/interfaces.html#session-events
That probably qualifies for "not being able to change the event code". > The only way I can think to get request there would be to try and stick it > on either the model object, or the session object, both of which feel even > more hacky than getting it from a thread local... I have very similar code in Kotti that gets hold of the request to set the owner id: https://github.com/dnouri/Kotti/blob/master/kotti/events.py And I don't feel evil at all. Though testing it turned out to be indeed a bit tricky: https://github.com/dnouri/Kotti/blob/master/kotti/tests.py#L626 Maybe the docs should be changed to say it's OK if you're working with a third party API and you know what you're doing. Daniel -- Daniel Nouri http://danielnouri.org -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.