Re: Help with cookies

2001-08-09 Thread Mark Maunder

If you're chaining handlers, they should all return OK. They will all get
called, so long as they either appear in the config file on the same line, or
have been registered using $r-push_handlers().

One of them must send the header though, or return REDIRECT (for example) to
perform a redirect. Does Apache::Cookie-bake() set both the regular headers and
the error headers?

I usually call the header setting routines manually like so:
$r-header_out(Set-Cookie = $cookie-as_string()); #and also call
$r-err_header_out(Set-Cookie = $cookie-as_string());

If you're returning OK, the server assumes you handled the request. So you
should have sent a response page and would probably have used
$r-send_http_header to generate the header for that page.
If you return REDIRECT, the header is sent for you based on what you set with
$r-err_header_out(). So if you want to be sure that the cookie will be set, you
should set it in both the error headers and the regular headers.

Then depending on whether you're redirecting or just generating a page call:
return REDIRECT;
 Or call
$r-send_http_header('text/html'); #If you're about to send some HTML.

Either way the cookie gets sent. (The err_header_out is for the REDIRECT and the
header_out is for the regular send_http_header). Also remember to set the
Location header if you're doing a redirect. I also use both err_header_out AND
header_out to set this. (I should probably just be using err_header_out for
that).

~mark.




Robert Landrum wrote:

 At 3:50 PM -0400 8/8/01, Perrin Harkins wrote:
 
 It depends on what's happening in that second module.  If you don't send an
 actual response to the client, headers (including cookies) will not be sent
 out.

 Umm... Is

return OK;

 the correct thing to return when using multiple handlers?  I thought
 DECLINED was the correct status code.  Then the last module (in this
 case MIS_APPS::RHS::Control::Scan) would return OK.

 Robert Landrum

 --
 A good magician never reveals his secret; the unbelievable trick
 becomes simple and obvious once it is explained. So too with UNIX.

--
Mark Maunder
Senior Architect
SwiftCamel Software
http://www.swiftcamel.com
mailto:[EMAIL PROTECTED]





Re: using DBI with apache

2001-08-09 Thread Mark Maunder

DBI works under Apache. Apache::DBI just gives you some performance gains like
persistent connections etc. Get the script working with DBI under Apache and
then start messing with Apache::DBI. Your problem is that you need to print
Content-type: text/html\n\n; before you print anything else. (CGI basics).

Greg Cobb wrote:

 I can run this simple script through perl itself, but when I put it in the
 cgi-bin and try to run it using mod_perl Perl pops up in windows with an
 error.  I assume this means I need something like Apache::DBI?...  I
 originally got Apache in binary form with mod_perl installed and did not
 have to compile anything.  I tried to follow the instructions but i dont
 seem to be able to build Apache::DBI
 I ran
 perl makefile.pl which creates a file called makefile
 then the instructions tell you to run
 make
 make test
 make install

 make by run by itself says 'No terminator specified for in-line operator'
 and i dont have a test or install file that came with the Apache:DBI
 download.  I have a test.pl but that doesnt seem to be what i need.  I am
 running Win 98se if that helps.  Anyone have any suggestions?

 Here is the code I tried to run.
 #!\perl\bin\perl
 use DBI;
 $dbh = DBI-connect('dbi:ODBC:Test1Db');
 $sqlstatement=SELECT * FROM ASTAB;
 $sth = $dbh-prepare($sqlstatement);
 $sth-execute ||
die Could not execute SQL statement ... maybe invalid?;

 #output database results
 while (@row=$sth-fetchrow_array)
   { print @row\n }

 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
Mark Maunder
Senior Architect
SwiftCamel Software
http://www.swiftcamel.com
mailto:[EMAIL PROTECTED]





Re: knowledge base - was Re: RFC: mod_perl 2.0 documentation project

2001-08-09 Thread Stas Bekman

On Wed, 8 Aug 2001, Jim Smith wrote:

 On Wed, Aug 08, 2001 at 10:45:43AM +0800, Stas Bekman wrote:
  On Tue, 7 Aug 2001, Jim Smith wrote:
 
   On Tue, Aug 07, 2001 at 10:16:26PM +0800, Stas Bekman wrote:
 Just some pseudo-random ideation boiling down to let's use mod_perl
 to buils a knowledge base both to demonstrate it's power and to serve
 the community.
   
