On Friday 14 September 2001 18:16, Alexandr Efimov wrote:
> >Yes. AxKit's XSP module does this. Your SQL can be generated with the
> >AxKit::XSP::ESQL module, and then you can loop over the results
> >in your XSLT stylesheet using either xsl:foreach or (better still)
> > using a template.
>
> Actually using AxKit::XSP::ESQL module seems to be much
> more complicated compared to calling a function in Template Toolkit,
> for example, it is inconvenient to write code like this:
> --------------
> <sql:execute-query>
> <sql:driver>Sybase</sql:driver>
> <sql:dburl>database=mydb</sql:dburl>
> <sql:username>matt</sql:username>
> <sql:password>millionaire</sql:password>
>
> <sql:query>SELECT MessageId, Subject FROM Messages</sql:query>
> </sql:execute-query>
> -----------------
> in Template, it would be something like
> [% data=fetch({sql=>"SELECT MessageId, Subject FROM Messages"}) %]
> and we can connect to database only once, probably before
> processing a Template. Also, logic seems to be easier to implement
> with Template than with AxKit.
Your examples are not equivalent ! To begin with, your connection params are
unlikely to be in the same place as the query, otherwise you'd have to
include them everytime you want to use the connection, which would be
painful. For this, you can use either entities or XInclude. The example would
be more like:
<sql:execute-query>
&connect_params;
<sql:query>SELECT MessageId, Subject FROM Messages</sql:query>
</sql:execute-query>
But this is still useless (as is your TT example), and not really equivalent.
A more exact equivalent would be:
<xsp:logic>
my $data = Foo::fetch({sql=>"SELECT MessageId, Subject FROM Messages"});
</xsp:logic>
AxKit::XSP::ESQL is great if you need to generate XML records from SQL. It
has many helpers to do that in a great variety of ways. However if all you
need is a little SQL here (ie if you're using less than 10% of what it does)
then the verbosity does clearly become an overhead. I personally do use it
for simplistic SQL queries, including updates that don't influence the
output, but only when I'm already using it for larger operations within the
same site (by larger I mean that have to generate XML records).
> So, we tried to set up Apache so that files will be processed
> with Template Toolkit first, and the result will be an XML
> to be processed by AxKit. But that didn't work,
> with the following error message in log:
> --------
> Can't locate object method "filter_register" via package "Apache" at
> /usr/local/lib/site_perl/Apache/RegistryFilter.pm line 13. --------
>
> How can I configure Apache so that Template output
> will be processed by AxKit?
I'm not sure, I never tried this. However if you're looking for performance I
wouldn't do that. Piping two independent modperl toolkits into one another is
likely to give you serious performance hits. I'd recommend either finding
your solution on the TT side, or switching completely to AxKit. Using both is
a bit weird. Note that there are other ways than XSP to generate dynamic data
in AxKit, I only mentionned it because it is the one I use (for the big
advantage that it is XML throughout).
> We have also heard something about OpenInteract, which is based on
> Template Toolkit - may be it would be simplier to use it?
This depends on where exactly your problem(s) lies.
--
_______________________________________________________________________
Robin Berjon <[EMAIL PROTECTED]> -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
-----------------------------------------------------------------------
An eye for an eye will make the whole world blind. -- Mahatma Gandhi