pros & cons of Apache2::Request vs. CGI

2007-01-14 Thread Torsten Foertsch
Hi,

what are the pros and cons of Apache2::Request vs. CGI in a MP2 environment?

Torsten


pgpw866vf3vwx.pgp
Description: PGP signature


OT: Really wierd problem with TT2

2007-01-14 Thread Erik Norgaard

Hi:

I know this is not modperl specific, but, I use TemplateToolkit2 to 
create pages on my site. My site contains a lot of photos and I want to 
add listings with thumbnail preview. But element attributes magically 
appears when generating the page. The page contains no java script or 
other stuff that can account for this:


In my handler I create a list reference with one entry preview per page 
like this:


  my $item;
  $item->{path}  = getPath($page->{page_id});
  $item->{title} = $page->{title};
  $item->{ctime} = dateStr($page->{ctime});

  my $text = $page->{page};
  if (my ($src) = $text =~ //io) { # Get image source
$src =~ s/\/?photo/photo\/thumb/gio;
$item->{img} = $src;
  }

  $text =~ s/.*?<\/object>//go; # Remove object-element
  $text =~ s/.*?<\/h\d>//gio;
  $text =~ s/\n?<\/p>/\n/go; # Replace paragraph by newline
  $text =~ s/<.*?>//go; # Remove all elements
  $text = substr($text,0,256);  # Get first 256 chars
  $text =~ s/\.[^\.]*?$/./go;   # Chomp to last period
  $text =~ s/\r?\n\r?\n\r?/\n/go;   # Remove double new-lines
  $item->{text} = $text;

So, the item contains the title, extract of the content and possibly 
path to a thumbnail image.


In my template I have this:

[% FOREACH item IN list %]

[% IF item.img %]


  


[% END %]


  [% item.title %]

Posted: [% item.ctime %]
[% item.text %]


[% END %]

Which produces this output:




  




Beach of Paris
Posted: 2007-01-07 00:42:25 UTC+01
This august in Paris they ...



So: where does the alt, title and class attributes in the image element 
come from??? I tried first to set these in the template, and discovered 
the dublicates when I tried to validate the result. Now, removing these 
attributes from the template and restarting Apache several times, I 
still get these extra "ghost" attributes.


If you like to see for yourself without my edits, the generated output 
is here: http://www.locolomo.org/photos/ and the full template is here: 
http://www.locolomo.org/pub/src/xcms/tt2/list.tt2


Thanks, Erik
--
Ph: +34.666334818  web: http://www.locolomo.org


smime.p7s
Description: S/MIME Cryptographic Signature


Re: pros & cons of Apache2::Request vs. CGI

2007-01-14 Thread Perrin Harkins

Torsten Foertsch wrote:

what are the pros and cons of Apache2::Request vs. CGI in a MP2 environment?


Apache2::Request is faster and uses less memory.  CGI is easier to 
install, has more features, and is portable to other environments.


- Perrin


Re: OT: Really wierd problem with TT2

2007-01-14 Thread Perrin Harkins

Erik Norgaard wrote:
So: where does the alt, title and class attributes in the image element 
come from???


This is something you will have to figure out by experimenting.  Print 
the contents of $item->{img} to your error_log.  Take the item.img part 
out of your template.  Change things until you understand where it's 
coming from.


- Perrin


Solved: OT: Really wierd problem with TT2

2007-01-14 Thread Erik Norgaard

Perrin Harkins wrote:

Erik Norgaard wrote:
So: where does the alt, title and class attributes in the image element 
come from???


This is something you will have to figure out by experimenting.  Print 
the contents of $item->{img} to your error_log.  Take the item.img part 
out of your template.  Change things until you understand where it's 
coming from.