I like the idea!!!
  
   If we can come up with a proposal for a generic knowledge base product that
   would be useful in an IT environment, I can probably devote some of my work
   to it -- this is something I've been wanting to put together at work for
   customers and our help desk people but haven't had time yet to get it all
   together.  I'll have more time in September after the students return.
 
  go ahead and be the first to propose Jim :)

 Ok... here are some of my initial thoughts.

 We need to be able to enter arbitrary documents, so I suggest DocBook
 as the standard format.  This handles articles, books, reference
 pages, etc., in a well-defined manner.  It also allows us to transform
 to other formats without much of a problem.  We can even consider
 AxKit for at least part of the web interface.

 We would want to have different sections for documents that are not
 related.  For example, we (here at TAMU) could use a section on Unix,
 another on Mac, and yet another on Windows systems.  Or we could
 divide it up by services.  The different sections would not expect
 overlap in keyword - content mapping, so we could have an
 AI::Catagorize object for each section that could provide a default
 set of keywords.  As we entered documents, those objects could learn
 which keywords were appropriate.

 We would want to have documents in multiple catagories.  This might
 require the person entering the document enter multiple sets of
 keywords, one per section.

 We would need to index on keyword so people could quickly find the
 documents.  Perhaps even a catelogue-style interface for browsing that
 would be based on keyword categories.  This would require some work.
 (Broad categories are indicated by the presence of certain keywords,
 or by a weighted average so a document having all but a couple of the
 appropriate keywords won't be dropped from that category.)

 Documents shouldn't have to be entered via the web interface, though
 they could be.  We could provide a set of web-page templates for each
 of the DocBook formats (well, the small ones anyway - don't want to
 write a book via a web interface).  Might want to even integrate with
 WebDAV and a repository.

 We probably want to set up a SourceForge project if this is a go.
 Any ideas on names?

This all sounds cool. I have a few concerns with this proposal:

- source documents living under modperl cvs are to be written in POD.
  The project that you suggest should be able to accept this and other
  formats as a source. Afterwards it can convert it to many other formats.
  Matt has already done some work on porting PODs into XML.

- where the actual converted knowledge base will be hosted? I mean who
  will host the production version? It's possible that we can get a
  machine at apache.org, but this is one of the things to worry about. If
  things need to be dynamically generated, we cannot do this from the same
  machine the modperl-site is hosted on (daedalus).

- we need someone to commit to lead the project, or things would never
  take off just like it has happened before.

 Now to see if I can get my boss to support me spending time on such a
 project :)

I hope he does. Really!

_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Reloading handler modules

2001-08-09 Thread willems Luc


hello ,

I'm converting some scripts into Apache handler scripts
in my configuration i have something like

Location /cpbin/xml
 Sethandler perl-script
 PerlHandler Apache::cp
/Location

Every time i change something in the Apache::cp module , i have to restart 
the server to enable the changes.
I know that , moving the script under the Apache::Registry handler will do 
the trick but i wan't to write native apache handlers , not using any CGI 
enviroment.

So , i came a cross to this information at the apache perl site :

---
If you want to reload a perlhandler on each invocation, the following trick 
will do it: 
  

  PerlHandler sub { do 'MyTest.pm'; MyTest::handler(shift) }

do() reloads MyTest.pm on every request. 



but this doesn't seem to work for me (?)

so , is there any other way to get the same effect , this is , reloading the 
module when it has changed instead of restarting the server ?


  luc




RE: Reloading handler modules

2001-08-09 Thread Geoffrey Young



 -Original Message-
 From: willems Luc [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 09, 2001 8:57 AM
 To: [EMAIL PROTECTED]
 Subject: Reloading handler modules
 
 
 
   hello ,
 
 I'm converting some scripts into Apache handler scripts
 in my configuration i have something like
 
 Location /cpbin/xml
  Sethandler perl-script
  PerlHandler Apache::cp
 /Location
 
 Every time i change something in the Apache::cp module , i 
 have to restart 
 the server to enable the changes.

use Apache::Reload...

--Geoff



Re: knowledge base - was Re: RFC: mod_perl 2.0 documentation project

2001-08-09 Thread Jim Smith

On Thu, Aug 09, 2001 at 07:31:11PM +0800, Stas Bekman wrote:
 This all sounds cool. I have a few concerns with this proposal:
 
 - source documents living under modperl cvs are to be written in POD.
   The project that you suggest should be able to accept this and other
   formats as a source. Afterwards it can convert it to many other formats.
   Matt has already done some work on porting PODs into XML.

I don't see this as a problem.  I was just picking a format out of the air
as a starting point.  TMTOWTDI and PCDAA (Perl Can Do Almost Anything).

 - where the actual converted knowledge base will be hosted? I mean who
   will host the production version? It's possible that we can get a 
   machine at apache.org, but this is one of the things to worry about. If 
   things need to be dynamically generated, we cannot do this from the same
   machine the modperl-site is hosted on (daedalus).  

I can't answer that at the moment.
 
 - we need someone to commit to lead the project, or things would never 
   take off just like it has happened before.

Well, I can lead the code development, but I can't commit to anything more
than that at the moment.  I won't be able to do even that until after the
semester starts (classes start 27 Aug, we have several things to get done
before then).

  Now to see if I can get my boss to support me spending time on such a 
  project :) 
 
 I hope he does. Really!

