From: Wil C. <wc...@na...> - 2002-10-25 23:50:56
|
I've noticed that although the docs say When your functions are called, they will be in the context of your module. This means that your useradmin_update.pl script can require the file of common functions used by other CGI programs. The functions can perform any action you like in order to update other config files or whatever, but should not generate any output on STDOUT, or take too long to execute.=20 =20 that having require "../web-lib.pl" ; &init_config() ; at the top of the script DID NOT actually pull in my module's configuration information. At least, it wasn't available within my useradmin_*_user subroutines. My subroutines actually test for automatic creation being enabled before running, so I noticed right away they weren't actually running. I did a hash dump to verify and the keys in %::config seem to actually be the configured keys from 'useradmin'. I found I was able to get my module's %::config if is put the 'require' and 'init_config' at the beginning of my subroutines. However, I fear I might be causing untoward side-effects, because after doing this, the "Return to" link at the bottom of the user add and delete response pages actually points to my module, not the useradmin module!=20 This is with 0.98 installed; I don't see anything mentioned in the change log about this. Wil --=20 Wil Cooley wc...@na... Naked Ape Consulting http://nakedape.cc * * * * Linux, UNIX, Networking and Security Solutions * * * * QCSNet http://www.qcsn.com * * * * T1, Frame Relay, DSL, Dial-up, and Web Hosting * * * * |
From: Jamie C. <jca...@we...> - 2002-10-26 00:28:44
|
Wil Cooley wrote: > I've noticed that although the docs say > > When your functions are called, they will be in the context of your > module. This means that your useradmin_update.pl script can > require the file of common functions used by other CGI programs. The > functions can perform any action you like in order to update other > config files or whatever, but should not generate any output on > STDOUT, or take too long to execute. > > that having > > require "../web-lib.pl" ; > &init_config() ; > > at the top of the script DID NOT actually pull in my module's > configuration information. At least, it wasn't available within my > useradmin_*_user subroutines. My subroutines actually test for > automatic creation being enabled before running, so I noticed right away > they weren't actually running. I did a hash dump to verify and the keys > in %::config seem to actually be the configured keys from 'useradmin'. > > I found I was able to get my module's %::config if is put the 'require' > and 'init_config' at the beginning of my subroutines. However, I fear I > might be causing untoward side-effects, because after doing this, the > "Return to" link at the bottom of the user add and delete response pages > actually points to my module, not the useradmin module! > > This is with 0.98 installed; I don't see anything mentioned in the > change log about this. What I usually have in my useradmin_update.pl script is a line at the top like : do 'mymodule-lib.pl'; and in mymodule-lib.pl, lines like : do '../web-lib.pl'; &init_config(); This sets %config just fine for me. require shouldn't be used in this case, because Perl will not actually re-read web-lib.pl if it thinks that it has been require'd before! - Jamie |
From: Wil C. <wc...@na...> - 2002-10-26 02:45:47
|
On Fri, 2002-10-25 at 17:28, Jamie Cameron wrote: > What I usually have in my useradmin_update.pl script is a line at the top= like : >=20 > do 'mymodule-lib.pl'; >=20 > and in mymodule-lib.pl, lines like : >=20 > do '../web-lib.pl'; > &init_config(); >=20 > This sets %config just fine for me. require shouldn't be used in this cas= e, because > Perl will not actually re-read web-lib.pl if it thinks that it has been r= equire'd before! Should I infer then that I should be able to use "do" instead of 'require' in my useradmin_update.pl and have it work, or is there some Perl black magic I'm missing that makes chained "do"'s somehow different? Wil --=20 Wil Cooley wc...@na... Naked Ape Consulting http://nakedape.cc * * * * Linux, UNIX, Networking and Security Solutions * * * * QCSNet http://www.qcsn.com * * * * T1, Frame Relay, DSL, Dial-up, and Web Hosting * * * * |
From: Jamie C. <jca...@we...> - 2002-10-26 04:56:58
|
Wil Cooley wrote: > On Fri, 2002-10-25 at 17:28, Jamie Cameron wrote: > > > >>What I usually have in my useradmin_update.pl script is a line at the top like : >> >>do 'mymodule-lib.pl'; >> >>and in mymodule-lib.pl, lines like : >> >>do '../web-lib.pl'; >>&init_config(); >> >>This sets %config just fine for me. require shouldn't be used in this case, because >>Perl will not actually re-read web-lib.pl if it thinks that it has been require'd before! > > > Should I infer then that I should be able to use "do" instead of > 'require' in my useradmin_update.pl and have it work, or is there some > Perl black magic I'm missing that makes chained "do"'s somehow > different? No black magic .. you should be able to use do '../web-lib.pl'; &init_config(); in your useradmin_update.pl script with no problems. - Jamie |