RT.pm LoadConfig sub ... is this a logic error?

Hi folks,

kind of new with RT. I copied RT_Config.pm to RT_SiteConfig.pm and then I
had made a change to my RT_SiteConfig.pm. I changed

Set($LogToSyslog , ‘debug’);
Set($LogToFile , undef);

to

Set($LogToSyslog , undef);
Set($LogToFile , ‘debug’);

[Don’t ask why :wink: ]

When I did not see the effect of the change I did a trace of the code
dealing with it.

I believe there maybe a “logic” error in the “LoadConfig” sub [see code
snippet below]. As the comments say, first load the “core config” and
then the site. But the actual code loads the site first and then the
core. To me that would reset values to the “core” default (due to the
"undef" value in the “Set”.

I would have done it differently [unless I am misunderstanding something]
– remove the “unless defined $_[0]” clause in the “Set” sub, and move the
"if (…)" clause after the “require $CORE_CONFIG_FILE …” statement.

For your amusement,

Lidio Presutti
Manager of Help Desk and LAN & Workstation Technology Services
Information Commons Phone: (416) 978-5130
University of Toronto Fax: (416) 978-0440

in RT.pm

=head2 LoadConfig

Load RT’s config file. First, go after the core config file.
After that, go after the site config.

=cut

sub LoadConfig {
local *Set = sub { $[0] = $[1] unless defined $_[0] };
if ( -f “$SITE_CONFIG_FILE” ) {
require $SITE_CONFIG_FILE
|| die (“Couldn’t load RT config file ‘$SITE_CONFIG_FILE’\n$@”);
}
require $CORE_CONFIG_FILE
|| die (“Couldn’t load RT config file ‘$CORE_CONFIG_FILE’\n$@”);
RT::I18N->Init;
}

I had all kinds of wierd errors/messages until I touched the logfile.
Have you done that?

What that code does, I think, is load the SiteConfig to get the values
set there, then the Config file to get the rest. I usually only
populate SiteConfig with the values I want to change from the defaults.

Lidio Presutti wrote:

Hi folks,

kind of new with RT. I copied RT_Config.pm to RT_SiteConfig.pm and then I
had made a change to my RT_SiteConfig.pm. I changed

Set($LogToSyslog , ‘debug’);
Set($LogToFile , undef);

to

Set($LogToSyslog , undef);
Set($LogToFile , ‘debug’);

[Don’t ask why :wink: ]

When I did not see the effect of the change I did a trace of the code
dealing with it.

I believe there maybe a “logic” error in the “LoadConfig” sub [see code
snippet below]. As the comments say, first load the “core config” and
then the site. But the actual code loads the site first and then the
core. To me that would reset values to the “core” default (due to the
"undef" value in the “Set”.

I would have done it differently [unless I am misunderstanding something]
– remove the “unless defined $_[0]” clause in the “Set” sub, and move the
"if (…)" clause after the “require $CORE_CONFIG_FILE …” statement.

For your amusement,

Lidio Presutti
Manager of Help Desk and LAN & Workstation Technology Services
Information Commons Phone: (416) 978-5130
University of Toronto Fax: (416) 978-0440


in RT.pm

=head2 LoadConfig

Load RT’s config file. First, go after the core config file.
After that, go after the site config.

=cut

sub LoadConfig {
local *Set = sub { $[0] = $[1] unless defined $_[0] };
if ( -f “$SITE_CONFIG_FILE” ) {
require $SITE_CONFIG_FILE
|| die (“Couldn’t load RT config file ‘$SITE_CONFIG_FILE’\n$@”);
}
require $CORE_CONFIG_FILE
|| die (“Couldn’t load RT config file ‘$CORE_CONFIG_FILE’\n$@”);
RT::I18N->Init;
}


Rt-devel mailing list
Rt-devel@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel

Drew Barnes
Applications Analyst
Raymond Walters College
University of Cincinnati

At Thursday 4/21/2005 03:33 PM, Lidio Presutti wrote:

Hi folks,

kind of new with RT. I copied RT_Config.pm to RT_SiteConfig.pm and then I
had made a change to my RT_SiteConfig.pm. I changed

Set($LogToSyslog , ‘debug’);
Set($LogToFile , undef);

to

Set($LogToSyslog , undef);
Set($LogToFile , ‘debug’);

Lidio,

You need to explicitly set variables to 0 if you want to override the
RT_Config value with a “false” or “off” setting. Setting a variable to
undef in RT_SiteConfig won’t do what you want.

Steve

Hi Stephen,

you are quite right, that is the correct way to achive what I wanted!
[It was my silly “gotcha” Perl coding :frowning: ]

Thanks,

Lidio.On Thu, 21 Apr 2005, Stephen Turner wrote:

At Thursday 4/21/2005 03:33 PM, Lidio Presutti wrote:

Hi folks,

kind of new with RT. I copied RT_Config.pm to RT_SiteConfig.pm and then I
had made a change to my RT_SiteConfig.pm. I changed

Set($LogToSyslog , ‘debug’);
Set($LogToFile , undef);

to

Set($LogToSyslog , undef);
Set($LogToFile , ‘debug’);

Lidio,

You need to explicitly set variables to 0 if you want to override the
RT_Config value with a “false” or “off” setting. Setting a variable to
undef in RT_SiteConfig won’t do what you want.

Steve