He was very receptive yesterday evening.  Wants to see a proposal (what
TAMU would be committing to) before giving the final go ahead.  We will
probably need to involve our helpdesk people in some of the user-interface
design.  We will need a design document before coding so we know what we're
aiming at.  I can lead on that.

--James



Re: knowledge base - was Re: RFC: mod_perl 2.0 documentation project

2001-08-09 Thread Stas Bekman

On Thu, 9 Aug 2001, Jim Smith wrote:

 On Thu, Aug 09, 2001 at 07:31:11PM +0800, Stas Bekman wrote:
  This all sounds cool. I have a few concerns with this proposal:
 
  - source documents living under modperl cvs are to be written in POD.
The project that you suggest should be able to accept this and other
formats as a source. Afterwards it can convert it to many other formats.
Matt has already done some work on porting PODs into XML.

 I don't see this as a problem.  I was just picking a format out of the air
 as a starting point.  TMTOWTDI and PCDAA (Perl Can Do Almost Anything).

that's cool.

  - where the actual converted knowledge base will be hosted? I mean who
will host the production version? It's possible that we can get a
machine at apache.org, but this is one of the things to worry about. If
things need to be dynamically generated, we cannot do this from the same
machine the modperl-site is hosted on (daedalus).

 I can't answer that at the moment.

We can start worrying about that later, once we get something to show. I
hope ASF can support that and may be use this project for other ASF
projects if something really cool and/or useful will be produced.

  - we need someone to commit to lead the project, or things would never
take off just like it has happened before.

 Well, I can lead the code development, but I can't commit to anything more
 than that at the moment.  I won't be able to do even that until after the
 semester starts (classes start 27 Aug, we have several things to get done
 before then).

Oh, that's absolutely fine. We aren't in hurry at all. We have not many
docs written yet anyway. This is something that we should do in parallel
with the actual docs writing.

   Now to see if I can get my boss to support me spending time on such a
   project :)
 
  I hope he does. Really!

 He was very receptive yesterday evening.  Wants to see a proposal
 (what TAMU would be committing to) before giving the final go ahead.
 We will probably need to involve our helpdesk people in some of the
 user-interface design.  We will need a design document before coding
 so we know what we're aiming at.  I can lead on that.

Fantastic. We can discuss things here. If the discussion becomes to heavy
and getting unrelated to mod_perl list, we can move it elsewhere. e.g.
[EMAIL PROTECTED] or if you host the project on sourceforge, we can
use their list.

_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Compiling with RegistryLoader

2001-08-09 Thread Kostas Lykourgiotis

Hi all,
I try to precompile a perl script on SERVER start-up using the typical
configuration. But I start the server a get a lot of errors or warnings that
refer to standard Perl modules.
On the other hand, if I try to compile the same script on a CHILD process
start-up, using a very similar configuration everything works fine!
The same situation occurred with every other script that I tried to compile.
These scripts are huge and they use MANY Perl modules.

The problem seems to be that there is a difference between the way that a script
is compiled in
parent apache process and in a apache child.

Has anybody faced the same problem, or knows any info that will help to overcome
it ?


Configuration:
Apache 1.3.20 on Linux
Perl 5.6.1 with itheads
mod_perl 1.25

-
The configuration of the first case is described hereafter:
 conf/httpd.conf 
PerlRequire conf/startup.pl
 conf/startup.pl 
use Apache::RegistryLoader;
my $rl = Apache::RegistryLoader-new();
$rl-handler('/Service/top/ig/huge.pl', '/home/dir/www/cgi-bin/huge.pl') ;


When I start the server, messages like this flood the error_log file:

Prototype mismatch: sub Socket::INADDR_ANY vs () at
/opt/irc/ircv2.5/lib/perl5/5.6.1/i686-linux/Socket.pm line 329, DATA line 378.
Prototype mismatch: sub Socket::INADDR_BROADCAST vs () at
/opt/irc/ircv2.5/lib/perl5/5.6.1/i686-linux/Socket.pm line 330, DATA line 378.
.
.
Subroutine TIEHASH redefined at
/opt/irc/ircv2.5/lib/perl5/5.6.1/i686-linux/DB_File.pm line 32, DATA line 378.
Subroutine FETCH redefined at
/opt/irc/ircv2.5/lib/perl5/5.6.1/i686-linux/DB_File.pm line 44, DATA line 378.
.
.
When I try to GET http://my.host/Service/top/ig/huge.pl I get more error
messages.

