Forum OpenACS Q&A: ArsDigita Templating System

Collapse
Posted by Roberto Mello on
Vlad made his tarball of the ATS available, I downloaded a copy and today finally I have time to look at it. The thread where this was discussed is here https://openacs.org/forums/message-view?message_id=17849.

According to Vlad, I should put the ats dir under the AOLserver modules/tcl directory. Vlad, is that correct? I am a templating newbie, so forgive me if any of these are dumb.

One thing that is puzzling me is that under database-procs/ there are two files: generic.tcl and oracle.tcl. generic.tcl implements the API for query, onevalue, onerow and multirow.

However, oracle.tcl implements get_db_handle, release_db_handle, begin_db_transaction, end_db_transaction, query, onevalue, onerow, multirow, multilist, nestedlist, onelist, dml, iterate. It also implements caching of queries and the API implemented in oracle.tcl is much more detailed and with more checking than in generic.tcl. Most of these make use of ns_ora (I don't know why plain ns_db wasn't used. Anyone know?).

Anyways, I think the best way to go is to port these better-implemented oracle.tcl functions to generic.tcl.

Another question is where does the master template go? Thanks.

Collapse
Posted by Don Baccus on
The ns_ora calls are probably to the newish aD select and dml driver
API that allows things like:

ns_ora select "select foo from bar where key = :tcl_key"

The driver looks up tcl_key in your Tcl environment.

We've got that implemented in the newest Postgres driver (thanks
mostly to Dan) as ns_pg_bind commands.

There's actually nothing about these commands that are db-specific and
one thing I've discussed with a couple of folks is that eventually we
may just want to extend ns_db to do these tcl-var lookups, at least
for drivers we support for OpenACS.  This implies a fork from the aD
Oracle driver, but a minor one and since aD will not be doing a hell
of a lot of future support work on the driver there's probably no real
cost involved, in practice.

But, for now, we'll use ns_pg_bind.  In ACS 4x the calls are
restricted to the database API anyway (which I've already ported, BTW).

Collapse
Posted by Jonathan Ellis on
Where can I get this new driver and db API?  I looked in the sdm and couldn't find anything...  Are they up on cvs already?
Collapse
Posted by Vlad Seryakov on
master template may be specified as DefaultMaster parameter in config file. Otherwise it is hardcoded into tag-init.tcl as /www/default-master.It uses ad_parameter function, which i modified into ns_config for /ats section.
database-proc/oracle.tcl is used for Oracle, but it is possible just modify ns_ora into ns_db and it works fine.I am using modified version of oracle.tcl, but i didn't completed this for production use.
Collapse
Posted by Wolfgang Winkler on
Is the master/slave functionality working for you? If I view the
compiled slave template I get

set __adp_output ""
append __adp_output "<master src="master">

<property name="title">My Page</property>
...

set __adp_output

Shouldn't the master-tag be compiled too, to set the __adp_master?

Collapse
Posted by Vlad Seryakov on
Master template is working, i justdon't use default master, i always
specify which master template to use.
Collapse
Posted by Christian Brechb&uuml;hler on
Wolfgang Winkler is right, the <master> (and <property>) tags should get translated, too. The complete slave page from the demo should translate into this:
set __adp_output ""

    set __adp_master [template::util::url_to_file "master" "$__adp_stub"]
set __adp_properties(title) "My Page"
append __adp_output "

<p>This is my page.</p>
"
set __adp_output
Your exact formatting might differ a bit, because this is from the demo page in package acs_templating under ACS 4.2, but the templating system should behave essentially the same. (I take it that you're using the standalone ATS.)
Collapse
Posted by Wolfgang Winkler on
I looked a bit closer and found, that in the function
adp_compile_chunk the various new tags should be changed into the
strings that are defined in tag-init.tcl.

They use the function ns_register_adptag, so this should be done
automatically by the funtcion ns_adp_parse. Although the tags are
registered, they are not substituted.

But if you call the .adp-files directly the tags get substituted.

Collapse
Posted by Carl Coryell-Martin on
A couple of weeks ago I ported our development installation of the ATS to use a modifed version of the oracle.tcl file rather than generic.tcl.

Basically I replaced ns_ora with ns_db.

In theory this bought me some really nice caching technology which wasn't implemented in my generic.tcl. I am still testing it to see how well it works, so your milage may vary...

cheers,