Is it possible to make "request" available in jinja2 templates like flask? (it might be possible by setting it as global? ill re-search that, if not or if theres another way in pyramid pls tell me)
(i dont use class bases views)
pdobrogost joined the channel
brainysmurf has quit
cdunklau
evagelos: hmm why do you need the request
evagelos
cdunklau: cause i need to put data from db depending on the user from request
actually i can just pass request to render
cdunklau
evagelos: sounds like that should happen in the view though
evagelos
the thing is how should i do it in the end, i mean either add_request_method or..?
cdunklau: well this packages uses the "main" package to send emails and iv been asked the main should handle everything
i tried to do it like u said and iv been asked to revert it back
so i have to call a function inside the jinja2 template where this function depends on the request
rickmak joined the channel
cdunklau
evagelos: i don't really see it
evagelos: but there's gotta be a way to inject the request object into the template globals
evagelos
so A is main package, B uses includeme to be included when A starts
B has views that need to send emails, A has the send_email function
B templates have a spot for an image(per user)
cdunklau
so, sorry, i don't know
:9
:(
evagelos
ok ok np :)
so the solution i guess is hook up the function while B starts, I pass the request in the templates so B templates can call that function
i dont see any other solution so i will use add_request_method, im not expert whatsoever
atomekk joined the channel
it just goes through A(main package) where it shouldn't know anything specific from B package thats the problem i guess
El_Rolando has quit
evagelos has quit
evagelos joined the channel
sirn joined the channel
ddimmich has quit
ddimmich joined the channel
ddimmich has quit
ddimmich joined the channel
El_Rolando joined the channel
hvelarde joined the channel
ddimmich has quit
MrTango joined the channel
mr_jolly joined the channel
mr_jolly has quit
mr_jolly joined the channel
mr_jolly has quit
MrTango has quit
mr_jolly joined the channel
mr_jolly has quit
Ergo
evagelos: request is available in the jinja2 templates
are you using pyramid_jinja2?
cdunklau
heh is it really
i couldn't find a mention of that in the docs
i haven't gotten far enough in my pyramid project to need that
cdunklau: the default template projects set things up for you - you should be able to access request normally
cdunklau
neat
Ergo
same with any other variable that you return from your views - you should not need to call render() directly unless you do something specific
(like rendering emails)
waigani joined the channel
waigani_ joined the channel
rickmak_ joined the channel
evagelos
Ergo im not sure but anyway i can pass it in the render()
driti joined the channel
Well guys my problem was that i was creating a jinja2 environment in order to render etc etc i think i finally figure it out how to do it properly and seems that i have to call render