[cgiapp] CAP::Authentication install failure on Perl 5.10 ?

2009-03-19 Thread Richard Jones
Has anyone successfully installed CAP::Authentication under Perl 5.10? 
It's failed for me on two separate Ubuntu Intrepid platforms, and I 
assume it's a Perl 5.10 issue, as recent installs on other Ubuntu 
platforms running Perl 5.8.8 have all been fine.


All failures happen in t/02_config.t - here's an example:

#   Failed test 'config dies when LOGOUT_RUNMODE is passed a hashref' at 
t/02_config.t line 70.

# expecting: Regexp ((?-xism:parameter LOGOUT_RUNMODE is not a string))
# found: panic: attempt to copy freed scalar 86bb3c0 to 8638e70 at 
/usr/share/perl/5.10/Carp/Heavy.pm line 96.


and near-identical output for:
Failed test 'config dies when POST_LOGIN_RUNMODE is passed a hashref'
Failed test 'config dies when POST_LOGIN_CALLBACK is passed a hashref'
Failed test 'config dies when POST_LOGIN_CALLBACK is passed a string'
Failed test 'config dies when RENDER_LOGIN is passed a hashref'
etc

also:
#   Failed test 'config dies when LOGIN_SESSION_TIMEOUT recieves an 
unparsable string' at t/02_config.t line 114.
# expecting: Regexp ((?-xism:parameter LOGIN_SESSION_TIMEOUT is not a 
valid time string))
# found: Bizarre copy of HASH in sassign at 
/usr/share/perl/5.10/Carp/Heavy.pm line 96.


I'm not sure whether this is a CAP::Auth or a Carp/Carp::Heavy issue. 
Any thoughts?

--
Richard Jones

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




RE: [cgiapp] Re: Proper Way To Load Template Params

2009-03-19 Thread adam
 My template is getting data via a SQL query. There is exactly one row
 retrieved.
 
 Currently I use the below method to show all records using a loop:
 $template-param(
 RESULTS = $self-dbh-selectall_arrayref('
 SELECT age, day FROM table WHERE id = ?',
 { Slice = {} },
 $self-session-param('cell')-{'sid'} )
 );
 
 
 Template:
 TMPL_LOOP NAME=RESULTS
 TMPL_VAR NAME=ageTMPL_VAR NAME=day
 /TMPL_LOOP

This is not directly related, but you may want to look at DBIx::Simple
in combination with its support for DBIx::Interp as a simpler, interface
over top of raw DBI.

 But how should I load the template if I have exactly one row returned? 
 I could fudge it and use the loop to iterate of the one row, but I think
 that may be a sub optimal method.

 $self-dbh-selectall_arrayref('
 SELECT age, day FROM table WHERE id = ?',
 { Slice = {} },
 $self-session-param('cell')-{'sid'} )

To get one row back, use selectrow_hashref, it will return a single hashref.
( no Slice needed. )

You then can skip the loop tokens in a template:

TMPL_VAR NAME=ageTMPL_VAR NAME=day



Mark


$template-param(
TITLE = Page Title,
RESULTS = $self-dbh-selectall_arrayref('
SELECT age, day FROM table WHERE id = ?',
{ Slice = {} },
$self-session-param('cell')-{'sid'} )
);


So how would the above line be modified for the selectrow_hashref to
work?  I've been trying it on my own and I either end up calling
$template with odd paramaters or I'm missing my bind variables for the
SQL.


Thanks







#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] Re: Proper Way To Load Template Params

2009-03-19 Thread P Kishor
On Wed, Mar 18, 2009 at 2:30 PM,  a...@spatialsystems.org wrote:
 My template is getting data via a SQL query. There is exactly one row
 retrieved.

 Currently I use the below method to show all records using a loop:
 $template-param(
 RESULTS = $self-dbh-selectall_arrayref('
 SELECT age, day FROM table WHERE id = ?',
 { Slice = {} },
 $self-session-param('cell')-{'sid'} )
 );


 Template:
 TMPL_LOOP NAME=RESULTS
 TMPL_VAR NAME=ageTMPL_VAR NAME=day
 /TMPL_LOOP

