You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by Nagarajan Chinnasamy <na...@gmail.com> on 2012/07/22 16:55:37 UTC
AddType directives to support .tcl extension
Hello,
First of all, Thank You for your efforts of supporting Tcl under Apache
Server. This definitely eliminates the need for me to learn yet another
language to port my applications to web.
I just installed the latest version of Rivet (v2) on Debian 6 Squeeze and
could successfully browse through the example .rvt pages found on Rivet
Home Page.
This is a question on the pages written with .tcl extension. My
understanding was that the .tcl and .rvt extensions are mutually
exchangeable. However, when I renamed a .rvt file to .tcl and invoked it
from the browser, I get errors on the page.
.tcl file content (.rvt renamed to .tcl):
---------------------------------------------------
<? set hello_message "Hello world" ?>
> <html>
> <head>
> <title><? puts $hello_message ?></title>
> </head>
> <body><?
> puts [html $hello_message pre b]
> ?></body>
> </html>
view-source output from the browser (chrome):
---------------------------------------------------------------
<PRE>
> <HR>invalid command name "<?"
> while executing
> "<? set hello_message "Hello world" ?>"<HR>
> <P><B>OUTPUT BUFFER:</B></P>
> <? set hello_message "Hello world" ?>
> <html>
> <head>
> <title><? puts $hello_message ?></title>
> </head>
> <body><?
> puts [html $hello_message pre b]
> ?></body>
> </html>
> </PRE>
Content of rivet.conf file placed in mods-enabled folder is:
----------------------------------------------------------------------------
<IfModule mod_rivet.c>
> # Let the module handle .rvt and .tcl files.
> AddType application/x-httpd-rivet rvt
> AddType application/x-rivet-tcl tcl
> # The default charset can be specified in the configuration
> AddType "application/x-httpd-rivet; charset=utf-8" rvt
> </IfModule>
Please explain.... may be my understanding of .rvt and .tcl extensions are
exchangeable isn't correct!?
Best Regards,
Nagu.
Re: AddType directives to support .tcl extension
Posted by Jeff Lawson <je...@bovine.net>.
Another primary difference is that .rvt files start out with the
expectation that they are outputting literal HTML content until the
escapement <? ?> sequence is encountered. Think of it as rvt files being
"HTML files with embedded blocks of Tcl", while .tcl files are just pure
Tcl script starting out in Tcl interpretation mode. I don't think it is
wise to change the meanings of .rvt/.tcl to have non-standard
interpretations, since it may complicate maintenance and sharing of your
code with others in the future.
PHP was initially developed as a HTML language and so when pages are run
they are always assumed to be HTML content until the escapement <? ?>
sequence is encountered. When you require/include other PHP files within a
PHP page, the extension actually doesn't matter (some people use .inc
extensions for such included files). Those included files are assumed to
be raw PHP-code and do not require an additional escapement sequence since
it was being included from such a block.
On Sun, Jul 22, 2012 at 5:18 PM, Massimo Manghi <ma...@unipr.it>wrote:
> Dear Nagu
>
> David and Damon should be called in to give a definite answer. The answer
> I gave myself was that rvt templates run within the ::request namespace and
> this namespace is erased on every request, thus deleting any variable
> created in a script embedded in it which was not fully qualified outside
> that namespace. There are of course cases where you want to store
> persistent application data in some variable and you can do it putting the
> in suitable namespace, still you can rely on the fact that everything you
> set within a template, unless intentionally scoped outside of it, it will
> be destroyed automatically
>
> cheers
>
> -- Massimo
>
>
>
>
> On 2012-07-22 19:46, Nagarajan Chinnasamy wrote:
>
>> Thanks Massimo. I also realized that they are being treated
>> differently, when I re-looked at the source of rivet-ajax example.
>>
>> This understanding (of .tcl & .rvt being same) was because of my
>> hang-over from php which Ive just started learning.
>>
>>
>> Any reason why we have separated them as different (unlike php)?
>>
>> Best Regards,
>> Nagu.
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.**apache.org<ri...@tcl.apache.org>
> For additional commands, e-mail: rivet-dev-help@tcl.apache.org
>
>
Re: AddType directives to support .tcl extension
Posted by Massimo Manghi <ma...@unipr.it>.
Dear Nagu
David and Damon should be called in to give a definite answer. The
answer I gave myself was that rvt templates run within the ::request
namespace and this namespace is erased on every request, thus deleting
any variable created in a script embedded in it which was not fully
qualified outside that namespace. There are of course cases where you
want to store persistent application data in some variable and you can
do it putting the in suitable namespace, still you can rely on the fact
that everything you set within a template, unless intentionally scoped
outside of it, it will be destroyed automatically
cheers
-- Massimo
On 2012-07-22 19:46, Nagarajan Chinnasamy wrote:
> Thanks Massimo. I also realized that they are being treated
> differently, when I re-looked at the source of rivet-ajax example.
>
> This understanding (of .tcl & .rvt being same) was because of my
> hang-over from php which Ive just started learning.
>
> Any reason why we have separated them as different (unlike php)?
>
> Best Regards,
> Nagu.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: AddType directives to support .tcl extension
Posted by Nagarajan Chinnasamy <na...@gmail.com>.
Thanks Massimo. I also realized that they are being treated differently,
when I re-looked at the source of rivet-ajax example.
This understanding (of .tcl & .rvt being same) was because of my hang-over
from php which I've just started learning.
Any reason why we have separated them as different (unlike php)?
Best Regards,
Nagu.
On Sun, Jul 22, 2012 at 10:23 PM, Massimo Manghi <ma...@unipr.it>wrote:
> On 2012-07-22 16:55, Nagarajan Chinnasamy wrote:
>
>> Hello,
>>
>> First of all, Thank You for your efforts of supporting Tcl under
>> Apache Server. This definitely eliminates the need for me to learn yet
>> another language to port my applications to web.
>>
>> I just installed the latest version of Rivet (v2) on Debian 6 Squeeze
>> and could successfully browse through the example .rvt pages found on
>> Rivet Home Page.
>>
>
>
>> This is a question on the pages written with .tcl extension. My
>> understanding was that the .tcl and .rvt extensions are mutually
>> exchangeable. However, when I renamed a .rvt file to .tcl and
>> invoked it from the browser, I get errors on the page.
>>
>>
> No, it doesn't work like that. Templates (.rvt) go into a parsing stage
> prior to being run within the ::request namespace, pure Tcl scripts (.tcl)
> are simply evaluated at the global namespace. That also implies HTML code
> has to be output explicitly using the 'puts' command.
>
>
>
> .tcl file content (.rvt renamed to .tcl):
>> ------------------------------**---------------------
>>
>> <? set hello_message "Hello world" ?>
>>> <html>
>>> <head>
>>> <title><? puts $hello_message ?></title>
>>> </head>
>>> <body><?
>>> puts [html $hello_message pre b]
>>> ?></body>
>>> </html>
>>>
>>
>> view-source output from the browser (chrome):
>> ------------------------------**------------------------------**---
>>
>> <PRE>
>>> <HR>invalid command name "<?"
>>> while executing
>>> "<? set hello_message "Hello world" ?>"<HR>
>>> <P><B>OUTPUT BUFFER:</B></P>
>>> <? set hello_message "Hello world" ?>
>>> <html>
>>> <head>
>>> <title><? puts $hello_message ?></title>
>>> </head>
>>> <body><?
>>> puts [html $hello_message pre b]
>>> ?></body>
>>> </html>
>>> </PRE>
>>>
>>
>>
> in fact, the script was evaluated as pure Tcl, therefore the interpreter
> couldn't figure out what the "<?" was about
>
>
>
> Content of rivet.conf file placed in mods-enabled folder is:
>>
>> ------------------------------**------------------------------**
>> ----------------
>>
>
> .rvt scripts are registered as different types of documents triggering the
> code that invokes the parser over them, the point of having 2 types
> registered was precisely that
>
>
>
> -- Massimo
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.**apache.org<ri...@tcl.apache.org>
> For additional commands, e-mail: rivet-dev-help@tcl.apache.org
>
>
Re: AddType directives to support .tcl extension
Posted by Massimo Manghi <ma...@unipr.it>.
On 2012-07-22 16:55, Nagarajan Chinnasamy wrote:
> Hello,
>
> First of all, Thank You for your efforts of supporting Tcl under
> Apache Server. This definitely eliminates the need for me to learn
> yet
> another language to port my applications to web.
>
> I just installed the latest version of Rivet (v2) on Debian 6 Squeeze
> and could successfully browse through the example .rvt pages found on
> Rivet Home Page.
>
> This is a question on the pages written with .tcl extension. My
> understanding was that the .tcl and .rvt extensions are mutually
> exchangeable. However, when I renamed a .rvt file to .tcl and
> invoked it from the browser, I get errors on the page.
>
No, it doesn't work like that. Templates (.rvt) go into a parsing stage
prior to being run within the ::request namespace, pure Tcl scripts
(.tcl) are simply evaluated at the global namespace. That also implies
HTML code has to be output explicitly using the 'puts' command.
> .tcl file content (.rvt renamed to .tcl):
> ---------------------------------------------------
>
>> <? set hello_message "Hello world" ?>
>> <html>
>> <head>
>> <title><? puts $hello_message ?></title>
>> </head>
>> <body><?
>> puts [html $hello_message pre b]
>> ?></body>
>> </html>
>
> view-source output from the browser (chrome):
> ---------------------------------------------------------------
>
>> <PRE>
>> <HR>invalid command name "<?"
>> while executing
>> "<? set hello_message "Hello world" ?>"<HR>
>> <P><B>OUTPUT BUFFER:</B></P>
>> <? set hello_message "Hello world" ?>
>> <html>
>> <head>
>> <title><? puts $hello_message ?></title>
>> </head>
>> <body><?
>> puts [html $hello_message pre b]
>> ?></body>
>> </html>
>> </PRE>
>
in fact, the script was evaluated as pure Tcl, therefore the
interpreter couldn't figure out what the "<?" was about
> Content of rivet.conf file placed in mods-enabled folder is:
>
> ----------------------------------------------------------------------------
.rvt scripts are registered as different types of documents triggering
the code that invokes the parser over them, the point of having 2 types
registered was precisely that
-- Massimo
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org