Re: [Catalyst] RE: DBIC - JSON conversion for AJAX

2011-09-14 Thread Ronald J Kimball
On Wed, Sep 14, 2011 at 11:44 AM, Roland Philibert rphilib...@aptina.comwrote:

 I did try what you suggest as per:
 sub thing_GET {

my ($self, $c) = @_;
 $self-status_ok(
$c,
entity = $rs =
 $c-model('DB::data)-search({},{result_class =
 'DBIx::Class::ResultClass::HashRefInflator',})-all
);
 }
 ...but the json rest object was showing just the number of row retrieved
 ie: {rest:80}


That is not quite what Ian suggested.  Scalar assignment (i.e. $rs =)
provides scalar context to the right-hand side, so you're calling all() in
scalar context, so you get the number of elements.  Also, the assignment to
$rs is misleading, as you're not actually assigning a ResultSet object to
it, but rather the result of calling -all() on a ResultSet.

Try one of these approaches instead, which all do the same thing in slightly
different ways.  Ian's original suggestion:

@arr = $c-model('DB::data)-search({},{result_class
= 'DBIx::Class::ResultClass::HashRefInflator',});
...
  entity = \@arr
...

or, with an anonymous array instead of a temporary array variable:

...
  entity = [$c-model('DB::data)-search({},{result_class
= 'DBIx::Class::ResultClass::HashRefInflator',})]
...

or, assigning the ResultSet to $rs first:

$rs = $c-model('DB::data)-search({},{result_class
= 'DBIx::Class::ResultClass::HashRefInflator',});
...
  entity = [$rs-all],
...

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


Re: [Catalyst] Semi-OT testing question

2011-06-10 Thread Ronald J Kimball
On Fri, Jun 10, 2011 at 11:10 AM, Jesse Sheidlower jes...@panix.com wrote:


 ok( $mech_admin-tick('roles','2'), ticked the newwords_admin checkbox );



 The only thing failing here is the _test_ in the first line of this. The
 form is submitted correctly, and when I test the view page for this
 newly-created user, it has the correct role.

 Similarly, for my edit test, I untick this role, tick a different
 role, and the results are correct. But both ok tests for the unticking
 and ticking, fail.

 What's wrong with my test here?


WWW::Mechanize-tick() and WWW::Mechanize-untick() don't return anything on
success.  They call WWW::Mechanize-warn() if the referenced checkbox does
not exist.

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


[Catalyst] Fatal errors in chained actions

2011-04-07 Thread Ronald J Kimball
I was surprised to discover that when a chained action throws a fatal
error, Catalyst continues executing the remaining actions in the
chain.  Personally, I had assumed that each action in the chain could
depend on the preceeding actions having been executed successfully.

I've looked at the code in Catalyst::ActionChain, Catalyst::Action,
and Catalyst, so I see how this happens, but I'm not sure it's what
should happen.  Is this the desired behavior?


Here's an example:

sub root : Chained('/') PathPart('chain') CaptureArgs(0) {
  my ($self, $c) = @_;

  die Oops!;

  $c-stash-{'greeting'} = 'Hello';
}

sub node : Chained('root') PathPart('') CaptureArgs(0) {
  my ($self, $c) = @_;

  die Oops!;

  $c-stash-{'name'} = 'world';
}

sub test : Chained('node') PathPart('') Args(0) {
  my ($self, $c) = @_;

  $c-stash-{'message'} =
$c-stash-{'greeting'} . ' ' . $c-stash-{'name'} . '!';

  $c-res-body($c-stash-{'message'});
}


