RE: PerlAddVar bug

2000-09-26 Thread Doug MacEachern

On Thu, 6 Jul 2000, Geoffrey Young wrote:
 
 I guess my expectation is that $r-dir_config('MyVar') and
 $r-dir_config-get('MyVar') should inherit equally, which as far as I can
 tell, they don't.  PerlSetVar or PerlAddVar - it makes no difference.

the problem is related to the Apache::Server-dir_config support.  in the
directive handler, if path was NULL, the var was set/add-ed only to the
server_rec-module_config.  $r-dir_config falls back to the
server_rec-module_config  if the var is not found in
request_rec-per_dir_config, but $r-dir_config-get does not.  the patch
below fixes the problem, works just as PerlSetEnv does.  the key/val is
always added to the per-dir table, and also added to the per-server table
is path == NULL, for use at startup time.

p.s.
i also just committed a change so PerlAddVar is now an ITERATE2 rather
than TAKE 2, so you can say:

PerlAddVar Key val-one val-two val-three

Index: src/modules/perl/perl_config.c
===
RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.102
diff -u -r1.102 perl_config.c
--- src/modules/perl/perl_config.c  2000/09/22 18:52:00 1.102
+++ src/modules/perl/perl_config.c  2000/09/26 18:29:51
@@ -717,17 +717,17 @@
 
 CHAR_P perl_cmd_var(cmd_parms *cmd, void *config, char *key, char *val)
 {
+perl_dir_config *rec = (perl_dir_config *)config;
 MP_TRACE_d(fprintf(stderr, "perl_cmd_var: '%s' = '%s'\n", key, val));
-if (cmd-path) {
-perl_dir_config *rec = (perl_dir_config *) config;
-if (cmd-info) {
-table_add(rec-vars, key, val);
-}
-else {
-table_set(rec-vars, key, val);
-}
+
+if (cmd-info) {
+table_add(rec-vars, key, val);
 }
 else {
+table_set(rec-vars, key, val);
+}
+
+if (cmd-path == NULL) {
 dPSRV(cmd-server);
 if (cmd-info) {
 table_add(cls-vars, key, val);




RE: PerlAddVar bug

2000-09-26 Thread Geoffrey Young



 -Original Message-
 From: Doug MacEachern [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, September 26, 2000 2:35 PM
 To: Geoffrey Young
 Cc: 'Eric Cholet'; Matt Sergeant; [EMAIL PROTECTED]
 Subject: RE: PerlAddVar bug
 
 
 On Thu, 6 Jul 2000, Geoffrey Young wrote:
  
  I guess my expectation is that $r-dir_config('MyVar') and
  $r-dir_config-get('MyVar') should inherit equally, which 
 as far as I can
  tell, they don't.  PerlSetVar or PerlAddVar - it makes no 
 difference.
 
 the problem is related to the Apache::Server-dir_config 
 support.  in the
 directive handler, if path was NULL, the var was set/add-ed 
 only to the
 server_rec-module_config.  $r-dir_config falls back to the
 server_rec-module_config  if the var is not found in
 request_rec-per_dir_config, but $r-dir_config-get does 
 not.  the patch
 below fixes the problem, works just as PerlSetEnv does.  the 
 key/val is
 always added to the per-dir table, and also added to the 
 per-server table
 is path == NULL, for use at startup time.

groovy - the patch seems to work just fine (you've been busy, it seems :)

 
 p.s.
 i also just committed a change so PerlAddVar is now an ITERATE2 rather
 than TAKE 2, so you can say:
 
 PerlAddVar Key val-one val-two val-three

that works ok too.

Any particular reason for keeping PerlSetVar TAKE2?

anyway, thanks again for the efforts

--Geoff

 
 Index: src/modules/perl/perl_config.c
 ===
 RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
 retrieving revision 1.102
 diff -u -r1.102 perl_config.c
 --- src/modules/perl/perl_config.c2000/09/22 18:52:00 1.102
 +++ src/modules/perl/perl_config.c2000/09/26 18:29:51
 @@ -717,17 +717,17 @@
  
  CHAR_P perl_cmd_var(cmd_parms *cmd, void *config, char *key, 
 char *val)
  {
 +perl_dir_config *rec = (perl_dir_config *)config;
  MP_TRACE_d(fprintf(stderr, "perl_cmd_var: '%s' = 
 '%s'\n", key, val));
 -if (cmd-path) {
 -perl_dir_config *rec = (perl_dir_config *) config;
 -if (cmd-info) {
 -table_add(rec-vars, key, val);
 -}
 -else {
 -table_set(rec-vars, key, val);
 -}
 +
 +if (cmd-info) {
 +table_add(rec-vars, key, val);
  }
  else {
 +table_set(rec-vars, key, val);
 +}
 +
 +if (cmd-path == NULL) {
  dPSRV(cmd-server);
  if (cmd-info) {
  table_add(cls-vars, key, val);
 



RE: PerlAddVar bug

2000-09-26 Thread Doug MacEachern

On Tue, 26 Sep 2000, Geoffrey Young wrote:
 
 groovy - the patch seems to work just fine (you've been busy, it seems :)

cool!

  p.s.
  i also just committed a change so PerlAddVar is now an ITERATE2 rather
  than TAKE 2, so you can say:
  
  PerlAddVar Key val-one val-two val-three
 
 that works ok too.
 
 Any particular reason for keeping PerlSetVar TAKE2?

not that i can think of, it should have been ITERATE2 the first time
around.




Re: PerlAddVar bug

2000-07-06 Thread Matt Sergeant

On Thu, 6 Jul 2000, Geoffrey Young wrote:

 Sorry to bring up PerlAddVar again, but this time I have a legitimate bug.
 It stems from what I reported last time about items in Apache::Table not
 being visible outside a Location directives:

See the section on DIR_MERGE in the Eagle book. It just needs someone to
write that code for PerlAddVar/PerlSetVar.

-- 
Matt/

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org




Re: PerlAddVar bug

2000-07-06 Thread Eric Cholet

 On Thu, 6 Jul 2000, Geoffrey Young wrote:
 
  Sorry to bring up PerlAddVar again, but this time I have a legitimate bug.
  It stems from what I reported last time about items in Apache::Table not
  being visible outside a Location directives:
 
 See the section on DIR_MERGE in the Eagle book. It just needs someone to
 write that code for PerlAddVar/PerlSetVar.
 

But there is dir_merge code for those variables, this works for me:

PerlSetVar MyVar foo

Location /test/
  PerlSetVar MyVar bar
  SetHandler "perl-script"
  PerlHandler Apache::Registry
  Options +ExecCGI
/Location

test/foo:
  my $r = shift;
  $r-send_http_header('text/plain');
  print $r-dir_config('MyVar');

% GET http://localhost/test/foo
bar


I don't know about PerlAddVar, haven't tested Geoff's examples yet,
but it should work as well since those vars all end up in 
perl_dir_config-vars

--
Eric





RE: PerlAddVar bug

2000-07-06 Thread Geoffrey Young



 -Original Message-
 From: Eric Cholet [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 06, 2000 1:47 PM
 To: Matt Sergeant; Geoffrey Young
 Cc: [EMAIL PROTECTED]
 Subject: Re: PerlAddVar bug
 
 
  On Thu, 6 Jul 2000, Geoffrey Young wrote:
  
   Sorry to bring up PerlAddVar again, but this time I have 
 a legitimate bug.
   It stems from what I reported last time about items in 
 Apache::Table not
   being visible outside a Location directives:
  
  See the section on DIR_MERGE in the Eagle book. It just 
 needs someone to
  write that code for PerlAddVar/PerlSetVar.
  
 
 But there is dir_merge code for those variables, this works for me:
 
 PerlSetVar MyVar foo
 
 Location /test/
   PerlSetVar MyVar bar
   SetHandler "perl-script"
   PerlHandler Apache::Registry
   Options +ExecCGI
 /Location
 
 test/foo:
   my $r = shift;
   $r-send_http_header('text/plain');
   print $r-dir_config('MyVar');
 
 % GET http://localhost/test/foo
 bar
 
 
 I don't know about PerlAddVar, haven't tested Geoff's examples yet,
 but it should work as well since those vars all end up in 
 perl_dir_config-vars

I guess my expectation is that $r-dir_config('MyVar') and
$r-dir_config-get('MyVar') should inherit equally, which as far as I can
tell, they don't.  PerlSetVar or PerlAddVar - it makes no difference.

if you change your test case to:

PerlSetVar MyVar foo
Location /test/
#  PerlSetVar MyVar bar
  SetHandler "perl-script"
  PerlHandler Apache::Registry
  Options +ExecCGI
/Location

test/foo:
  my $r = shift;
  $r-send_http_header('text/plain');
  print "1: " . $r-dir_config('MyVar');
  print "\n2: " . $r-dir_config-get('MyVar');

% GET http://localhost/test/foo
1: foo
2: 

I think you'll see it...

--Geoff


 
 --
 Eric