From: Bodo S. <bo...@le...> - 2005-12-19 10:01:09
|
Hi all, a couple of weeks ago, Jesse provided a patch for bin/krang_create_list to make it work with the new addon system. Using it showed some constraint I didn't expect: The name of the elementlib and the name of the addon must be identical. I feel this is an unnecessairy constraint that does not allow to have multiple elementsets in one addon. Why shouldn't we just use the standard interface of Krang::File to find the elementlib directory. So instead of: my $addon = InstanceElementSet; # Are we in the new /krang/addons/ directory, or legacy /krang/element_lib/? my $element_lib_dir = catdir(KrangRoot, 'addons', $addon, 'element_lib', $addon); $element_lib_dir = catdir(KrangRoot, 'element_lib', $addon) unless (-d $element_lib_dir); I'd propose my $elementset = InstanceElementSet; my $element_lib_dir = pkg('File')->find(catdir('element_lib', $elementset)); Krang::File's find() method finds "element_lib/$elementset" in the addon with the highest priority and if none is found looks for it in /KrangRoot/element_lib/. So, here's the patch I'd like to commit. Warmest regards, Bodo <patch> Index: krang_create_lists =================================================================== RCS file: /home/bobesch/var/lib/cvs/my_krang/bin/krang_create_lists,v retrieving revision 1.1.1.2 diff -w -u -r1.1.1.2 krang_create_lists --- krang_create_lists 17 Dec 2005 15:07:04 -0000 1.1.1.2 +++ krang_create_lists 19 Dec 2005 10:04:59 -0000 @@ -77,6 +77,7 @@ use Krang::ClassLoader 'ListGroup'; use Krang::ClassLoader 'List'; use Krang::ClassLoader 'ListItem'; +use Krang::ClassLoader 'File'; use XML::Simple; # For script commands @@ -95,12 +96,9 @@ # Find path to element library for InstanceElementSet -my $addon = InstanceElementSet; - -# Are we in the new /krang/addons/ directory, or legacy /krang/element_lib/? -my $element_lib_dir = catdir(KrangRoot, 'addons', $addon, 'element_lib', $addon); -$element_lib_dir = catdir(KrangRoot, 'element_lib', $addon) unless (-d $element_lib_dir); -die("Can't find element_lib/$addon/ in krang/addons/ or krang/element_lib/") unless (-d $element_lib_dir); +my $elementset = InstanceElementSet; +my $element_lib_dir = pkg('File')->find(catdir('element_lib', $elementset)); +die("Can't find element_lib/$elementset/ in krang/addons/ or krang/element_lib/") unless (-d $element_lib_dir); # Location of our file, if we have one. my $list_conf_file = catfile($element_lib_dir, 'lists.conf'); </patch> |