[Dancer-users] How to use dancer functions in other modules

Brian E. Lozier brian at massassi.com
Tue Mar 8 03:40:50 CET 2011


I have some modules for form generation and processing that aren't
Dancer classes (in that they don't contain any routes).  Inside these
I'd like to use some of the dancer functions like "params."  When I
"use Dancer" at the top of one of these modules I am getting a really
odd error message.

runtime error

Operation "eq": no method found,
	left argument in overloaded package Fan::Form::Register,
	right argument has no overloaded magic at
/usr/local/lib/perl5/site_perl/5.12.3/Dancer/Request.pm line 177.

/usr/local/lib/perl5/site_perl/5.12.3/Dancer/Request.pm around line 177

174     return %{$self->{params}} if wantarray && @_ == 1;
175     return $self->{params} if @_ == 1;
176
177     if ($source eq 'query') {
178         return %{$self->{_query_params}} if wantarray;
179         return $self->{_query_params};
180     }

In my main Dancer class, Fan::Web, I have a route sub that says:

my $params = params();

I then pass this hashref into my form module like this:

   my $form = Fan::Form::Register->new($params);

If I don't "use Dancer" in the form module, all works well.  If I "use
Dancer;" in the form module I get the error message.  I am trying to
use Dancer so I can use the debug/warning functions.  I don't
understand the error message.  I have an overloaded "" operator in the
form class (to return an HTML representation of the form) but I don't
know how calling the params() function in my main Dancer routes class
(Fan::Web) and then passing the hashref into my form class can cause
an error like this.  Any thoughts?

Thanks,
Brian


More information about the Dancer-users mailing list