---
The configuration of the second case (compile on the child startup) :
 conf/httpd.conf 
PerlChildInitHandlerconf::startup
 conf/startup.pm 
package conf::startup
use Apache::RegistryLoader;
sub handler {
  my $rl = Apache::RegistryLoader-new();
  $rl-handler('/Service/top/ig/huge.pl', '/home/dir/www/cgi-bin/huge.pl') ;
}

After start-up the script is executed with the Apache::Registry and everything
works fine!



Thanks in advance,
 Kostas

begin:vcard 
n:Lykourgiotis;Konstantinos
x-mozilla-html:FALSE
adr:;;
version:2.1
email;internet:[EMAIL PROTECTED]
x-mozilla-cpt:;0
fn:Konstantinos Lykourgiotis
end:vcard



Re: Compiling with RegistryLoader

2001-08-09 Thread Perrin Harkins

 I try to precompile a perl script on SERVER start-up using the typical
 configuration. But I start the server a get a lot of errors or warnings
that
 refer to standard Perl modules.

It looks like you're having problem stemming from mod_perl executing the
PerlRequire command twice during startup.  Try upgrading to mod_perl 1.26,
which fixes this bug.
- Perrin




my OR our that is the question ?!

2001-08-09 Thread raptor

hi,

I have the following situation ... it is not big issue but i'm interested
why this happen .. so here is it :

my $ID = 555;
print $ID;

sub blah {
..
 {
local $$dbh{AutoCommit} = 0;
   eval  {
   local $$dbh{RaiseError} = 1;
   $ID =  selectrow query;#say it returns 111

   };
.
 };
 print $ID;

};#end blah

print $ID

So this shortened example prints sometimes :

555
111
111- correct

rarely  :

555
111
555 --- not correct

OK... this seemed to me like uninitialised variable ... or there is special
behaviour when using lexical-var insde eval 
but the problem dissappeared when I declared it like that :

our $ID;


Could someone explain me why this happen.
=
iVAN
[EMAIL PROTECTED]
=





Re: Apache::Upload bug?

2001-08-09 Thread Joe Schaefer

Jeffrey Hartmann [EMAIL PROTECTED] writes:

 After much tracing I found that the problem occurs in the command my
 $fh = $file-fh; where Apache::Upload dup()'s the filehandle and
 passed the duplicate to the perl script.  Then when the program exits
 the perl script still has an open filehandle to that file.  I fixed my
 problem by adding a close $$fh;  to my program which closed the
 duplicate filehandle. 

You have hit the nail on the head; the refcount for $$fh is too high.
I see the problem with apache1.3.19 + modperl 1.25 + perl 5.6.1, 
but I don't know if the same holds for earlier versions.  

It appears that the C code generated by xsubpp is the culprit, but I'm 
not exactly sure about this.

In the meantine, try inserting the following line at the top of the 
CLEANUP: section of ApacheUpload_fh in Request.xs:

  SvREFCNT_dec(SvRV(ST(0))); /* ~ line 523 in Request.xs */

It seems to do the trick for single file uploads.  Please let us
know if this fixes the problem for you.

 Now I'm not sure if this is a bug or if it's supposed to be like that, 
 but the documentation makes it sound like it gives you the actually 
 filehandle of the tempfile, and not a copy.  I just assumed that it 
 would be closed by Apache::Upload when the request was finished.

The duping behavior is desirable, but the filehandle remaining open 
is definitely a bug; and it may have been around for quite a while.

Thanks a bunch for fleshing it out.

-- 
Joe Schaefer




Modules `use`d by PerlModule vanishing after startup?

2001-08-09 Thread Stephen Clouse

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I have recently been working on a framework for moving our applications to 
mod_perl but I've run into a very odd problem.

I load our program's main Apache handler, with:

PerlModule IQGroup::IQCoordinator

And then set it up as a PerlHandler for a virtual host.  But when I attempt to 
load the program, it fails and throws this into the error log:

[Thu Aug  9 14:29:05 2001] [error] Can't locate object method 
GetCurrentRequest via package IQGroup::Core::ApacheRequest (perhaps 
you forgot to load IQGroup::Core::ApacheRequest?) at 
/usr/lib/perl5/5.6.1/IQGroup/IQCoordinator.pm line 60.

Except it IS being loaded, it's the first module `use`d by our PerlHandler.  A 
trace on the Apache process even shows the module being read at startup.

When I insert Apache::Status and take a look at the symbol table, it shows the 
IQGroup::Core::ApacheRequest namespace, but with no symbols in it!  Even more 
odd, the modules that it in turn uses DO show up, all symbols intact.

Now, if I load the handler in the startup file:

use IQGroup::IQCoordinator;