Use of uninitialized value in concatenation (.) or string at
lib/ChainTest/Controller/Root.pm line 67.
Use of uninitialized value in concatenation (.) or string at
lib/ChainTest/Controller/Root.pm line 67.
[info] *** Request 1 (1.000/s) [19323] [Thu Apr  7 13:52:19 2011] ***
[debug] GET request for chain from 127.0.0.1
[debug] Path is /test
[error] Caught exception in ChainTest::Controller::Root-root Oops!
at lib/ChainTest/Controller/Root.pm line 51.
[error] Caught exception in ChainTest::Controller::Root-node Oops!
at lib/ChainTest/Controller/Root.pm line 59.
[debug] Response Code: 500; Content-Type: text/html; charset=utf-8;
Content-Length: 7078
[info] Request took 0.028427s (35.178/s)
.+---.
| Action | Time  |
++---+
| /root  | 0.000252s |
| /node  | 0.000113s |
| /test  | 0.000216s |
| /end   | 0.000469s |
'+---'


The test() action assumes that $c-stash-{'greeting'} and
$c-stash-{'name'} have been set.  In this example it's fairly
innocuous, but what if test() was doing something like updating a
database based on those supposed values?

Ronald

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


Re: [Catalyst] Re: How to get uri_for something with a fragment?

2011-03-08 Thread Ronald J Kimball
On Mon, Mar 7, 2011 at 6:20 PM, Ashley Pond V a...@sedition.com wrote:
 2011/3/7 Adam Sjøgren a...@koldfront.dk:
 On Mon, 7 Mar 2011 13:01:42 -0800, Ashley wrote:

 What Ronald said + the #fragment is not passed along in the available
 ENV with some servers and setups. In these cases it doesn't exist as
 far as the backend is concerned. If you rely on it for dispatch, you
 may get burned.

 Uhm, the _browser_ handles fragments. Browsers don't send them to the
 server _at all_.

 Nice. I didn't want to blanket it with a 100% of the time in all
 clients/servers this won't work because I was not sure.

Fortunately, John never said he wanted the fragment to be passed back
to the server.  You're saying this won't work to something that was
never proposed in the first place.

Ronald

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


Re: [Catalyst] Re: How to get uri_for something with a fragment?

2011-03-08 Thread Ronald J Kimball
On Tue, Mar 8, 2011 at 11:27 AM, Ashley Pond V a...@sedition.com wrote:

 Well, the original message was:

 How do I call uri_for_action and pass it the '#id' part? It's not an arg 
 and it's not part of the query string. This is called the fragment 
 identifier in the final URL.

 uri_for_action makes it implicit that he was seeking a server side use
 of the fragment.

No, it does not.  He was simply creating a URL, with a fragment, that
will be included in the body of the response so the user can click on
it in the browser.

Ronald

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


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ronald J Kimball
On Sun, Mar 6, 2011 at 6:46 AM, John M. Dlugosz wxju46g...@snkmail.com wrote:
  On 3/6/2011 5:28 AM, Andrew Rodland andrew-at-cleverdomain.org
 |Catalyst/Allow to home| wrote:

 Or, since you know that what it generates *doesn't* have a fragment you could
 always just $c-uri_for_action(...) . '#id' which will be perfectly valid
 (although no longer a URI object).

 I considered that a hack until I knew better, since it won't work if there
 are query arguments.

Why won't it work if there are query arguments?  Seems correct to me.

Ronald

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


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ronald J Kimball
On Mon, Mar 7, 2011 at 2:35 PM, Ashley Pond V a...@sedition.com wrote:

 Using the fragment is probably a bad idea. It's not supported by all
 servers so it can end up lost on the backend depending on your setup.

I can't figure out what you mean by this.  This is a URL that will be
included in the body of a response.  How is the server involved at
all?

Ronald

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


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ronald J Kimball
On Mon, Mar 7, 2011 at 3:25 PM, John M. Dlugosz wxju46g...@snkmail.com wrote:
  On 3/7/2011 1:35 PM, Ashley Pond V apv-at-sedition.com |Catalyst/Allow to
 home| wrote:

 Using the fragment is probably a bad idea. It's not supported by all
 servers so it can end up lost on the backend depending on your setup.

 I've never heard of a web server that didn't have fragments.  I link to
 anchors all the time!

