From: Davide P.C. <dp...@un...> - 2005-05-04 01:23:59
|
Folks: On the discussion board at http://webhost.math.rochester.edu/webworkdocs/discuss/msgReader$3244? mode=topic&y=2005&m=4&d=22 a user asks how to add directories that can be searched for macro files by loadMacros(). The current implementation doesn't provide for this, but it would not be hard to do. One possibility would be to add a variable to global.conf that is an array of directories to be searched (in the order given). In dangerousMacros around line 260, you would repalce the explicit check of $macroDirectory and $courseScriptsDirectory by a loop through the macro directory array. (The macroDirectory and courseScriptsDirectory variables can then be dropped.) I would also like to suggest that loadMacros be able to access subdirectories of the macro directory (not by searching them automatically, but by making explicit references to them). For example, there are several macro files that defined various Parser contents, and it would be nice to have a "context" subdirectory of the macros directory and then use loadMacros("context/LimitedVector.pl"); The curernt loadMacros() will actually do this, but the _init() routine stuff won't work for this. This can be fixed with a single line in dangerousMacros. At around line 205, right after my $init_subroutine_name = "_${macro_file_name}_init"; you should add $init_subroutine_name =~ s/[^a-z0-9_]/_/gi; to convert any '/' to a '_' in the name. (This also converts any other special characters to underscores, so that in case the file name contains characters that are not legal in a perl subroutine name, they will not cause problems with the _init() routine. This would be a good thing to do even if you don't like the sub-directory idea.) What do you think? Davide |