[dancer-users] Trouble with DBIC in Plugins
Andrew Beverley
andy at andybev.com
Tue Apr 28 08:51:55 BST 2015
On Mon, 2015-04-27 at 22:26 +1000, Matthew Mallard wrote:
> 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.
Firstly, there is change going on in the world of plugins, which I
suspect will fix this, but I haven't read up on the full details myself:
http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/004512.html
> 3 questions:
> * why does it complain about "Plugin calls 'dsl' instead of
> '$dsl->dsl’" when I appear to be using '$dsl->dsl’?
Are you using an old version of the DBIC plugin? I think that is fixed
in the most recent version.
> * 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?
This is a bit more tricky. With the current plugin architecture,
"schema" is not available in the DSL when you call it from another
plugin as you are doing. You can workaround this by capturing it during
plugin initialisation, as long as you load the DBIC plugin before yours.
See Plugin::Auth::Extensible::Provider::DBIC for an example:
https://github.com/ctrlo/Dancer2-Plugin-Auth-Extensible-Provider-DBIC/blob/master/lib/Dancer2/Plugin/Auth/Extensible/Provider/DBIC.pm#L171
Andy
More information about the dancer-users
mailing list