This is not directly related, but you may want to look at DBIx::Simple
in combination with its support for DBIx::Interp as a simpler, interface
over top of raw DBI.

 But how should I load the template if I have exactly one row returned?
 I could fudge it and use the loop to iterate of the one row, but I think
 that may be a sub optimal method.

 $self-dbh-selectall_arrayref('
 SELECT age, day FROM table WHERE id = ?',
 { Slice = {} },
 $self-session-param('cell')-{'sid'} )

To get one row back, use selectrow_hashref, it will return a single hashref.
( no Slice needed. )

You then can skip the loop tokens in a template:

TMPL_VAR NAME=ageTMPL_VAR NAME=day



Mark


 $template-param(
 TITLE = Page Title,
 RESULTS = $self-dbh-selectall_arrayref('
 SELECT age, day FROM table WHERE id = ?',
 { Slice = {} },
 $self-session-param('cell')-{'sid'} )
 );


 So how would the above line be modified for the selectrow_hashref to
 work?  I've been trying it on my own and I either end up calling
 $template with odd paramaters or I'm missing my bind variables for the
 SQL.


I do like so

my $results = $sth-fetchall_arrayref({});

and then

my $tmpl = param(
  RESULTS = $results,
);



 Thanks







 #  CGI::Application community mailing list  
 ##                                                            ##
 ##  To unsubscribe, or change your message delivery options,  ##
 ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
 ##                                                            ##
 ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
 ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
 ##                                                            ##
 





-- 
Puneet Kishor http://www.punkish.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Carbon Model http://carbonmodel.org/
Open Source Geospatial Foundation http://www.osgeo.org/

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




[cgiapp] New to working with CGI::App and OO perl. Testing under mod_perl. The old inconsistent data with reloads problem.

2009-03-19 Thread Derek Walker
I'm writing a very basic app under apache + mod_perl.

I've made the super vanilla instance script and application module.

=
#!/usr/bin/perl
use lib '/var/www/html/infra';
use Physical;

my $app = Physical-new();
$app-run();
=
package Physical;
use strict;
use warnings;
use base 'CGI::Application';
use DBI;
use CGI::Carp qw( fatalsToBrowser );
#
my $dbh;
my $user;
my @roles;
my $c_id;
#

#for $i ( 0 .. $#ref ) {
#for $j ( 0 .. $#{$ref[$i]} ) {
#$ref[$i][$j];
#}
#}

sub setup {
=

SNIP

I'm running into the old chestnut of a problem of how to properly
'wrap' a perl application under mod_perl to avoid the shared global
variable issue (that I only partially understand at this point)

Reading from a couple of books and web sites I can see the basics of
how to wrap things to avoid this collision, but I can't quite make it
work for my basic test app.

Is there a quick or easy way to modify the instance script to make it
play better under mod_perl?

Thanks.

-- 
-Derek

Nothing will work unless you do.

PGP: CA0C 4699 5B89 930F FD1D  705A 6CBF 52F9 4612 6276

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] CAP::Authentication install failure on Perl 5.10 ?

