Discussion:
[bottlepy] bottle template
Larry Owens
2016-05-12 16:07:55 UTC
Permalink
Can a python def be defined and used within a template?
--
--
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.
Derek Bartron
2016-06-17 18:16:15 UTC
Permalink
Yes. A template is a python program, and such has access to everything you
would do inside of any python app. You can import modules, run SQL
queries, do math, run for loops, and even define defs. Although I find it
much easier to create a function inside of a module and either import it
inside the tpl and just call the function, or better bring it in as an
object when the template is called (thus avoiding importing it again if
it's already imported under the main module).
Post by Larry Owens
Can a python def be defined and used within a template?
--
--
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.
Larry Owens
2016-07-04 16:10:50 UTC
Permalink
Thank you. I found my error. I missed that an "end" statement is required
to end a def function.
Post by Derek Bartron
Yes. A template is a python program, and such has access to everything
you would do inside of any python app. You can import modules, run SQL
queries, do math, run for loops, and even define defs. Although I find it
much easier to create a function inside of a module and either import it
inside the tpl and just call the function, or better bring it in as an
object when the template is called (thus avoiding importing it again if
it's already imported under the main module).
Post by Larry Owens
Can a python def be defined and used within a template?
--
--
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...