No, really, that's meaningless.  Fragments are handled by the user
agent, not by the server.

http://tools.ietf.org/html/rfc3986#section-3.5

Ronald

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


Re: [Catalyst] Cache of unchanging content

2011-03-02 Thread Ronald J Kimball
On Wed, Mar 2, 2011 at 12:43 AM, John M. Dlugosz wxju46g...@snkmail.com wrote:

 As for reaching for templates in CSS:  Sure, you can break common lines into
 different tags so you only specify a color once:

    #this, #that, div p .theother { color: x }

 but that doesn't help making (say) a border color and a background color the
 same value.

Have you considered using LESS?  http://lesscss.org/

Ronald

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


Re: [Catalyst] Catalyst Git Conversion

2011-02-14 Thread Ronald J Kimball
On Sat, Feb 12, 2011 at 3:45 AM, fREW Schmidt fri...@gmail.com wrote:


 #1: is it correct that the svn user rjk is Ronald J Kimball 
 r...@linguist.dartmouth.edu ?


That email address is no longer active.  Please use r...@tamias.net instead.
My github username is tamias.

I'm excited to have Catalyst in git!

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


Re: [Catalyst] Re: Converting a GET request to a POST request

2010-11-29 Thread Ronald J Kimball
On Fri, Nov 26, 2010 at 3:02 PM, Aristotle Pagaltzis pagalt...@gmx.de wrote:
 * Ronald J Kimball rkimb...@pangeamedia.com [2010-11-23 18:00]:
 REST principles dictate that I use POST, not GET, for these
 requests. The same-origin policy forces me to use JSONP, which
 can only make GET requests, not POST. What's the solution?

 “You can’t get there from here”: you can’t use Javascript to make
 unsafe requests outside the origin.

 mstStep back./mst What are you actually trying to do?

 I could imagine that eg. an OAuth-based solution could work
 (wherein the user hands other sites an auth token from you, and
 the sites use that token to make requests to your site on their
 users’ behalf). Or maybe it’s too complicated or overkill for
 you – that depends on your aim and constraints.

 So tell us about them.

This is for a widget that will be hosted on third party websites.  The
widget will allow users of those sites to interact with our content.
The widget will be written in JavaScript and HTML.  The widget will
retrieve content and submit user interactions using Ajax and JSONP
(supposedly via a REST API :).  Users will not be required to log in
to interact with the content in the widget.

Thank you for your feedback.  Some of this is new territory for me, so
being steered away from doing things the wrong way is very helpful.

Ronald

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


Re: [Catalyst] Converting a GET request to a POST request

2010-11-23 Thread Ronald J Kimball
On Mon, Nov 22, 2010 at 7:33 PM, Tomas Doran bobtf...@bobtfish.net wrote:

 On 22 Nov 2010, at 18:28, Ronald J Kimball wrote:

 It doesn't care what the request method is, as long as it's POST, PUT,
 OPTIONS, or DELETE.  ;)

 No, it just doesn't care.

 If I create Catalyst::Action::Deserialize::JSONP, I'll still need to
 convert the GET request to a POST.  That seems to be the really tricky
 part.

 Why? Where is the code which forces it to be a POST?

In Catalyst::Action::Deserialize:

sub execute {
my $self = shift;
my ( $controller, $c ) = @_;

my @demethods = qw(POST PUT OPTIONS DELETE);
my $method= $c-request-method;
if ( grep /^$method$/, @demethods ) {
my ( $sclass, $sarg, $content_type ) =
  $self-_load_content_plugins( 'Catalyst::Action::Deserialize',
$controller, $c );
return 1 unless defined($sclass);
my $rc;
if ( defined($sarg) ) {
$rc = $sclass-execute( $controller, $c, $sarg );
} else {
$rc = $sclass-execute( $controller, $c );
}
if ( $rc eq 0 ) {
return $self-_unsupported_media_type( $c, $content_type );
} elsif ( $rc ne 1 ) {
return $self-_serialize_bad_request( $c, $content_type, $rc );
}
}

$self-maybe::next::method(@_);

return 1;
}