2009-03-19 Thread fREW Schmidt
On Wed, Mar 18, 2009 at 9:40 AM, Richard Jones ra.jo...@dpw.clara.co.ukwrote:

 Has anyone successfully installed CAP::Authentication under Perl 5.10? It's
 failed for me on two separate Ubuntu Intrepid platforms, and I assume it's a
 Perl 5.10 issue, as recent installs on other Ubuntu platforms running Perl
 5.8.8 have all been fine.

 All failures happen in t/02_config.t - here's an example:

 #   Failed test 'config dies when LOGOUT_RUNMODE is passed a hashref' at
 t/02_config.t line 70.
 # expecting: Regexp ((?-xism:parameter LOGOUT_RUNMODE is not a string))
 # found: panic: attempt to copy freed scalar 86bb3c0 to 8638e70 at
 /usr/share/perl/5.10/Carp/Heavy.pm line 96.

 and near-identical output for:
 Failed test 'config dies when POST_LOGIN_RUNMODE is passed a hashref'
 Failed test 'config dies when POST_LOGIN_CALLBACK is passed a hashref'
 Failed test 'config dies when POST_LOGIN_CALLBACK is passed a string'
 Failed test 'config dies when RENDER_LOGIN is passed a hashref'
 etc

 also:
 #   Failed test 'config dies when LOGIN_SESSION_TIMEOUT recieves an
 unparsable string' at t/02_config.t line 114.
 # expecting: Regexp ((?-xism:parameter LOGIN_SESSION_TIMEOUT is not a valid
 time string))
 # found: Bizarre copy of HASH in sassign at
 /usr/share/perl/5.10/Carp/Heavy.pm line 96.

 I'm not sure whether this is a CAP::Auth or a Carp/Carp::Heavy issue. Any
 thoughts?


I'm running CAP::Authentication with perl 5.10 on windows fine.

-- 
fREW Schmidt
http://blog.afoolishmanifesto.com

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] New to working with CGI::App and OO perl. Testing under mod_perl. The old inconsistent data with reloads problem.

2009-03-19 Thread Michael Peters

Derek Walker wrote:


I'm running into the old chestnut of a problem of how to properly
'wrap' a perl application under mod_perl to avoid the shared global
variable issue (that I only partially understand at this point)


The basic idea is don't use globals (to make things simpler, my package scoped 
variables are the same as globals in this email). The problem is remembering 
that your package won't be recompiled on every request so anything you put in a 
global will stick around for every request. Sometimes this is what you want (say 
for a configuration object which doesn't change between requests) but in others 
it's not. I see you have a $user and @roles. Those are definitely per-request 
kinds of things and should never be globals.


Also, you really shouldn't put a database handle as a global either since that 
could timeout and then you'll get strange problems at 6am when people start 
using your app again in the morning after it's been sitting for hours without 
any use. Under mod_perl Apache::DBI takes care of giving you a nice peristant DB 
conection without you having to worry about things like timeouts.


--
Michael Peters
Plus Three, LP


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




[cgiapp] 500 error on missing runlevel

2009-03-19 Thread Stewart L
Tried digging a bit through the archives and didn't find anything on this.

If someone does something weird and calls a runlevel that does not exist,
the application returns a 500 Server error and the message 'no such run
level'.

Is there a way to handle this more gracefully than have the application
crash?  I'd like to return an error page.

-- 
Stewart
--
If you see yourself in others, then whom can you harm?

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] 500 error on missing runlevel

2009-03-19 Thread Steve
Are you using either CGI::Application::Dispatch or CGI::Carp 
qw(fatalsToBrowser)?


---
Steve Comrie

Stewart L wrote:

Tried digging a bit through the archives and didn't find anything on this.

If someone does something weird and calls a runlevel that does not exist,
the application returns a 500 Server error and the message 'no such run
level'.

Is there a way to handle this more gracefully than have the application
crash?  I'd like to return an error page.

  



#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] 500 error on missing runlevel

2009-03-19 Thread fREW Schmidt
On Thu, Mar 19, 2009 at 1:01 PM, Steve st...@octane.to wrote:

 Are you using either CGI::Application::Dispatch or CGI::Carp
 qw(fatalsToBrowser)?

 ---
 Steve Comrie

 Stewart L wrote:

 Tried digging a bit through the archives and didn't find anything on this.

 If someone does something weird and calls a runlevel that does not exist,
 the application returns a 500 Server error and the message 'no such run
 level'.

 Is there a way to handle this more gracefully than have the application
 crash?  I'd like to return an error page.



