[Catalyst] Test::WWW::Mechanize::Catalyst and is_base()

2007-11-06 Thread Chisel Wright
I've recently started Doing The Right Thing and have starting fleshing
out the test suite for one of my projects.

In the last day or three I've added Test::WWW::Mechanize::Catalyst based
tests.

I seem to be having a problem with the value set for base in the
tests; I'm using:

  base href=[%c.req.base%] /

and all of my links are of the form:

  a href=somewhere/interesting.../a

When I run the foo_server.pl script, viewing the page source reveals
that the base is (as expected) set to 'http://localhost:3000'.

When I'm running Mechanize based tests the base appears to always be set
to the URL that's being requested. This causes problems with things like
$mech-links_ok().

I've had no day-to-day problems using base and relative hrefs; I went
this route because I didn't want to have to add [%c.req.base%] to
_every_ URL in the app.

It's fairly easy to reproduce with a small catalyst application, and
I've all written a test for Test::WWW::Mechanize::Catalyst that
demonstrates the behaviour I'm having trouble with.
I don't know where the problem originates, but this seemed to be the
easiest place to demonstrate it.

As far as I can tell, all of the relevant modules are up-to-date:
  Module  = Test::WWW::Mechanize (PETDANCE/Test-WWW-Mechanize-1.16.tar.gz)
  Module  = Test::WWW::Mechanize::Catalyst 
(LBROCARD/Test-WWW-Mechanize-Catalyst-0.41.tar.gz)
  Module  = WWW::Mechanize (PETDANCE/WWW-Mechanize-1.32.tar.gz)
  Module  = Catalyst (MRAMBERG/Catalyst-Runtime-5.7011.tar.gz)

Also all /^Catalyst/ extras are up-to-date.

Does anyone have any idea if this is a bug, or if I'm just going about
things the wrong way?

Chisel

 cut here 
$ catalyst.pl BaseTag
$ ./script/basetag_create.pl controller Lemon
$ ./script/basetag_create.pl view TT TT
$ vi lib/BaseTag/Controller/Lemon.pm

sub juice :Local {
my ($self, $c) = @_;
}

$ mkdir -p root/base/lemon
$ vi root/base/lemon/juice.tt

?xml version=1.0?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

html
head
base href=[%c.req.base%] /
title[%c.req.base%]/title
/head
body
[%c.req.base%]
/body
/html

$ vi t/00.base.t