Yes  taking a few hours off the bug is obvious, in the parsing for 
the source path of the image:


  if (my ($src) = $text =~ //io) {

Should be:

  if (my ($src) = $text =~ //io) {

The first takes all the attributes of the original image ... DUH!

Well, thanks.

Cheers Erik

--
Ph: +34.666334818  web: http://www.locolomo.org


smime.p7s
Description: S/MIME Cryptographic Signature


urgent help needed - this script does not chdir

2007-01-14 Thread abhishek jain

Hi,
I am new to modperl and needs help, i have a script which works fine in
non-modperl enviornment but when i include in modperl::registry then mine
scripts when invoked via a browser finds itself in / directory i mean the
file or script do not include the files with the require command i mean the
relative path it cannot understand.
Additionally when i give this block,
BEGIN{
chdir('/home/absolute/directory');
};

then the script will run fine for some time and not fine i mean will give
error on including a function in a library included by require.


Pl. help me , i need a sol urgently ,
thanks ,
Abhsihek jain


Re: urgent help needed - this script does not chdir

2007-01-14 Thread Perrin Harkins

abhishek jain wrote:
I am new to modperl and needs help, i have a script which works fine in 
non-modperl enviornment but when i include in modperl::registry then 
mine scripts when invoked via a browser finds itself in / directory


http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache__Registry___C_Apache__PerlRun__and_Friends

- Perrin


does begin block effect any performance in modperl

2007-01-14 Thread abhishek jain

Hi friends,
i need to know that if i add the following block then will it affect
anything in the execution of modperl apart from first time run.

BEGIN{
require'abc.pl';
require'large_file.pl';

};

I mean anything relative to the performance.is the begin block called
everytime orjust the first time and is it safe to define a function in a
file and call it with this method rather than a package ,

Pl. help me.

Thanks,
Abhishek jain.


Problem with libapreq2 and make

2007-01-14 Thread Jonathan Mangin
Hi,
Downloaded libapreq2-2.08 and did:
perl Makefile.PL --with-apache2-apxs=/usr/local/apache3/bin/apxs
make

Got the following errors:
make[2]: *** [libapreq2.la] Error 1
make[2]: Leaving directory `/src/misc/libapreq2-2.08/library'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/src/misc/libapreq2-2.08/library'
make: *** [all-recursive] Error 1

I got the same errors with a CPAN install.  Does anyone have a
clue what the problem might be?  I replaced make 3.80 with 3.81,
but no difference.  This is with Solaris 2.8x86 and gcc 3.3.2.

Thanks,
Jon



Re: does begin block effect any performance in modperl

2007-01-14 Thread Clinton Gormley
On Mon, 2007-01-15 at 00:49 +0530, abhishek jain wrote:
> Hi friends,
> i need to know that if i add the following block then will it affect
> anything in the execution of modperl apart from first time run.
> BEGIN{
> require'abc.pl';
> require'large_file.pl';
> 
> };
> 
> I mean anything relative to the performance.is the begin block called
> everytime orjust the first time and is it safe to define a function in
> a file and call it with this method rather than a package , 

The begin blocks are only run at compile time, so won't affect the
performance of future requests.

http://perl.apache.org/docs/2.0/user/coding/coding.html#C_BEGIN__Blocks

clint



Re: Problem with libapreq2 and make

2007-01-14 Thread Jonathan Mangin

- Original Message - 
From: "Jonathan Mangin" <[EMAIL PROTECTED]>
To: 
Sent: Sunday, January 14, 2007 2:30 PM
Subject: Problem with libapreq2 and make


> Hi,
> Downloaded libapreq2-2.08 and did:
> perl Makefile.PL --with-apache2-apxs=/usr/local/apache3/bin/apxs
> make
>
> Got the following errors:
> make[2]: *** [libapreq2.la] Error 1
> make[2]: Leaving directory `/src/misc/libapreq2-2.08/library'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory `/src/misc/libapreq2-2.08/library'
> make: *** [all-recursive] Error 1
>
> I got the same errors with a CPAN install.  Does anyone have a
> clue what the problem might be?  I replaced make 3.80 with 3.81,
> but no difference.  This is with Solaris 2.8x86 and gcc 3.3.2.
>
> Thanks,
> Jon
>
I see that others have gotten actual errors before the
lines I listed above.  I don't see any errors.
Here are the three lines preceding make[2]... (just in case):

(cd .libs && rm -f libapreq2.so.2 && ln -s libapreq2.so.2.6.0
libapreq2.so.2)
(cd .libs && rm -f libapreq2.so && ln -s libapreq2.so.2.6.0 libapreq2.so)
false cru .libs/libapreq2.a  util.o version.o cookie.o param.o parser.o
parser_urlencoded.o parser_header.o parser_multipart.o module.o
module_custom.o module_cgi.o error.o

Thanks again,
Jon



RE: error when installing mod_perl

2007-01-14 Thread Adam Prime x443
I just ran into this same error.  mod_perl 2.0.3 will build fine against
httpd 2.2.3, but against 2.2.4 it gives this single failed test.  

Adam 

-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 13, 2007 4:17 AM
To: modperl@perl.apache.org
Subject: error when installing mod_perl

Hi,

I have tried to install mod_perl with Apache 2.24, but it gave the
following 
error:

Failed Test  Stat Wstat Total Fail  List of Failed

---
t/api/server_const.t31  3
4 tests and 1 subtest skipped.
Failed 1/236 test scripts. 1/2578 subtests failed.
Files=236, Tests=2578, 190 wallclock secs (151.08 cusr + 26.72 csys =
177.80 
CPU)
Failed 1/236 test programs. 1/2578 subtests failed.
[warning] server localhost.localdomain:8529 shutdown
[  error] error running tests (please examine t/logs/error_log)
++
| Please file a bug report: http://perl.apache.org/bugs/ |
++
make: *** [run_tests] Error 1
[EMAIL PROTECTED] mod_perl-2.0.3]#

Octavian



Re: error when installing mod_perl

2007-01-14 Thread Octavian Rasnita

From: "Adam Prime x443" <[EMAIL PROTECTED]>


I just ran into this same error.  mod_perl 2.0.3 will build fine against
httpd 2.2.3, but against 2.2.4 it gives this single failed test.


Yes I know that, but I don't know if that bug is an important one and if it 
would be better to install Apache 2.23 instead of 2.24 until it will be 
patched.


Does anyone know?

Octavian





Re: Lost ENV variable value .........

2007-01-14 Thread Tracy12

Can you let us know how you did this,

Can we update the REMOTE_USER variable, From where can we find the
documentation.

Does mod_cas takes configurable parameters,is it s Authentication module,

Our objective is simply, call the CAS, serivice_validate retrive the xml and
look for a specific attribute, if it is there update the remote_user
variable, that is it. We dont bother about any PGTIOU etc... We only
care about service_validate.

Let us know specifics,

Thanks



Peter Rosenthal wrote:
> 
> I have used CAS myself, but instead of attempting to implement the server
> module for CAS authentication I used mod_cas. This might be an easier way
> of
> doing what you are trying to do.
> 
> On 12/01/07, Michael Peters <[EMAIL PROTECTED]> wrote:
>>
>> Tracy12 wrote:
>>
>> > 1) As we dont use the apache basic authentication but our CAS
>> > authentication. If the authentication is not successful how can we
>> redirect
>> > to the CAS login page.
>> >
>> >   My suggestion -> instead of returning the AUTH_REQUIRED redirect
>> to
>> > CAS URL with the service.
>> >   if this is wrong how to achieve this in a different way
>>
>> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
>> redirection
>> (unless of course you need to figure out the URL dynamically). This way
>> you can
>> keep the location as part of your config data.
>>
>> ErrorDocument 403 /login/url
>>
>> > 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> > entry what the values should we give for AuthType , AuthName in the
>> above
>> > Location declaration.
>>
>> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
>> whatever you want it to be. It's basically a way to group the locations
>> that use
>> the same Auth together (called a "realm").
>>
>> > 3) Pass addtional parameters to the handler
>> >   solution -> in the httpd.conf block pass it as
>> >
>> >   PerlSetVar CASHost "testCasServer"
>> >   PerlSetVar CASPort "8443"
>>
>> Yep. If possible keep the configuration data inside the configuration
>> s.
>>
>> --
>> Michael Peters
>> Developer
>> Plus Three, LP
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Lost-ENV-variable-value-.-tf2956856.html#a8364005
Sent from the mod_perl - General mailing list archive at Nabble.com.



