[Catalyst] generic db table list

Zbigniew Lukasiak zzbbyy at gmail.com
Fri Jun 2 09:29:09 CEST 2006


Hi,

The auto action is called before any other action from that controller
- so the $c->stash->{columns} just stays there and is always available
in the View.

'perldoc Catalyst' says:
...
 # called for all actions, from the top-most controller downwards
sub auto : Private {
...
-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/

On 6/2/06, Fernan Aguero <fernan at iib.unsam.edu.ar> wrote:
> Or ... learning TT along the way.
>
> What I want to do: have a generic 'list' action that lists
> the contents of a database table. I'm planning to use this
> with more complex queries (not just one table per page) but
> right now I'm starting with functionality similar to that
> provided by InstantCRUD to learn along the way.
>
> Basically I want to end up with an action and an associated
> view that for any resultset, will do something like
>
> <table>
> [% FOREACH row in rs.next() %]
> <tr>
> [% FOREACH column in row %]
> <td>[% column.value %]</td>
> [% END %]
> </tr>
> [% END %]
> </table>
>
> Right now, for one particular table, I'm doing this:
> [% FOREACH row in rs.next() %]
> <tr>
> <td>[% row.user_id %]</td>
> <td>[% row.username %]</td>
> ...
> ...
>
> and it works, but this is just because I'm using the column
> names for this particular case ... or saying it another way,
> I've not found a way for looping through all the keys of a
> hash in TT, like you can do with raw perl:
> foreach $key ( keys(%hash) )
>
> All the examples in the Template Toolkit pods always use the
> exact names of the keys for accessing values ... and I find
> it difficult to follow the InstantCRUD example as the 'list'
> action (InstantCRUD.pm, line 211) does not define any
> 'columns' in the stash, but they are used in the associated
> 'list.tt' template (where does this array come from?)
>
> For those familiar with InstantCRUD, there are some column
> names begin pushed into the stash in another action (auto)
> ... but I cannot see how they're connected.
>
> Thanks in advance for any help, suggestion or clarification,
>
> Fernan
>
>
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>



More information about the Catalyst mailing list