then everything loads properly, although I get a slew of subroutine blah 
redefined messages in the error log when it hits the PerlModule directive.

This doesn't seem like intended behavior (nothing I read suggests it's supposed 
to work like this)...so what's eating my module's symbol table?

- -- 
Stephen Clouse [EMAIL PROTECTED]
Senior Programmer, IQ Coordinator Project Lead
The IQ Group, Inc. http://www.theiqgroup.com/

-BEGIN PGP SIGNATURE-
Version: PGP 6.5.8

iQA/AwUBO3Lr3gOGqGs0PadnEQLHTACgrvUHoQSRdUDYntXkzmnCOapDy5MAn2Ex
HIvS8i793nzDBqowJ/EMf7T9
=0PSY
-END PGP SIGNATURE-



Re: my OR our that is the question ?!

2001-08-09 Thread Andrew Ho

Hello,

rI have the following situation... it is not big issue but
ri'm interested why this happen...
r
rmy $ID = 555;
rsub blah {
r...
r$ID =  selectrow query;
r...
r}

This is, in fact, a big issue. You should see a message in your error log
shared variable $ID will not stay shared. You should not use a my
variable defined at the top level of your Apache::Registry script in a
subroutine. See this entry in the mod_perl guide:

http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S

The workaround is to make $ID a package global (use vars qw($ID)).

Humbly,

Andrew

--
Andrew Ho   http://www.tellme.com/   [EMAIL PROTECTED]
Engineer   [EMAIL PROTECTED]  Voice 650-930-9062
Tellme Networks, Inc.   1-800-555-TELLFax 650-930-9101
--




Re: my OR our that is the question ?!

2001-08-09 Thread Jim Smith

On Thu, Aug 09, 2001 at 01:36:28PM -0700, Andrew Ho wrote:
 Hello,
 
 rI have the following situation... it is not big issue but
 ri'm interested why this happen...
 r
 rmy $ID = 555;
 rsub blah {
 r...
 r$ID =  selectrow query;
 r...
 r}
 
 This is, in fact, a big issue. You should see a message in your error log
 shared variable $ID will not stay shared. You should not use a my
 variable defined at the top level of your Apache::Registry script in a
 subroutine. See this entry in the mod_perl guide:
 
 http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S
 
 The workaround is to make $ID a package global (use vars qw($ID)).

With Perl 5.6, the following are roughly equivalent:

  use vars qw($ID);

  our $ID;

However, you will need to put the `our' declaration within the block (which
may happen implicitely with Apache::Registry).

So (pre-5.6):

  use vars qw($ID);

  sub foo {
  $ID = shift;
  }

But (= 5.6):

  sub foo {
  our $ID = shift;
  }

--James



Apache::Cookie

2001-08-09 Thread Rasoul Hajikhani

I must first thank all of you that helped and apologize to you... I now
know why I was not able to read and write my cookies. The Domain. my
module is now happy to accommodate my request after changing from
http://localhost/...; to the appropriate
http://mymachine.mydomain.com/...;. Thanks to you all for responding
and thank god for the mod_perl archives...
cheers
thanks
-r



Re: my OR our that is the question ?!

2001-08-09 Thread raptor

thanx,
Yes I see ... but I was interested WHY when we are in nested subroutines ...
the inner-one will see the lexical var only the first time !! I mean the
REASON of this perl behaviour ! It it closer/easier to think of it that
my-vars  are visible all the time in their inner scopes (except if u are
going outside the scope of the variable itself) .. what I mean if I'm not
very clear ... it is easy to think that :

{
$var is not visible here

{
 my $var = 5;
   { { sub blah {{ sub xxx{ $var is visible here all the time, not just the
first one } } } } }
}

$var is not visible here
}


On the other hand 'our' and use vars make a global var which as stated
anywhere is not a good programming practice (only in some special cases,
this is not one of them I think :)   / i mean use global where U need
global use local var where u need local/ ).   {note : not local-op }
So I'm using ASP.pm which compiles all scripts into one package (by
default) so the purpose of  lexical-scope splitconquer  is no more
valid... I mean that the variable 'say $ID into script blah.pl I want to be
differnt from the $ID var into xxx.pl i.e. I don't want this :

package AllCompiledScripts;

our $ID;

sub compiled_blah {
  $ID =15;#or if u like our $ID = 15
sub inner_blah{   };
};

sub compiled_xxx {
  $ID =555
sub inner_xxx{   };
};
1;

I want this :

package AllCompiledScrips;

compiled_blah ::  $ID is not visible here
compiled_xxx ::  $ID is not visible here

sub compiled_blah {
  my $ID =15
sub inner_blah{ compiled_blah ::  $ID visible here but compiled_xxx ::
$ID not visible  };
};

sub compiled_xxx {
  my $ID =555
sub inner_xxx{ compiled_xxx ::  $ID visible here  but compiled_blah ::
$ID not visible };
};

compiled_blah ::  $ID is not visible here
compiled_xxx ::  $ID is not visible here

1;


So what is the REASON for this copy-on-first-call behaviour.(there have to
be some reason, if i'm not totaly dull to see it )

Thanx alot for your attention
=
iVAN
[EMAIL PROTECTED]
=


  rI have the following situation... it is not big issue but
  ri'm interested why this happen...
  r
  rmy $ID = 555;
  rsub blah {
  r...
  r$ID =  selectrow query;
  r...
  r}
 
  This is, in fact, a big issue. You should see a message in your error
log
  shared variable $ID will not stay shared. You should not use a my
  variable defined at the top level of your Apache::Registry script in a
  subroutine. See this entry in the mod_perl guide:
 
 
http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S
 
  The workaround is to make $ID a package global (use vars qw($ID)).

 With Perl 5.6, the following are roughly equivalent:

   use vars qw($ID);

   our $ID;

 However, you will need to put the `our' declaration within the block