Ronald

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


Re: [Catalyst] Re: Converting a GET request to a POST request

2010-11-23 Thread Ronald J Kimball
On Mon, Nov 22, 2010 at 3:12 PM, Aristotle Pagaltzis pagalt...@gmx.de wrote:
 This is really, really, really bad. It’s roughly like modifying
 a file system to be allow file deletion as a side effect of
 opening a file. GET is supposed to be safe, that is, it should be
 free of side effects that the user cannot be held responsible
 for. It is very, very easy to get a browser to send GET requests
 incidentally, eg. by putting the link in a `img src` or
 a stylesheet `link` and getting a user to visit. Things like
 Google Web Accelerator and other automated user agents (like
 search engines of course) also generally assume that GET is safe.
 Much web infrastructure also assumes that GET requests are
 cacheable, so if there are any proxies between the app and the
 user, sending multiple pseudo-POST requests may not actually do
 anything.

I completely understand the points you're making here.  As I said, one
of the drawbacks of this solution is that it makes me feel really
dirty.

For what it's worth, the REST methods that I want to expose in this
way are for posting responses to content.  There won't be any deletes.


 The same-origin policy is not there by mistake, but to keep your
 users safe from malicious 3rd party sites they may visit.

REST principles dictate that I use POST, not GET, for these requests.
The same-origin policy forces me to use JSONP, which can only make GET
requests, not POST.  What's the solution?


Ronald

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


Re: [Catalyst] Converting a GET request to a POST request

2010-11-22 Thread Ronald J Kimball
On Mon, Nov 22, 2010 at 12:53 PM, Tomas Doran bobtf...@bobtfish.net wrote:

 On 22 Nov 2010, at 17:44, Ronald J Kimball wrote:

 This works for JSON requests (e.g. application/json), but not for
 JSONP requests (e.g. text/javascript), because there is no
 Catalyst::Action::Deserialize::JSONP.  I guess I could create one that
 extends Catalyst::Action::Deserialize::JSON...

 Yes, that's a more correct solution.
 http://cpansearch.perl.org/src/BOBTFISH/Catalyst-Action-REST-0.87/lib/Catalyst/Action/Deserialize/JSON.pm
 Catalyst::Action::Deserialize::JSON reads out of the body (but it doesn't
 care what the request method is - you can PUT instead of POST for example).
 So do that, and you have no more issues?

It doesn't care what the request method is, as long as it's POST, PUT,
OPTIONS, or DELETE.  ;)

If I create Catalyst::Action::Deserialize::JSONP, I'll still need to
convert the GET request to a POST.  That seems to be the really tricky
part.

Ronald

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


Re: [Catalyst] Catalyst::Test local_request(), Test::WWW::Mechanize::Catalyst, and base href=...

2010-08-04 Thread Ronald J Kimball
On Mon, Aug 2, 2010 at 5:56 PM, Tomas Doran bobtf...@bobtfish.net wrote:

 On 29 Jul 2010, at 21:40, Ronald J Kimball wrote:

 The only reference I found to this issue is a post to this mailing list
 from 2007, which no one answered.  Has anyone else experienced this problem?
  Would a patch that cribs some code from LWP::UserAgent and puts it in
 Catalyst::Test local_request() be accepted?

 Yes.

 Please hop onto irc, grab a commit bit and make a branch!

I've created the Catalyst-Test-base-href branch and commited my
changes.  I'm ready for feedback.  Any particular next step I need to
take?

Ronald

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


[Catalyst] Catalyst::Test local_request(), Test::WWW::Mechanize::Catalyst, and base href=...