use Test::More tests = 3;
use_ok( 'Test::WWW::Mechanize::Catalyst', 'BaseTag' );
my $mech = Test::WWW::Mechanize::Catalyst-new;
$mech-get_ok(http://localhost/lemon/juice;, 'Got lemon/juice');
$mech-base_is('http://localhost/');

$ CATALYST_DEBUG=0 ./script/basetag_test.pl /lemon/juice |grep 'base'
base href=http://localhost/; /

$ CATALYST_DEBUG=0 prove -l ./t/00.base.t
./t/00.baseok 1/3
#   Failed test at ./t/00.base.t line 5.
#  got: http://localhost/lemon/juice;
#   length: 28
# expected: http://localhost/;
#   length: 17
# strings begin to differ at char 18
./t/00.baseNOK 3/3# Looks like you failed 1 test of 3.   
./t/00.basedubious   
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 3
Failed 1/3 tests, 66.67% okay
Failed Test   Stat Wstat Total Fail  List of Failed
---
./t/00.base.t1   256 31  3
Failed 1/1 test scripts. 1/3 subtests failed.
Files=1, Tests=3,  1 wallclock secs ( 1.07 cusr +  0.15 csys =  1.22 CPU)
Failed 1/1 test programs. 1/3 subtests failed.
 cut here 
-- 
Chisel Wright
e: [EMAIL PROTECTED]
w: http://www.herlpacker.co.uk/

  It's like ingenuity wrapped in stupidity wrapped in a function.


bug-base-tag.t
Description: Troff document
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Selective debug output

2007-11-06 Thread Joe Landman
How do I selectively enable or disable debugging output?  Specifically, 
FormBuilder debugging output is simply far to verbose to be meaningful 
to us.  I suppose I could simply pass in a debug=0 when I create the 
form.  Is there any global way?


FWIW:  I only want to surpress formbuilder output during debug.


--
Joe Landman
[EMAIL PROTECTED]

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Selective debug output

2007-11-06 Thread Jonathan Rockway
Joe Landman wrote:
 How do I selectively enable or disable debugging output? 
 Specifically, FormBuilder debugging output is simply far to verbose to
 be meaningful to us.  I suppose I could simply pass in a debug=0 when
 I create the form.  Is there any global way?

 FWIW:  I only want to surpress formbuilder output during debug. 

Unfortunately there is no way to do what you want.  Most of the plugins
(etc.) just check $c-debug to see whether or not to log via
$c-log-debug.  I suggest a filter in a custom log class (just regex
the formbuilder crap out), or fixing the plugins/controllers to check
$c-config-{pluginname_debug) or something.  Maybe we can make this
easier in 5.8; suggestions welcome.

Regards,
Jonathan Rockway






signature.asc
Description: OpenPGP digital signature
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Selective debug output

2007-11-06 Thread J. Shirley
On Nov 6, 2007 5:47 PM, Jonathan Rockway [EMAIL PROTECTED] wrote:

 Joe Landman wrote:
  How do I selectively enable or disable debugging output?
  Specifically, FormBuilder debugging output is simply far to verbose to
  be meaningful to us.  I suppose I could simply pass in a debug=0 when
  I create the form.  Is there any global way?
 
  FWIW:  I only want to surpress formbuilder output during debug.

 Unfortunately there is no way to do what you want.  Most of the plugins
 (etc.) just check $c-debug to see whether or not to log via
 $c-log-debug.  I suggest a filter in a custom log class (just regex
 the formbuilder crap out), or fixing the plugins/controllers to check
 $c-config-{pluginname_debug) or something.  Maybe we can make this
 easier in 5.8; suggestions welcome.

 Regards,
 Jonathan Rockway





I would prefer something like:
MyApp-config(
'PluginName' = { debug = 0 }
);

Thoughts?

-- 
J. Shirley :: [EMAIL PROTECTED] :: Killing two stones with one bird...
http://www.toeat.com
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] A question on persistence with sessions or similar

2007-11-06 Thread Joe Landman

Hi Folks:

  Here is what I want to do.  I want to preserve values of stuff across 
the life of a session, without having to jump through hoops to do it.  I 
want it to survive redirects in the app.  It would be nice if it were 
just like stash.


  Really, it is very simple.  And I thought I had it.

$c-flash

as part of C::P::Sessions, C::P::Sessions::Store::FastMmap and 
C::P::Sessions::State::Cookie says it preserves state across redirects. 
 You have to touch the values at each instance (and since this is in 
the middle of a bunch of forms that might be suspect).


  Unfortunately, I am noticing lots of dropouts of state.  Values go 
missing and all that.  The session ids are preserved.  The state is not.


  Rather than jamming this all into a cookie, I would like a server 
side version that just works.  I am awful close to using a 
quick-n-dirty DB for this explicitly, using the session_id as a key.


  I am assuming it is massive pilot error on my part, but I am having 
trouble finding it.  I get the same behavior with 
C::P::Sessions::Store::File as I do with FastMmap.  Any thoughts?  Is 
the state working perfectly for others?  If so, are you using FastMmap? 
 Are you using Cache?


  Finally as an RFE for 5.8, it would be really, really nice if there 
was a $c-sessionstash that worked just like stash.  Stash is great, 
things that work like stash are great.


--
Joe Landman
[EMAIL PROTECTED]

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] A question on persistence with sessions or similar

2007-11-06 Thread Peter Karman


