[Dancer-users] creating an abstract class and then basing other classes on that
P Kishor
punk.kish at gmail.com
Wed Aug 25 16:11:51 CEST 2010
I upgraded to 1.1808, to benefit from the new work done by the
developers, and also to try out the new, multi-folder pattern
suggested by Sukria. So, now I have
appdir/
yourapp.pl
lib/
yourapp.pm
yourapp/
function1.pm
function2.pm
views/
function1/
function2/
in yourapp.pm, you mount your subapps like that
package yourapp;
use Dancer ':syntax';
load_app 'yourapp::function1', prefix => '/function1';
load_app 'yourapp::function2', prefix => '/function2';
...
and in your subapps:
package yourapp::function1;
use Dancer ':syntax';
get '/' => sub { "
template '/function1/index';
};
So, first, in my subapps, I have to specify the full relative path to
the views as shown above. That works. But, now I want to create
modules for the subapps as well. This would be in the spirit of how
there is Dancer::Session::Abstract, and then, there are the real
Dancer::Session::YAML and Dancer::Session::Simple, etc. My reason is
thus -- take either function1 or function2, and provide the ability to
query data with the same call, but from different data stores based on
a config setting. So, the user calls `data()` but if the config
setting is 'db' then get the data from a database, or if the config
setting is 'file' then get the data from a file. So, now I have
appdir/
yourapp.pl
lib/
yourapp.pm
yourapp/
function1.pm
function1/
data.pm
file.pm
function2.pm
function2/
data.pm
file.pm
But, I can't figure out what is the path to my modules? For example,
in function1.pm, should I say `use function1::data` or `use
yourapp::function1::data`?
--
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