Discussion:
[bottlepy] Accessing cookie data in templates? Is there a better way?
Marco Scannadinari
2015-03-25 20:27:28 UTC
Permalink
In *.tpl files, is there a way to access cookie data inside the template
without explicitly passing the bottle object to the template
({{b.request.get_cookie("foo")}})? Is there a better way of doing it? Seems
like I'm swimming against the current on this... Thanks!

-marco
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Avelino
2015-03-27 16:47:13 UTC
Permalink
Send "request.cookies" for template!

Sample: https://gist.github.com/avelino/0cd691a98d3f4e86f416
Post by Marco Scannadinari
In *.tpl files, is there a way to access cookie data inside the template
without explicitly passing the bottle object to the template
({{b.request.get_cookie("foo")}})? Is there a better way of doing it? Seems
like I'm swimming against the current on this... Thanks!
-marco
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
For more options, visit https://groups.google.com/d/optout.
--
Thiago Avelino - GPG Keys: 2E98180A
<***@avelino.xxx> (Mail/XMPP)
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marco Scannadinari
2015-03-27 17:16:13 UTC
Permalink
Thanks, I was not aware of the cookies attribute! Is there a way to pass
this object to all templates implicitly, since in most of my URL handlers I
just return template("foo")... Otherwise I will have to use
return template("foo", cookies=b.request.cookies)
each time :/

-marco
Post by Avelino
Send "request.cookies" for template!
Sample: https://gist.github.com/avelino/0cd691a98d3f4e86f416
Post by Marco Scannadinari
In *.tpl files, is there a way to access cookie data inside the template
without explicitly passing the bottle object to the template
({{b.request.get_cookie("foo")}})? Is there a better way of doing it?
Seems
Post by Marco Scannadinari
like I'm swimming against the current on this... Thanks!
-marco
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google
Groups "bottlepy" group.
Post by Marco Scannadinari
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Thiago Avelino - GPG Keys: 2E98180A
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Avelino
2015-03-27 17:37:01 UTC
Permalink
Is the same process, difference that you are using template file.
Post by Marco Scannadinari
Thanks, I was not aware of the cookies attribute! Is there a way to pass
this object to all templates implicitly, since in most of my URL handlers I
just return template("foo")... Otherwise I will have to use
return template("foo", cookies=b.request.cookies)
each time :/
-marco
Post by Avelino
Send "request.cookies" for template!
Sample: https://gist.github.com/avelino/0cd691a98d3f4e86f416
Post by Marco Scannadinari
In *.tpl files, is there a way to access cookie data inside the template
without explicitly passing the bottle object to the template
({{b.request.get_cookie("foo")}})? Is there a better way of doing it?
Seems
Post by Marco Scannadinari
like I'm swimming against the current on this... Thanks!
-marco
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google
Groups "bottlepy" group.
Post by Marco Scannadinari
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Thiago Avelino - GPG Keys: 2E98180A
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
For more options, visit https://groups.google.com/d/optout.
--
Thiago Avelino - GPG Keys: 2E98180A
<***@avelino.xxx> (Mail/XMPP)
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marco Scannadinari
2015-03-28 16:10:40 UTC
Permalink
Yep I am aware it is the same, but instead of `template("xyz",
cookies=request.cookies)`, I would like to write `template("xyz")`, and the
`cookies` object be passed automatically each time. Is this possible?

Thanks,