Joe Landman wrote on 11/6/07 9:40 PM:
 Hi Folks:
 
   Here is what I want to do.  I want to preserve values of stuff across
 the life of a session, without having to jump through hoops to do it.  I
 want it to survive redirects in the app.  It would be nice if it were
 just like stash.
 
   Really, it is very simple.  And I thought I had it.
 
 $c-flash
 


 $c-session


That does what you describe.

-- 
Peter Karman  .  http://peknet.com/  .  [EMAIL PROTECTED]

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] A question on persistence with sessions or similar

2007-11-06 Thread Andrew Rodland
On Tuesday 06 November 2007 09:40:01 pm Joe Landman wrote:
 Hi Folks:

Here is what I want to do.  I want to preserve values of stuff across
 the life of a session, without having to jump through hoops to do it.  I
 want it to survive redirects in the app.  It would be nice if it were
 just like stash.

Really, it is very simple.  And I thought I had it.

   $c-flash

 [...]

Finally as an RFE for 5.8, it would be really, really nice if there
 was a $c-sessionstash that worked just like stash.  Stash is great,
 things that work like stash are great.


There is. It's called session. Flash works like session except that stuff 
disappears after the first time you read it -- thus the mysterious data 
dropouts.

Andrew

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Selective debug output

2007-11-06 Thread Jonathan Rockway
J. Shirley writes:
 I would prefer something like:
 MyApp-config(
 'PluginName' = { debug = 0 }
 );

 Thoughts?

Nice.  But maybe do Plugin::PluginName to avoid namespace collisions.

I wonder how we can best make this approach standard though...

If I were nothingmuch, I would do caller magic to determine which module
is calling $c-debug, and then return true or false accordingly.  Maybe
I will try this out as a plugin, actually :)  Evil, but it will hack
around broken plugins and Just Work :)

Regards,
Jonathan Rockway



signature.asc
Description: OpenPGP digital signature
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] A question on persistence with sessions or similar

2007-11-06 Thread Joe Landman

Jonathan Rockway wrote:

Just out of curiosity, what documentation lead you in this direction? 
flash doesn't get much mention officially, I don't think.


http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-0.19/lib/Catalyst/Plugin/Session.pm

For some reason, session didn't work the first time I played with it.

It is behaving nicely now.  So I read the rest of the documentation, and 
there, right under sessions is a little discussion on flash ...


... to my fevered brain, it seemed like approximately what I wanted to do.

--
Joe Landman
[EMAIL PROTECTED]

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] A question on persistence with sessions or similar

2007-11-06 Thread Jonathan Rockway
Joe Landman wrote:

 There is. It's called session. Flash works like session except that
 stuff disappears after the first time you read it -- thus the
 mysterious data dropouts.

 Yup.  Pilot error.  s/flash/session/g  works the way I want.  Thanks.


Just out of curiosity, what documentation lead you in this direction? 
flash doesn't get much mention officially, I don't think.

Regards,
Jonathan Rockway



signature.asc
Description: OpenPGP digital signature
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Selective debug output

2007-11-06 Thread Bill Moseley
On Tue, Nov 06, 2007 at 07:47:11PM -0600, Jonathan Rockway wrote:
 Joe Landman wrote:
  How do I selectively enable or disable debugging output? 
  Specifically, FormBuilder debugging output is simply far to verbose to
  be meaningful to us.  I suppose I could simply pass in a debug=0 when
  I create the form.  Is there any global way?
 
  FWIW:  I only want to surpress formbuilder output during debug. 
 
 Unfortunately there is no way to do what you want.  Most of the plugins
 (etc.) just check $c-debug to see whether or not to log via
 $c-log-debug.  I suggest a filter in a custom log class (just regex
 the formbuilder crap out), or fixing the plugins/controllers to check
 $c-config-{pluginname_debug) or something.  Maybe we can make this
 easier in 5.8; suggestions welcome.

Can't you limit what packages generate logging using log4perl?


-- 
Bill Moseley
[EMAIL PROTECTED]


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/