How to extract a parameter

2007-01-14 Thread Tracy12

Hi,

Is there a easy way to extract the ticket(may be using a Regular Expression)
parameter from a URL as follows

http://localhost/myTest.pl?ticket=ST-2-zbwAtOlYlfzoC6knUXP9&name=test

I need to extract this from the perl_module where I have a handler for the
$r as follows, which is called from the httpd.conf

sub authen_handler  {
my $self= shift;
my $r = shift;

 ..

Also would like to know how to get the entire queryString?

-- 
View this message in context: 
http://www.nabble.com/How-to-extract-a-parameter-tf3011730.html#a8364352
Sent from the mod_perl - General mailing list archive at Nabble.com.



Re: How to extract a parameter

2007-01-14 Thread Fred Moyer

Tracy12 wrote:

Hi,

Is there a easy way to extract the ticket(may be using a Regular Expression)
parameter from a URL as follows

http://localhost/myTest.pl?ticket=ST-2-zbwAtOlYlfzoC6knUXP9&name=test


use CGI;
my $cgi = CGI->new($r);
my $ticket = $cgi->param('ticket');



I need to extract this from the perl_module where I have a handler for the
$r as follows, which is called from the httpd.conf

sub authen_handler  {
my $self= shift;
my $r = shift;

 ..

Also would like to know how to get the entire queryString?


http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_args_

But it's really much easier to use CGI :)

HTH


Re: How to extract a parameter

2007-01-14 Thread Jonathan Vanasco


On Jan 14, 2007, at 6:45 PM, Fred Moyer wrote:

But it's really much easier to use CGI :)


There's also libapreq





// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -

| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -

| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -





Re: Lost ENV variable value .........

2007-01-14 Thread Tracy12

I agree but look at the following scenario

if User hits http://somedomain/test.pl?param1=x¶m2=y

and if a failure happens in the authenticate handler I need to redirect to 

http://casmachine:8443/cas/login?service= that is
http://casmachine:8443/cas/login?service=http://somedomain/test.pl?param1=x¶m2=y


even though the
http://casmachine:8443/cas/login?service=http://somedomain/test.pl is static
users might requrest for inner files. Hence it is not static

Due to this reason I thought I cant use AUTH_REQUIRED and use ErrorDocument 

Please let me know above can be achieved even using errorDocument 

Thanks





Peter Rosenthal wrote:
> 
> I have used CAS myself, but instead of attempting to implement the server
> module for CAS authentication I used mod_cas. This might be an easier way
> of
> doing what you are trying to do.
> 
> On 12/01/07, Michael Peters <[EMAIL PROTECTED]> wrote:
>>
>> Tracy12 wrote:
>>
>> > 1) As we dont use the apache basic authentication but our CAS
>> > authentication. If the authentication is not successful how can we
>> redirect
>> > to the CAS login page.
>> >
>> >   My suggestion -> instead of returning the AUTH_REQUIRED redirect
>> to
>> > CAS URL with the service.
>> >   if this is wrong how to achieve this in a different way
>>
>> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
>> redirection
>> (unless of course you need to figure out the URL dynamically). This way
>> you can
>> keep the location as part of your config data.
>>
>> ErrorDocument 403 /login/url
>>
>> > 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> > entry what the values should we give for AuthType , AuthName in the
>> above
>> > Location declaration.
>>
>> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
>> whatever you want it to be. It's basically a way to group the locations
>> that use
>> the same Auth together (called a "realm").
>>
>> > 3) Pass addtional parameters to the handler
>> >   solution -> in the httpd.conf block pass it as
>> >
>> >   PerlSetVar CASHost "testCasServer"
>> >   PerlSetVar CASPort "8443"
>>
>> Yep. If possible keep the configuration data inside the configuration
>> s.
>>
>> --
>> Michael Peters
>> Developer
>> Plus Three, LP
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Lost-ENV-variable-value-.-tf2956856.html#a8365208
Sent from the mod_perl - General mailing list archive at Nabble.com.