(which
 may happen implicitely with Apache::Registry).

 So (pre-5.6):

   use vars qw($ID);

   sub foo {
   $ID = shift;
   }

 But (= 5.6):

   sub foo {
   our $ID = shift;
 }




mod_perl forgetting values

2001-08-09 Thread Kevin Schroeder

Hi,
I'm currently writing a program for a client that utilizes mod_perl.  It
runs fine in my development environment of Linux running Apache 1.3.20 with
mod_perl 1.25.  But when I put it into the live environment which is Solaris
2.x running Apache 1.3.12 with mod_perl 1.21 it has a tendency to
intermittently forget values that are being sent from a form.  Everything is
scoped properly and it's not like the program is remembering values
previously sent, it will suddenly forget the value of a variable.

The thing that fixed it was restarting Apache.  I would prefer to have
a fix for this problem rather than a simple workaround like restarting
Apache from cron every few hours.

Does anyone here know the reason or a solid fix for this problem?  Does
it have something to do with the older versions of Apache and mod_perl?

Thanks,
Kevin




Re: my OR our that is the question ?!

2001-08-09 Thread Perrin Harkins

 So what is the REASON for this copy-on-first-call behaviour.(there have to
 be some reason, if i'm not totaly dull to see it )

It's called a closure.  You can read up on it in the Camel book or in Damian
Conway's OO book.
- Perrin




Re: my OR our that is the question ?!

2001-08-09 Thread raptor

didn't thought of that :)), but what will broke if the var is
copied/aliased every time not just the first time ...

I mean the call to closure make a new instance of the sub()  every time
isn't it ?!?
! I see the closures get bound every-time , but non closures only the
first time !
But still can figure out ...if I'm thinking correctly .

- closure makes a new instance of of itself and get the latest value of
outer-lexical variable in its private space.
- there is no reason why normal sub() can get/alias! this value every time,
this doens't broke the closure behaviour (i.e. normal sub() doesn't need to
make its own private copy but use the outer-scope-lexical  ) or I'm wrong
again.
=
iVAN
[EMAIL PROTECTED]
=




OT: Re: my OR our that is the question ?!

2001-08-09 Thread James Smith

On Fri, Aug 10, 2001 at 01:08:12AM +0300, raptor wrote:
 didn't thought of that :)), but what will broke if the var is
 copied/aliased every time not just the first time ...
 
 I mean the call to closure make a new instance of the sub()  every time
 isn't it ?!?
 ! I see the closures get bound every-time , but non closures only the
 first time !
 But still can figure out ...if I'm thinking correctly .
 
 - closure makes a new instance of of itself and get the latest value of
 outer-lexical variable in its private space.
 - there is no reason why normal sub() can get/alias! this value every time,
 this doens't broke the closure behaviour (i.e. normal sub() doesn't need to
 make its own private copy but use the outer-scope-lexical  ) or I'm wrong
 again.

This really is more of a Perl topic.

Many people mistake anonymous subs and closures.  The two are orthoginal:
anonymous subs can be closures, named subs and be closures, anonymous subs
might not be closures, named subs likewise.  It all depends on if named
lexical variables are in scope when the sub is defined.

--James



Re: mod_perl forgetting values

2001-08-09 Thread Stas Bekman

