[dancer-users] Trouble with DBIC in Plugins

Matthew Mallard matt at Q-Technologies.com.au
Mon Apr 27 13:26:26 BST 2015


Hi,

I’m getting a bit confused with plugins.  I’m sure that I was able to use the DBIC Plugin at one point from one of my plugins, but I can’t seem to get it to  work in 0.159002 or 0.160000.  DBIC seems to be okay outside of plugins.

3 questions:
* why does it complain about "Plugin calls 'dsl' instead of '$dsl->dsl’" when I appear to be using '$dsl->dsl’?
* how do I get DBIC to print the SQL it’s executing so I can double check it’s what I’m expecting?
* am I doing something else wrong in the way I’m trying to use DBIC?

Basically this is the code in my plugin:

register get_topics => sub {
    my $dsl = shift;
    my $type = shift;
    my $application = shift;
    my $pageid = shift;
    my $dberr = 0;

    my $current;
    my $urlref;
    my $template = "";
    my $id;
    
    my @topics;
    $dsl->debug( "**** Here 1 ****");
    eval { @topics = $dsl->schema->resultset('ContentType')->search({ application => $application }, { prefetch => [ 'content_type_names' ], order_by => 'sort_order' }) };
    $dberr += $dsl->check_db_result( $dsl, $@, __LINE__ );
    $dsl->debug( "**** Here 2 **** " . @topics);

 etc, etc
}

The output in the console is this:

[Routes:37674] core @2015-04-27 21:57:16> Entering hook core.app.before_request in (eval 87) l. 1
[Routes:37674] debug @2015-04-27 21:57:16> **** Here 1 **** in /code/Dancer/MediBase/bin/../lib/QTechLib/Plugin.pm l. 31
DEPRECATED: QTechLib::Plugin calls 'dsl' instead of '$dsl->dsl'. at /perf/perl/lib/perl5/Dancer2/Plugin/DBIC.pm line 13.
[Routes:37674] debug @2015-04-27 21:57:16> ######Dancer2::Core::DSL__WITH__Dancer2::Plugin::DBIC__WITH__Dancer2::Plugin::Ajax__WITH__QTechLib::L12N::Plugin__WITH__QTechLib::Plugin=HASH(0x3a05a88)###### at line: in /code/Dancer/MediBase/bin/../lib/QTechLib/Plugin.pm l. 66
[Routes:37674] debug @2015-04-27 21:57:16> **** Here 2 ****  in /code/Dancer/MediBase/bin/../lib/QTechLib/Plugin.pm l. 31

Here 2 should print the number of topics - which should be greater than zero.


with thanks,
Matt




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150427/ecfb0915/attachment.html>


More information about the dancer-users mailing list