-marco
Post by Avelino
Is the same process, difference that you are using template file.
Post by Marco Scannadinari
Thanks, I was not aware of the cookies attribute! Is there a way to pass
this object to all templates implicitly, since in most of my URL
handlers I
Post by Marco Scannadinari
just return template("foo")... Otherwise I will have to use
return template("foo", cookies=b.request.cookies)
each time :/
-marco
Post by Avelino
Send "request.cookies" for template!
Sample: https://gist.github.com/avelino/0cd691a98d3f4e86f416
Post by Marco Scannadinari
In *.tpl files, is there a way to access cookie data inside the
template
Post by Marco Scannadinari
Post by Avelino
Post by Marco Scannadinari
without explicitly passing the bottle object to the template
({{b.request.get_cookie("foo")}})? Is there a better way of doing
it?
Post by Marco Scannadinari
Post by Avelino
Seems
Post by Marco Scannadinari
like I'm swimming against the current on this... Thanks!
-marco
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google
Groups "bottlepy" group.
Post by Marco Scannadinari
To unsubscribe from this group and stop receiving emails from it,
send
Post by Marco Scannadinari
Post by Avelino
Post by Marco Scannadinari
For more options, visit https://groups.google.com/d/optout.
--
Thiago Avelino - GPG Keys: 2E98180A
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google
Groups "bottlepy" group.
Post by Marco Scannadinari
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Thiago Avelino - GPG Keys: 2E98180A
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to a topic in the
Google Groups "bottlepy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/bottlepy/zK6wSM8m5qU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcel Hellkamp
2015-04-02 13:58:04 UTC
Permalink
Sure

import bottle
def template(*a, **ka):
ka['cookies'] = bottle.request.cookies
return bottle.template(*a, **ka)
Post by Marco Scannadinari
Yep I am aware it is the same, but instead of `template("xyz",
cookies=request.cookies)`, I would like to write `template("xyz")`, and
the `cookies` object be passed automatically each time. Is this possible?
Thanks,
-marco
Is the same process, difference that you are using template file.
Post by Marco Scannadinari
Thanks, I was not aware of the cookies attribute! Is there a way
to pass
Post by Marco Scannadinari
this object to all templates implicitly, since in most of my URL
handlers I
Post by Marco Scannadinari
just return template("foo")... Otherwise I will have to use
return template("foo", cookies=b.request.cookies)
each time :/
-marco
Post by Avelino
Send "request.cookies" for template!
Sample: https://gist.github.com/__avelin__o/0cd691a98d3f4e86f416
<https://gist.github.com/avelino/0cd691a98d3f4e86f416>
Post by Marco Scannadinari
Post by Avelino
Post by Marco Scannadinari
In *.tpl files, is there a way to access cookie data inside
the template
Post by Marco Scannadinari
Post by Avelino
Post by Marco Scannadinari
without explicitly passing the bottle object to the template
({{b.request.get_cookie("foo")____}})? Is there a better way
of doing it?
Post by Marco Scannadinari
Post by Avelino
Seems
Post by Marco Scannadinari
like I'm swimming against the current on this... Thanks!
-marco
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/____bottlepy
<http://groups.google.de/group/bottlepy> for mailing list options.
Post by Marco Scannadinari
Post by Avelino
Post by Marco Scannadinari
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google
Groups "bottlepy" group.
Post by Marco Scannadinari
To unsubscribe from this group and stop receiving emails from
it, send
Post by Marco Scannadinari
Post by Avelino
Post by Marco Scannadinari
For more options, visit https://groups.google.com/d/__op__tout
<https://groups.google.com/d/optout>.
Post by Marco Scannadinari
Post by Avelino
--
Thiago Avelino - GPG Keys: 2E98180A
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/____bottlepy
<http://groups.google.de/group/bottlepy> for mailing list options.
Post by Marco Scannadinari
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google
Groups "bottlepy" group.
Post by Marco Scannadinari
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/__op__tout
<https://groups.google.com/d/optout>.
--
Thiago Avelino - GPG Keys: 2E98180A
http://avelino.xxx
I love long mails! - http://email.is-not-s.ms/
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/____bottlepy
<http://groups.google.de/group/bottlepy> for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to a topic in
the Google Groups "bottlepy" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/__to__pic/bottlepy/zK6wSM8m5qU/__unsub__scribe
<https://groups.google.com/d/topic/bottlepy/zK6wSM8m5qU/unsubscribe>.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/__op__tout
<https://groups.google.com/d/optout>.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...