[Dancer-users] Problem with using the prefix feature to split the application

P Kishor punk.kish at gmail.com
Sat Oct 2 20:28:46 CEST 2010


Thanks for the quick reply.

On Sat, Oct 2, 2010 at 1:26 PM, franck <franck at lumberjaph.net> wrote:
> Hi
>
>> I was using the following idiom, and everything was working fine
>>
>>    ----
>>    package app;
>>    use Dancer ':syntax';
>>    use Dancer::Plugin::Ajax;
>>
>>    load_app "app::app1", prefix => "/app1";
>>    load_app "app::app2", prefix => "/app2";
>>
>>    ..
>>
>>    true;
>>    ----
>>
>>    package app::app1;
>>    use Dancer ':syntax';
>>
>>    ..
>>
>>    true;
>>    ----
>>
>>    package app::app2;
>>    use Dancer ':syntax';
>>
>>    ..
>>
>>    true;
>>    ----
>>
>> The above was a holdover from earlier versions of Dancer, but, as I
>> noted above, it was working fine. Today I noticed that the
>> Dancer::Cookbook has a different suggestion, so I implemented that and
>> ran into a problem. My new implementation is
>>
>>    ----
>>    package app;
>>    use Dancer ':syntax';
>>    use Dancer::Plugin::Ajax;
>>
>>    use app::app1;
>>    use app::app2;
>>
>>    prefix undef;
>>
>>    ..
>>
>>    true;
>>    ----
>>
>>    package app::app1;
>>    use Dancer ':syntax';
>>    prefix 'app1';
>>    ..
>>
>>    true;
>>    ----
>>
>>    package app::app2;
>>    use Dancer ':syntax';
>>    prefix 'app2';
>>    ..
>>
>>    true;
>>    ----
>>
>> I get the following error
>>
>>  Error while loading /Users/punkish/Sites/app/app.pl: unable to load
>> application app : not a valid prefix: `app', must start with a / at
>> /usr/local/lib/perl5/site_perl/5.12.1/Dancer/App.pm line 32., referer:
>> http://app.local/app1/
>>
>> What gives?
>>
> a prefix must start with '/', if the '/' is missing in the cookbook, it's an
> error, and that will be fixed right away.


Yes, it is missing in the cookbook.

> However, I prefer your first solution :)  (load_app "app::app1", prefix =>
> "/app1";)

Hmmm.... then shouldn't the cookbook show the preferred solution -- I
am assuming you know way more than I do about Dancer, and if you
prefer a particular solution, that *should* be the preferred solution,
no? ;-)


-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the Dancer-users mailing list