Hello all,

(I've sent this message to the Class::DBI mailing list, but I figured out that this question is more related to Template Toolkit plugins.)

I'm working on a web applications framework, which will receive an url like this:

http://.../cgi-bin/gnubis.pl/sample/contact/list_contact
                      ^         ^      ^       ^
                      !         !      !       !
         Framework ---'         !      !       !
          Application ----------'      !       !
           Module ---------------------'       !
            Template --------------------------'

And then, process a template using this code:

    my $TT = Template->new({
                        INCLUDE_PATH => "./apps/$app/templates/",
                         PLUGIN_BASE => "$app"
    });

    $TT->process ("$module/$template.tt2",$param)
            or die $TT->error();


(For instance, $app could be "crm", $module "contacts" and $template "list_contacts".)


My goal, by defining PLUGIN_BASE => "$app", is to allow the creation of Class::DBI plugins, that could be used in this way:

    [%
       USE plugin.contact;
       list_contact = contact.retrieve_all()
    %]

    <table>
    [% FOREACH contact = list_contact %]
      <tr>
        <td>[% contact.id %]</td>
        <td>[% contact.display_name %]</td>
        <td>[% contact.organization %]</td>
      </tr>
    [% END %]
    </table>

My question is: have anybody integrated Class::DBI and Template Toolkit using plugins?

Here's a sample template that isolates the problem:

[% USE Dumper %]

    [%
       USE plugin.contact;
       list_contact = plugin.contact.retrieve_all()
    %]

    <PRE>
    plugin.contact: [% Dumper.dump(plugin.contact) %]
    list_contact: [% Dumper.dump(list_contact) %]
    </PRE>

It returns:

    plugin.contact: $VAR1 = 'simple::plugin::contact';
    list_contact: $VAR1 = '';


The problem seems to be in the plugin module:


package crm::plugin::contact;

    use strict;
    use base qw(crm::plugin);
    use crm::cdbi::contact;

1;

I tried to create a "fake" retrieve_all sub:

package crm::plugin::contact;

    use strict;
    use base qw(crm::plugin);
    #use crm::cdbi::contact;

    sub retrieve_all {
      die 123;
    }

1;

Nothing changes. Any ideas?

The modules are organized like this:

    Class                 Inherits from      Uses
    -------------------   -----------------  -----------------
    crm                   Class::DBI
    crm::contact          crm
    crm::plugin           Template::Plugin
    crm::plugin::contact  crm::plugin        crm::contact

Any input will be appreciated.

Thanks in advance,

--
[]s

Nelson

________________________________________________________________
Nelson Ferraz

GNU BIS: http://www.gnubis.com.br
PhPerl:  http://www.phperl.com




_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to