2010-07-29 Thread Ronald J Kimball
I've recently been working on writing tests for a Catalyst app using
Test::WWW::Mechanize::
Catalyst.  Unfortunately, I've hit a snag; Catalyst::Test's local_request()
method (which is used by Test::WWW::Mechanize::Catalyst) does not parse the
base href=... tag in the content of the response.  This means that the
Mechanize object can't follow links properly.

The documentation for $r-base in HTTP::Response states:

   The base URI is obtained from one the following sources (in
   priority order):

   1.  Embedded in the document content, for instance BASE
   HREF=... in HTML documents.

   ...

   When the LWP protocol modules produce the HTTP::Response object,
   then any base URI embedded in the document (step 1) will already
   have initialized the Content-Base: header. This means that this
   method only performs the last 2 steps...

Looking inside LWP::UserAgent, I see that it does indeed have code that uses
HTML::HeadParser to parse the html head and set headers in the response
accordingly.

However, Catalyst::Test does not use LWP::UserAgent in local_request(), and
it doesn't use HTML::HeadParser itself, so it's not setting the response's
content-base header for the base href=... tag.


I've attached a test app with test files to demonstrate the problem.  (The
app is just the initial app created by catalyst.pl, with a simple test
action added that inserts a base href=... tag into the welcome message.
Also, I deleted the images to make the attachment smaller.)


Test fails with Catalyst::Test doing local_request():

% perl base_ct.t
ok 1 - GET /test
ok 2 - Got base href
# Base href = http://localhost/
not ok 3 - Response base matches base href
#   Failed test 'Response base matches base href'
#   at base_ct.t line 18.
#  got: 'http://localhost/test'
# expected: 'http://localhost/'
1..3
# Looks like you failed 1 test of 3.


Test succeeds with Catalyst::Test doing remote_request():

% CATALYST_SERVER=http://localhost:3000/ perl base_ct.t
ok 1 - GET /test
ok 2 - Got base href
# Base href = http://localhost:3000/
ok 3 - Response base matches base href
1..3


Using Test::WWW::Mechanize::Catalyst succeeds or fails in the same way.


The only reference I found to this issue is a post to this mailing list from
2007, which no one answered.  Has anyone else experienced this problem?
Would a patch that cribs some code from LWP::UserAgent and puts it in
Catalyst::Test local_request() be accepted?

Ronald


TestApp.tar.gz
Description: GNU Zip compressed data
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Including a submenu

2009-04-06 Thread Ronald J Kimball

toppe...@gmail.com wrote:


Then, I tried setting $page in my controllers, hoping to have the
submenu switches/menu.tt2, etc included.

However, when I load the page,  I get the following error:
Couldn't render template file error - /menu.tt2: absolute paths are
not allowed (set ABSOLUTE option)

Am I going missing something obvious, or going about this in the wrong
way?


Yes, you're missing the information that would allows us to diagnose the 
problem. :)


How did you set the value of $page?  Are you able to set the values of 
other variables successfully?


Ronald

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


Re: [Catalyst] catalystframework.org exired

2007-11-19 Thread Ronald J Kimball
According to the whois record, it appears the domain has already been 
renewed:


Domain ID:D108520399-LROR
Domain Name:CATALYSTFRAMEWORK.ORG
Created On:14-Nov-2005 14:17:32 UTC
Last Updated On:19-Nov-2007 14:17:38 UTC
Expiration Date:14-Nov-2008 14:17:32 UTC


It is stupid that they apparently can't allow a payment without putting 
the payer in control of the domain.


Ronald


Christopher H. Laco wrote:

Bernhard Weißhuhn wrote:

Oh no!

somebody renew catalystframework.org! Quick! Until *they* get it.

regards,
  bkw


Just called GoDaddy. This is so fucked up. They won't let anyone pay for
renewal who isn't the last person/card on file with the 4 digit pin or
the same credit card.

That's retarded. They say it's because the person who last paid for it
could move it and take control...aka, their system is fucking broken.

That just makes me want to find another registrar that isn't so broken.

:-(

-=Chris


___
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/