Re: Lost ENV variable value .........

2007-01-14 Thread Tracy12

I agree but look at the following scenario

if User hits http://somedomain/test.pl?param1=x¶m2=y

and if a failure happens in the authenticate handler I need to redirect to

http://casmachine:8443/cas/login?service= that is
http://casmachine:8443/cas/login?service=http://somedomain/test.pl?param1=x¶m2=y


even though the
http://casmachine:8443/cas/login?service=http://somedomain/test.pl is static
users might requrest for inner files. Hence it is not static

Due to this reason I thought I cant use AUTH_REQUIRED and use ErrorDocument

Please let me know above can be achieved even using errorDocument

Thanks 

Michael Peters wrote:
> 
> Tracy12 wrote:
> 
>> 1) As we dont use the apache basic authentication but our CAS
>> authentication. If the authentication is not successful how can we
>> redirect
>> to the CAS login page.
>> 
>>   My suggestion -> instead of returning the AUTH_REQUIRED redirect to
>> CAS URL with the service.
>>   if this is wrong how to achieve this in a different way
> 
> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
> redirection
> (unless of course you need to figure out the URL dynamically). This way
> you can
> keep the location as part of your config data.
> 
>   ErrorDocument 403 /login/url
> 
>> 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> entry what the values should we give for AuthType , AuthName in the above
>> Location declaration.
> 
> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
> whatever you want it to be. It's basically a way to group the locations
> that use
> the same Auth together (called a "realm").
> 
>> 3) Pass addtional parameters to the handler
>>   solution -> in the httpd.conf block pass it as 
>> 
>>   PerlSetVar CASHost "testCasServer"
>>   PerlSetVar CASPort "8443"
> 
> Yep. If possible keep the configuration data inside the configuration
> s.
> 
> -- 
> Michael Peters
> Developer
> Plus Three, LP
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Lost-ENV-variable-value-.-tf2956856.html#a8365219
Sent from the mod_perl - General mailing list archive at Nabble.com.



