#include with DocumentTemplate?
I'm fairly new to Python and when I asked this question on a couple of the python.org mailing lists, I was told I should probably ask here instead. I'm writing some CGIs in Python and I borrowed the DocumentTemplate module from Zope because it does most of what I need. However, there's one thing that it apparently doesn't do that I would really like. And that would be to use "#include" tags to read in other DTML documents and parse them. That is, tags like this: <!--#include name="header.dtml" --> Does DocumentTemplate already handle that? I couldn't find it in the documentation. If it's not already built-in, is it possible to add such a tag? I've seen the examples on zope.org for adding tags to DocumentTemplate's parser, but I don't know if its possible to get it to read a new file and parse it in the middle of parsing another template. Has anybody already implemented this? Thanks in advance. -- Lance E Sloan Web Services, Univ. of Michigan: Full-service Web and database design, development, and hosting. Specializing in Perl & Python CGIs. http://websvcs.itd.umich.edu/ - "Putting U on the Web"
[Lance E Sloan]
I'm writing some CGIs in Python and I borrowed the DocumentTemplate module from Zope because it does most of what I need. However, there's one thing that it apparently doesn't do that I would really like. And that would be to use "#include" tags to read in other DTML documents and parse them. That is, tags like this:
<!--#include name="header.dtml" -->
Does DocumentTemplate already handle that? I couldn't find it in the documentation.
[Tom] If you want to display ("render") header_dtml, write <dtml-var header_dtml> If you want to call it (i.e., get it to do something that isn't intended to display), write <dtml-call header_dtml> I don't see that there is really a need for an "include" as such since you can incorporate other code as shown above. Do you still think you need to do it? And stop using that obsolete syntax <!--#, even if it's still left over in some documentation. Cheers, Tom P
Lance, Do you mean <dtml-var "myDTMLmethodtobeincluded"> ? Of course, any DTML method will be parsed when the page is viewed, using its context, not rendered into a static file beforehand.. that's the single biggest plus to using Zope, I think.. :) HTH, Chris
I'm fairly new to Python and when I asked this question on a couple of the python.org mailing lists, I was told I should probably ask here instead.
I'm writing some CGIs in Python and I borrowed the DocumentTemplate module from Zope because it does most of what I need. However, there's one thing that it apparently doesn't do that I would really like. And that would be to use "#include" tags to read in other DTML documents and parse them. That is, tags like this:
<!--#include name="header.dtml" -->
Does DocumentTemplate already handle that? I couldn't find it in the documentation.
If it's not already built-in, is it possible to add such a tag? I've seen the examples on zope.org for adding tags to DocumentTemplate's parser, but I don't know if its possible to get it to read a new file and parse it in the middle of parsing another template. Has anybody already implemented this?
Thanks in advance.
Chris Beaumont wrote:
Do you mean <dtml-var "myDTMLmethodtobeincluded"> ?
Hmm. I don't think so, but then, I don't understand all the features of DocumentTemplate, so I'm not sure. Maybe that will do what I want. I thought that the dtml-var tag was just used to display the value of a variable. Does it do more than that? I assume that by "myDTMLmethod", you mean that is a variable that you have assigned a method to. Is that correct? (I have a C background, so I would call it a pointer to a function.) If that's what you mean, it's not what I was hoping for. Basically, I'm looking for something that works just like the SSI '<!--#include name="filename"-->' tag. When DocumentTemplate encounters it in one DTML file, it will read in the specified file, presumably also containing DTML, and parse it, recursively.
Of course, any DTML method will be parsed when the page is viewed, using its context, not rendered into a static file beforehand.. that's the single biggest plus to using Zope, I think..
Yes, I agree. Since I'm new to Python, I don't understand all the terminology yet. What exactly do you mean by "DTML method"? My apologies if I'm asking so many questions that I seem to be a simpleton. Hopefully I'm not getting on anybody's nerves. Yet. -- Lance E Sloan Web Services, Univ. of Michigan: Full-service Web and database design, development, and hosting. Specializing in Perl & Python CGIs. http://websvcs.itd.umich.edu/ - "Putting U on the Web"
I'm writing some CGIs in Python and I borrowed the DocumentTemplate
So you aren't using Zope and the ZODB in a traditional way. This is just importing the DocumentTemplate in a python CGI script? If its the latter I dont know... Cheers. -- Andy McKay.
participants (4)
-
Andy McKay -
Chris Beaumont -
Lance E Sloan -
Thomas B. Passin