http://search.cpan.org/dist/CGI-Application/lib/CGI/Application.pm
Search for AUTOLOAD.  That should do what you want.


-- 
fREW Schmidt
http://blog.afoolishmanifesto.com

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] 500 error on missing runlevel

2009-03-19 Thread Stewart L
AUTOLOAD worked great.  Thanks for thae help and the fast response.

On Thu, Mar 19, 2009 at 2:58 PM, Stewart L stewart...@gmail.com wrote:

 AUTOLOAD worked great.  Thanks for thae help and the fast response.

 Stew



 On Thu, Mar 19, 2009 at 2:53 PM, fREW Schmidt fri...@gmail.com wrote:

 On Thu, Mar 19, 2009 at 1:01 PM, Steve st...@octane.to wrote:

  Are you using either CGI::Application::Dispatch or CGI::Carp
  qw(fatalsToBrowser)?
 
  ---
  Steve Comrie
 
  Stewart L wrote:
 
  Tried digging a bit through the archives and didn't find anything on
 this.
 
  If someone does something weird and calls a runlevel that does not
 exist,
  the application returns a 500 Server error and the message 'no such run
  level'.
 
  Is there a way to handle this more gracefully than have the application
  crash?  I'd like to return an error page.
 
 

 http://search.cpan.org/dist/CGI-Application/lib/CGI/Application.pm
 Search for AUTOLOAD.  That should do what you want.


 --
 fREW Schmidt
 http://blog.afoolishmanifesto.com

 #  CGI::Application community mailing list  
 ####
 ##  To unsubscribe, or change your message delivery options,  ##
 ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
 ####
 ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
 ##  Wiki:  http://cgiapp.erlbaum.net/ ##
 ####
 




 --
 Stewart
 --
 If you see yourself in others, then whom can you harm?




-- 
Stewart
--
If you see yourself in others, then whom can you harm?

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] Double session use for CAP::Session

2009-03-19 Thread Ron Savage
Hi Brad

On Wed, 2009-03-18 at 09:41 -0500, Brad Cathey wrote:
 Hello,
 

 QUESTION: is there anyway to manipulate multiple sessions in  
 CAP::Session?

The only way is for the 1st app to pass the 1st session id to the 2nd
app. So I guess you'll have to change the link you mentioned to add that
id.

-- 
Ron Savage
r...@savage.net.au
http://savage.net.au/index.html



#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] New to working with CGI::App and OO perl. Testing under mod_perl. The old inconsistent data with reloads problem.

2009-03-19 Thread Ron Savage
Hi Derek

Michale has answered your question, so I just say the same thing
differently.

(After all, remeber that joke: We're all going down the same road in
different directions...)

On Thu, 2009-03-19 at 08:35 -0700, Derek Walker wrote:
 I'm writing a very basic app under apache + mod_perl.
 
 I've made the super vanilla instance script and application module.
 
 =
 #!/usr/bin/perl
 use lib '/var/www/html/infra';
 use Physical;
 
 my $app = Physical-new();
 $app-run();

Or, even better:

Physical - new() - run()

since $app is never used in any meaningful way.

Years ago I proposed a doc patch on this very issue...

 I'm running into the old chestnut of a problem of how to properly
 'wrap' a perl application under mod_perl to avoid the shared global
 variable issue (that I only partially understand at this point)

To me this is a design problem, not a coding problem.

Of course it matters what you mean by 'wrap', but I'd suggest stop
thinking in terms of wrapping and start thinking in terms of re-design.

 Reading from a couple of books and web sites I can see the basics of
 how to wrap things to avoid this collision, but I can't quite make it
 work for my basic test app.

Vague guideline:

o Create Physical object.

o In its constructor, create db handle etc which are local to the
Physical object.

o Hence, let the lifetime of the Physical object control the lifetime of
that object's attributes.


-- 
Ron Savage
r...@savage.net.au
http://savage.net.au/index.html



#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####