Re: mod_perl installation

2007-01-14 Thread Foo JH
If you're running on Linux/ Sun, I think most people avoid threading for 
performance reasons. If you're going to be on Windows, you don't have a 
choice: threading is compulsory.


You may want to read up on the various MPM models for each OS.

Octavian Rasnita wrote:

Hi,

How it is recommended to install perl if I also want to use it with 
mod_perl?

With or without threading support?
With or without support for multiplicity?

It gives an error when installing with Apache 2.24, and I am trying to 
see if I don't make some mistakes.


Thank you.

Octavian





Re: How to extract a parameter

2007-01-14 Thread Foo JH

Fred Moyer wrote:

Tracy12 wrote:

Hi,

Is there a easy way to extract the ticket(may be using a Regular 
Expression)

parameter from a URL as follows

http://localhost/myTest.pl?ticket=ST-2-zbwAtOlYlfzoC6knUXP9&name=test


There is an easy way, that emulates CGI's methods. It's called 
libapreq2, and the class you're looking for is Apache2::Request. To get 
the ticket for example, you create an instance of the class, and called 
$req->param("ticket");


It's not part of the mod_perl package, but it is easily available.


Re: does begin block effect any performance in modperl

2007-01-14 Thread Jeff Pang

>> 
>> I mean anything relative to the performance.is the begin block called
>> everytime orjust the first time and is it safe to define a function in
>> a file and call it with this method rather than a package , 
>
>The begin blocks are only run at compile time, so won't affect the
>performance of future requests.
>

If you require those scripts from more than one main-script under mod_perl,then 
it should affect the performance.
Because each main-script load those scripts independently,then there are 
multi-copies of those scripts in each apache's process space,it distinctly 
waste the memory.
It's good to define the scripts needed to be loaded as  classes and access 
their methods by OO way.

--
Books below translated by me to Chinese.
Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/
Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/


Functionality works/test failed

2007-01-14 Thread Tracy12

Hi,

I am in the process of changing a perl module written to a Perl
Authentication handler.

Well when I try to deploy the module it failed in the  ' make test' stage
all the other steps went ok.
But the functionality works as expected.


When we execute make test it gives the following error

Failed Test Stat Wstat Total Fail  Failed  List of Failed
---
t/00.load.t1   256 11 100.00%  1
2 tests skipped.
Failed 1/3 test scripts, 66.67% okay. 1/1 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 255


I found out that the reason for failure is the following line

use Apache2::compat;

but when I remove this entry the make test gives no errors but functionality
fails and in the log it says that
 Can't locate object method "user" via package "Apache2::Connection" at
/usr/lib/perl5/site_perl/5.8.8/AuthCAS.pm line 512.\n

which is basically   $r->connection->user($user);
line in the source.



Also in the in the 't' folder the source of the 00.load.t is as follows

use Test::More tests => 1;

BEGIN {
use_ok( 'AuthCAS' );
}

diag( "Testing AuthCAS $AuthCAS::VERSION" );


Let us know how to get around with this,

-- 
View this message in context: 
http://www.nabble.com/Functionality-works-test-failed-tf3013107.html#a8367531
Sent from the mod_perl - General mailing list archive at Nabble.com.



Re: How to extract a parameter

2007-01-14 Thread Issac Goldstand
Jonathan Vanasco wrote:
> On Jan 14, 2007, at 6:45 PM, Fred Moyer wrote:
>> But it's really much easier to use CGI :)
> 
> There's also libapreq

OK - so out of the corner of my eye, I saw the link again as the
previous mail was being copied to my sent-mail and noticed that it said
RequestRec::args and not Request::args.  So I put my foot in my mouth :-)

As Jonathan correctly said, there's also libapreq:

http://httpd.apache.org/apreq/docs/libapreq2/modules.html