On Mar 8, 2011, at 2:17 AM, franck wrote:
Hi
On Tue, Mar 8, 2011 at 7:40 AM, Flavio Poletti <polettix@gmail.com> wrote: Hi,
first of all you should import with the ":syntax" import option to avoid some collateral effects that should happen only in the main module:
use Dancer ':syntax';
Second, looking at the code the import mechanism is quite bare-bones and does not allow you to perform selective import. Considering that you have control upon the module that needs Dancer, do you think that you can rename your "sub params" in some other way? I think it should be better for you too - having two "params" requires a switch of mental context at each edit file change.
Cheers,
I'm in the process of merging an awesome patch by ironcamel / sawyer / schwern where you will be able to exclude some keywords, and importing groups of keyword (like Dancer ':moose', which will exclude before and after)
This will be available in our next release (probably this week).
franck, please note that 'get' and 'set' conflict with the similarly named methods in PDL [http://pdl.perl.org]. There might be other conflicts as well. This has been causing me quite some grief for a while now.
Flavio.
On Tue, Mar 8, 2011 at 3:43 AM, Brian E. Lozier <brian@massassi.com> wrote: Well I think I hit "send" too soon. The problem is that I have a "params" METHOD already defined in this form class. When I import Dancer it seems to override that method. Is there a way to only import the logging functions and not all the Dancer functions?
Thanks!
On Mon, Mar 7, 2011 at 6:40 PM, Brian E. Lozier <brian@massassi.com> wrote:
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 ..