On Thu, 9 Aug 2001, Kevin Schroeder wrote:

 Hi,
 I'm currently writing a program for a client that utilizes mod_perl.  It
 runs fine in my development environment of Linux running Apache 1.3.20 with
 mod_perl 1.25.  But when I put it into the live environment which is Solaris
 2.x running Apache 1.3.12 with mod_perl 1.21 it has a tendency to
 intermittently forget values that are being sent from a form.  Everything is
 scoped properly and it's not like the program is remembering values
 previously sent, it will suddenly forget the value of a variable.

 The thing that fixed it was restarting Apache.  I would prefer to have
 a fix for this problem rather than a simple workaround like restarting
 Apache from cron every few hours.

 Does anyone here know the reason or a solid fix for this problem?  Does
 it have something to do with the older versions of Apache and mod_perl?

most likely
http://perl.apache.org/guide/porting.html#Sometimes_it_Works_Sometimes_it

try testing with -X

_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Re: my OR our that is the question ?!

2001-08-09 Thread Stas Bekman

On Thu, 9 Aug 2001, Perrin Harkins wrote:

  So what is the REASON for this copy-on-first-call behaviour.(there have to
  be some reason, if i'm not totaly dull to see it )

 It's called a closure.  You can read up on it in the Camel book or in Damian
 Conway's OO book.

oh even here:
http://perl.apache.org/guide/perl.html#Understanding_Closures_the_Ea


_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Error decrypting in message using gpg in modperl script

2001-08-09 Thread Chris Pizzo

Anyone know why the decryption fails using gpg when run in a perl script in
a browser but works if run in a shell?  Here's the code sample:

my $cipher = TAG;
 -BEGIN PGP MESSAGE-

pvbhS8Q22VYPqn+4sitEw0bgTmDhPo6rruzsSJxCHLBUyTPrYaPlmelF2iADCpKD
IeqIOK0KZwRMHrXrlFir37i+2NzmNzcF4kidPKWuKSQe6ZNWs28=
=w+vi
-END PGP MESSAGE-
TAG
# Decode logic

$ENV{GNUPGHOME}=/usr/local/.gnupg;


my($PGP,$dbh,$sth,$pid,$recipient,$dat,@plaintext,@errs,$q,$r,$cc_no,$cc_exp
, $dbh1);

my($amount,$cc_no,$cc_exp,$c_name,$c_add,$c_city,$c_st,$c_zip,$c_country,$c_
type);

$PGP = /usr/bin/gpg --no-secmem-warning -dar;

$recipient = xx;

# Open a two-way pipe to pgp or gpg.
$pid = open3(\*PGP_WRITE, \*PGP_READ, \*PGP_ERR, $PGP $recipient);

unless ($pid) {
print Error: Could not open encryption program: $!;
exit;
}
# Send the plaintext to pgp/gpg

print PGP_WRITE $cipher;

close(PGP_WRITE);

# Read the ciphertext from PGP/gpg

@plaintext = PGP_READ;
close(PGP_READ);

# Read any error messages.

@errs = PGP_ERR;
close(PGP_ERR);
print @errs;

This is the Error:
gpg: decrypt_message failed: eof

Again it works fine in a shell but fails when run from the browser.  Any
help greatly appreiciated.

Chris




Re: Error decrypting in message using gpg in modperl script

2001-08-09 Thread Ron Savage

Chris

See below.

Cheers
Ron Savage
[EMAIL PROTECTED]
http://savage.net.au/index.html

 $PGP = /usr/bin/gpg --no-secmem-warning -dar;

Ahhh. Does the web server, running as 'nobody' (perhaps) have permission to run 'gpg'?





Re: Error decrypting in message using gpg in modperl script

2001-08-09 Thread Benjamin Trott

 Anyone know why the decryption fails using gpg when run in a perl script in
 a browser but works if run in a shell?  Here's the code sample:
 
 my $cipher = TAG;
 -BEGIN PGP MESSAGE-
 
 pvbhS8Q22VYPqn+4sitEw0bgTmDhPo6rruzsSJxCHLBUyTPrYaPlmelF2iADCpKD
 IeqIOK0KZwRMHrXrlFir37i+2NzmNzcF4kidPKWuKSQe6ZNWs28=
 =w+vi
 -END PGP MESSAGE-

This is not an answer to your question, but might I suggest (plug) using
Crypt::OpenPGP, my pure-Perl OpenPGP implementation? It will decrypt your
message, and it won't require launching an external shell etc.

use Crypt::OpenPGP:
my $pgp = Crypt::OpenPGP-new;
my $pt = $pgp-decrypt( Data = $cipher, Passphrase = $pass );

Here is a page w/ some more information:

http://rhumba.pair.com/ben/perl/openpgp/

If you have any problems let me know by mail.

bye,
Ben




cvs commit: modperl-2.0/xs/Apache/Filter Apache__Filter.h

2001-08-09 Thread dougm

dougm   01/08/09 09:52:51

  Modified:src/modules/perl modperl_bucket.c modperl_filter.c
modperl_filter.h
   xs/Apache/Filter Apache__Filter.h
  Log:
  adjust to recent bucket brigade api changes
  
  Revision  ChangesPath
  1.3   +7 -5  modperl-2.0/src/modules/perl/modperl_bucket.c
  
  Index: modperl_bucket.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_bucket.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- modperl_bucket.c  2001/08/04 18:49:25 1.2
  +++ modperl_bucket.c  2001/08/09 16:52:51 1.3
  @@ -55,7 +55,6 @@
   static const apr_bucket_type_t modperl_bucket_sv_type = {
   mod_perl SV bucket, 4,
   modperl_bucket_sv_destroy,
  -modperl_bucket_sv_free,
   modperl_bucket_sv_read,
   apr_bucket_setaside_notimpl,
   apr_bucket_shared_split,
  @@ -67,9 +66,10 @@
 SV *sv,
 int offset, int len)
   {
  -modperl_bucket_sv_t *svbucket = 
  -(modperl_bucket_sv_t *)safemalloc(sizeof(*svbucket));
  +modperl_bucket_sv_t *svbucket; 
   
  +Newz(0, svbucket, 1, modperl_bucket_sv_t);
  +
   bucket = apr_bucket_shared_make(bucket, svbucket, offset, offset+len);
   
   /* XXX: need to deal with PerlInterpScope */
  @@ -79,7 +79,7 @@
   svbucket-sv = sv;
   
   if (!bucket) {
  -safefree(svbucket);
  +Safefree(svbucket);
   return NULL;
   }
   
  @@ -88,6 +88,8 @@
   MP_TRACE_f(MP_FUNC, sv=0x%lx, refcnt=%d\n,
  (unsigned long)sv, SvREFCNT(sv));
   
  +bucket-free = modperl_bucket_sv_free;
  +
   bucket-type = modperl_bucket_sv_type;
   
   return bucket;
  @@ -95,7 +97,7 @@
   
   apr_bucket *modperl_bucket_sv_create(pTHX_ SV *sv, int offset, int len)
   {
  -apr_bucket *bucket = (apr_bucket *)calloc(1, sizeof(*bucket));
  +apr_bucket *bucket = (apr_bucket *)safemalloc(sizeof(*bucket));
   APR_BUCKET_INIT(bucket);
   return modperl_bucket_sv_make(aTHX_ bucket, sv, offset, len);
   }
  
  
  
  1.23  +2 -2  modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- modperl_filter.c  2001/07/15 23:42:06 1.22
  +++ modperl_filter.c  2001/08/09 16:52:51 1.23
  @@ -112,7 +112,7 @@
   }
   
   int modperl_run_filter(modperl_filter_t *filter, ap_input_mode_t mode,
  -   apr_size_t *readbytes)
  +   apr_off_t *readbytes)
   {
   AV *args = Nullav;
   int status;
  @@ -382,7 +382,7 @@
   apr_status_t modperl_input_filter_handler(ap_filter_t *f,
 apr_bucket_brigade *bb,
 ap_input_mode_t mode,
  -  apr_size_t *readbytes)
  +  apr_off_t *readbytes)
   {
   modperl_filter_t *filter;
   int status;
  
  
  
  1.10  +2 -2  modperl-2.0/src/modules/perl/modperl_filter.h
  
  Index: modperl_filter.h
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- modperl_filter.h  2001/07/15 22:33:48 1.9
  +++ modperl_filter.h  2001/08/09 16:52:51 1.10
  @@ -26,7 +26,7 @@
   modperl_filter_t *modperl_filter_mg_get(pTHX_ SV *obj);
   
   int modperl_run_filter(modperl_filter_t *filter, ap_input_mode_t mode,
  -   apr_size_t *readbytes);
  +   apr_off_t *readbytes);
   
   /* output filters */
   apr_status_t modperl_output_filter_handler(ap_filter_t *f,
  @@ -53,7 +53,7 @@
   apr_status_t modperl_input_filter_handler(ap_filter_t *f,
 apr_bucket_brigade *bb,
 ap_input_mode_t mode,
  -  apr_size_t *readbytes);
  +  apr_off_t *readbytes);
   
   void modperl_input_filter_register_connection(conn_rec *c);
   
  
  
  
  1.13  +1 -1  modperl-2.0/xs/Apache/Filter/Apache__Filter.h
  
  Index: Apache__Filter.h
  ===
  RCS file: /home/cvs/modperl-2.0/xs/Apache/Filter/Apache__Filter.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Apache__Filter.h  2001/07/15 22:33:50 1.12
  +++ Apache__Filter.h  2001/08/09 16:52:51 1.13
  @@ -63,7 +63,7 @@