Re: [Catalyst] Please help to figure out with URL's

2014-12-04 Thread Larry Leszczynski

On Thu, Dec 4, 2014, at 12:41 PM, Trevor Leffler wrote:
> This is a typical use:
> 
>  rel="stylesheet">

Assuming you're using Template Toolkit, you should use the "url" filter,
not the "html" filter:

   


Larry

___
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] May be asynchronous communication between Catalyst applications

2013-03-04 Thread Larry Leszczynski
Hi -

On Sun, Mar 3, 2013, at 08:44 PM, linuxsupport wrote:
> I tried Catalyst::Plugin::RunAfterRequest, when I send request to the app,
> it returns fine but it does not accept any other request after that until that
> sub routine finishes.

By default the test server runs a single process, so that process will
complete the after-request work before accepting a new request to work
on.  You need to allow it to fork to run multiple processes:

myapp_server.pl -f


HTH,
Larry

___
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] Use of uninitialized value in delete

2012-10-27 Thread Larry Leszczynski
Hi Bill -

On Fri, Oct 19, 2012, at 11:37 AM, Bill Moseley wrote:

> Use of uninitialized value in delete
> 
> with a line number pointing to this line:
> 
> delete $c->stash->{foo};
> 
> I didn't think that delete() issued a warning,

Are both $c and $c->stash defined at that point?


Larry

___
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] [JOB] telecommute web developer

2011-09-01 Thread Larry Leszczynski
Hi -

We're looking to hire another full-time web developer to join a great
team, telecommute or local (central MN).

- Telecommute with occasional "face time" trips to MN
- Must have strong Perl skills
- Should have all the usual web dev skills (HTML, JS, CSS, AJAX, DHTML)
- Bonus points for skills in:
Catalyst
Moose
Template Toolkit
Rose::DB::Object
JS toolkits like ExtJS, jQuery, Prototype, YUI
PostgreSQL
- Great benefits

The official job post is at: http://jobs.perl.org/job/13544

Currently considering US residents.

For more information: www.atomiclearning.com

If you’re interested, contact: h...@atomiclearning.com


Thanks!
Larry

___
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] Force https in generated URIs

2011-08-04 Thread Larry Leszczynski
Hi t0m -

> On 4 Aug 2011, at 16:57, Larry Leszczynski wrote:
> 
> > Side question:  Is namespace::autoclean needed any more?
> 
> define 'needed'?
> 
> It's never 'needed' as long as you never want a 'has' method, and  
> you're happy with none of your imports being cleaned up, so all your  
> classes are lolcat like in their ability to ->can('has');
> 
> Cheers
> t0m

Thanks for the clarification - I had seen a fair amount of Moose code
that did *not* use namespace::autoclean, so wasn't sure if it was
something that had become automatically enabled or something.  I see now
in the best practices document that it is still recommended:

http://search.cpan.org/perldoc?Moose::Manual::BestPractices



Thanks!
Larry


___
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] Force https in generated URIs

2011-08-04 Thread Larry Leszczynski
Hi Tobias -

> Therefore I need to force all generated URIs to be https.

If generated URIs means those coming from $c->uri_for() and friends, you
should be able the modify the URI scheme in $c->request->base, which
gets used by uri_for().

Not tested but try something like the following.

HTH,
Larry

Side question:  Is namespace::autoclean needed any more?

==

package MyApp;

use Moose;

use namespace::autoclean;

BEGIN { extends 'AL::Catalyst::Base' }

with 'MyApp::Roles::Catalyst::IsOnlyHTTPS';

use Catalyst (...);

==

package MyApp::Roles::Catalyst::IsOnlyHTTPS;

use Moose::Role;

use namespace::autoclean;

after 'prepare_path' => sub {

my $c = shift;

$c->request->base->scheme('https');

# Might be necessary to keep request
# uri in sync with request base?
# Not sure...
#
#$c->request->uri->scheme('https');

return;
};

1;

==

___
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] Configuring Apache for mod_perl Catalyst and php via mod_proxy

2011-07-29 Thread Larry Leszczynski
Hi Matthew -

On Fri, 29 Jul 2011 12:25 +0100, "matthew couchman (JIC)"
 wrote:
> Thanks for your reply. Perhaps it was too sweeping a statement but I can
> only say that for my setup mod_perl works fine through Apache alone as
> does php but when I combine them it crashes with memory corruption
> errors.

Usually that means that your mod_perl and mod_php have been linked
against conflicting versions of the same system library or built with
conflicting compile options.  Make sure you have built them using the
same environment and config options.  You'll probably find more useful
info on the mod_perl mailing list than this list:

   http://perl.apache.org/maillist/modperl.html

On that page there are also links to searchable archives of the mod_perl
list, might find some info about your problem in there.


HTH,
Larry

___
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] [JOB] Looking for Telecommute Web Developer

2011-06-18 Thread Larry Leszczynski
Hi -

We're looking to hire another full-time web developer to join a great
team, telecommute or local (central MN).

- Telecommute with occasional "face time" trips to MN
- Must have strong Perl skills
- Should have all the usual web dev skills (HTML, JS, CSS, AJAX, DHTML)
- Bonus points for skills in:
Catalyst
Moose
Template Toolkit
Rose::DB::Object
JS toolkits like ExtJS, jQuery, Prototype, YUI
Postgresql
- Great benefits

The official job post is at: http://jobs.perl.org/job/13544

Currently considering US residents.

For more information: www.atomiclearning.com

If you’re interested, contact: h...@atomiclearning.com


Thanks!
Larry

___
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] [OT] Anybody else going to O'Reilly Velocity next week?

2011-06-10 Thread Larry Leszczynski
Hi all -

Just wondering if anybody else is planning to go to the O'Reilly
Velocity conference in Santa Clara next week - email me off-list and we
can make plans to meet up.


Thanks!
Larry

___
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] long poll AJAX

2011-06-07 Thread Larry Leszczynski
Hi Jeff -

> The problem seems to be a bottleneck in Catalyst, because as soon as
> the long poll completes all of the waiting status requests complete
> instantly as well. I had imagined that the threading on Catalyst would
> support the functionality I'm looking for.

Just a guess...  By any chance are you launching Catalyst by running the
myapp_server.pl script?  By default it starts up in single-threaded
mode.  You would need to add the "--fork" option to to make it fork a
new process for each request.


HTH,
Larry 

___
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] Static GET of an ogg audio file

2011-04-08 Thread Larry Leszczynski
Hi Jeff -

> I have created a directory called "media" in the path
> /root/static/media and put some audio files in there (happen to be
> ogg-vorbis). I am using the HTML5 tag  in the Firefox 4 browser
> to play the file in an app. It mostly works but there is a problem in
> that the browser cannot determine the tracks duration. (Ogg files do
> not store duration in their headers as other audio formats do, but
> that's not the issue here).
> 
> I set up a simple experiment where I took the same ogg audio file and
> simply served it as a straight file from Apache and Catalyst. So in
> one case the URL typed in to FF was  http://apacheURL/media/test.ogg
> and the other was http://catalystURL/static/media/test.ogg (both URLs
> are on the same LAN, no firewalls etc)
> 
> With Apache there were no issues,, with Catayst the file plays but the
> duration info is not present - (hence the "play cursor" is always hard
> against the right hand side of the play bar.)

What differences do you see when you look at the response headers,
especially Content-Type?


Larry

___
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] Force the session to be saved.

2011-03-30 Thread Larry Leszczynski
Hi Duncan -

On Wed, 30 Mar 2011 09:40 +0100, "Duncan Garland"
 wrote:
> > finalize_session (which writes the session to the DB) runs before
> > finalize_body (which writes the response to the client), so Catalyst
> > already does what you would like it to, and forcing a session write
> > before running the view is unlikely to help anything. I suspect
> > either your database isn't guaranteeing ordering, or the problem is
> > somewhere other than where you're looking.
> > 
> > Andrew
>
> Thanks. That's very useful and a bit depressing.

Is it possible you are seeing a race condition from other things being
loaded, maybe on the previous page?  A one point we had a similar thing
going on and realized that some static content (images, etc.) was
actually going through the app and triggering a session read/save.


Thanks!
Larry

___
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 Larry Leszczynski

> 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 have see fragments cause problems in server-side code that is naive
about URL handling, like splitting the string on "?" and assuming all
the stuff after the question mark is query params when it might in fact
include a fragment.

Since most (all?) of the URLs you see being passed around in Catalyst
code are actual URI objects (http://search.cpan.org/perldoc?URI), just
treat them as objects and use all the nice URI methods for manipulating
them and you'll be fine.


Larry

___
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] [JOB] Looking for Web Developer

2011-02-01 Thread Larry Leszczynski
Hi -

As previously posted, we're looking to hire a full-time web developer,
either in-house or telecommute.  The job is mostly Catalyst
development for our web apps with a fair amount of work on the client
side using ExtJS, jQuery, Prototype, etc.  The official job posting is
available at:

http://www.atomiclearning.com/k12/jobopps#web_developer

A few people who contacted me asked about what level of experience we
are looking for.  The listing says 2 or more years, but that is really
only a minimum - we are considering all experience levels (the more the
better in my opinion), and I would expect salary would be commensurate
with experience (but don't ask me for specifics, the HR people handle
all that stuff...).

Contact me OFF LIST (please) if you’d like more details or have any
specific questions.


Thanks!
Larry


___
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] [JOB] Looking for Web Developer

2011-01-26 Thread Larry Leszczynski
Hi -

We're looking to hire a full-time web developer at $work.  Contact me
OFF LIST (please) and I can send more details.  The basics:

- Local (central MN) or telecommute
- All the usual web dev skills (HTML, JS, CSS, AJAX, DHTML)
- Bonus points for skills in:
Catalyst
Moose
Template Toolkit
Rose::DB::Object
JS toolkits like ExtJS, jQuery, Prototype, YUI
Postgresql


Thanks!
Larry

___
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] Transferring control via root/auto

2010-12-08 Thread Larry Leszczynski
Hi -

On Wed, 08 Dec 2010 13:31 +, "Tomas Doran" 
wrote:
> 
> On 7 Dec 2010, at 16:11, Ben van Staveren wrote:
> 
> > You want to $c->detach('end') -- unless that's the default these  
> > days.
> 
> The end action will _always_ be run, there is no need to detach to the  
> end action.
> 
> However I'm not sure what doing $c->detach in auto will do (I guess  
> the same as returning 0 - i.e. stop further actions from running), but  
> I'm not sure - you should probably return 0 (to stop further dispatch)  
> rather than detaching in the auto action..

In situations like this I find this flow diagram helpful:

   http://dev.catalystframework.org/attachment/wiki/WikiStart/catalyst-flow.png

but I admit I am also not totally clear about how detach/go fit in...  
Maybe someone has an updated diagram (or can update this one)?


Thanks!
Larry

___
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] Forward on to other actions after removing first path segment?

2010-11-15 Thread Larry Leszczynski
Hi Dorian -

> OK, but the part that confuses me is why /foo doesn't resolve to  
> MyApp::Foo::index with ->go or ->visit.

Maybe this will help (I think in this case "index" works like
"default"):

   http://wiki.catalystframework.org/wiki/wikicookbook/safedispatchusingpath


HTH,
Larry

___
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] Question about Chained Controller

2010-11-15 Thread Larry Leszczynski
Hi Woosely Xu -

On Mon, 15 Nov 2010 10:32 +0800, "woosley. xu." 
wrote:
> I am still wondering why forward dose not working in my way, and I
> just find detach('login') works good.

Because forward() returns to the action from which it was called, and
detach() does not:

   
http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80029/lib/Catalyst.pm#REQUEST_FLOW_HANDLING

So even though you are forwarding to your login() method, upon return it
will continue processing your get() method.


HTH,
Larry

___
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] Running system commands under FastCGI with IPC::Cmd / IPC::Run

2010-10-26 Thread Larry Leszczynski
Hi Ian -

> On 10/21/2010 2:43 PM, Ian Sillitoe wrote:
> >
> > This works under the test server, but throws the following error
> > under FastCGI:
> >
> > |"Can't locate object method "FILENO" via package "FCGI::Stream" at 
> > /home/ian/perl5/lib/perl5/IPC/Run.pm line 1115.

On Thu, 21 Oct 2010 15:29 -0400, "Stuart Watt" 
wrote:
> 
> You may want to check your version of FCGI. There are previous reports
> of related issues, which seem to be an interaction between IPC::*
> modules expectations of standard input/output/error, and FCGI, which
> fakes them. See
> http://www.mail-archive.com/po...@openbsd.org/msg16948.html for an
> example. In my FCGI, the FILENO method is present, but this appears to
> have been added in version 0.67_01 on 20 Dec 2009 - this is pretty
> recent and your Perl may not include it.

If you can't upgrade (or upgrading doesn't fix things), you can also do
something like this before the IPC call:

# HACK HACK HACK
# Fix for running IPC::Run under FastCGI
# See: http://www.mail-archive.com/po...@openbsd.org/msg16948.html
#
unless (exists &FCGI::Stream::FILENO)
{
*FCGI::Stream::FILENO = sub { return -2 };
}


HTH,
Larry

___
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] New install getting "Wide character in syswrite" error

2010-09-22 Thread Larry Leszczynski
Hi Charlie -

> once the problem starts the test server won't respond to any further
> requests; requires a restart. Canceling the current request results in
> following error:
> 
> Caught exception in engine "Wrong Content-Length value: 52"

May be totally related but I have seen those symptoms when the body of a
POST request gets read earlier in the request than usual, and then looks
empty when it is supposed to be read (so the Content-Length is zero
instead of whatever it should be).  In my case I was calling
$c->req->param inside prepare_path, and it seemed like it was sucking in
the whole POST body, leaving it empty for when it needed to be accessed
later.


HTH,
Larry

___
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] Make the money format macro globally available.

2010-09-21 Thread Larry Leszczynski
Hi Duncan -

On Tue, 21 Sep 2010 17:52 +0100, "Duncan Garland"
 wrote:
> How do you make the money macro available in all templates?
> 
> [% USE money=format('%.2f') -%]
> 
> Presumably something goes in here:
> 
> __PACKAGE__->config(
> TEMPLATE_EXTENSION => '.tt',
> render_die => 1,
> WRAPPER => 'wrapper.tt',
> );

You can put commonly used macros, formats, etc. in a file named e.g.
"pre_process_config.tt" in your main templates directory, then add
"PRE_PROCESS" to your config:


  __PACKAGE__->config(
  TEMPLATE_EXTENSION => '.tt',
  render_die => 1,
  WRAPPER => 'wrapper.tt',
  PRE_PROCESS => 'pre_process_config.tt'.
  );


HTH,
Larry

___
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] Forcing charset=utf-8 on all Content-Types for Catalyst::Controller::REST

2010-07-26 Thread Larry Leszczynski
Hi Dave -

> After searching google, and reading through all of the relevant
> documentation, and a considerable portion of the code, we have been
> unable to locate the correct place to set or override the Content-Type
> header to append a "charset=utf-8" string, required by our caching proxy
> to properly handle the encoding.  We would like a place to handle all
> mimetypes, so that our JSON, JSONP, and XML interfaces all get the
> correct charset set.

If you're sure all your content actually is utf-8, one way is to
subclass Catalyst::View and do something like:

after process => sub {

my ($self, $c) = @_;

my $ct = $c->response->content_type;

if ($ct)
{
$ct =~ s/;\s*charset=.*//i;
$ct .= '; charset=utf-8';
}
else
{
$ct = 'text/html; charset=utf-8';
}

$c->response->content_type($ct);
};


Thanks!
Larry

___
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] Contributing code

2010-06-21 Thread Larry Leszczynski

> Have you read http://wiki.catalystframework.org/wiki/contrib ?

To whom it may concern:  This URL is currently (Jun. 21, 15:22:18 UTC)
returning a 500 server error.


Larry

___
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] Alternatives to Catalyst ?

2010-04-21 Thread Larry Leszczynski

On Wed, 21 Apr 2010 20:30 +0400, "Oleg Pronin" 
wrote:
> 
> 1) Getting all params 3x faster than only one
> 2) Getting $req->{parameters}{lang} 150x faster than $req->param('lang')

What a surprise: accessing the hash directly is faster than calling a
function that accesses the hash.  Plus, the docs state that
$req->param() is considered a legacy interface to provide CGI.pm
compatibility, and if you look at the source it's obvious it has to do
extra work to make it work like CGI.pm.  If you don't need that, don't
use it.


___
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 forward to a specific path

2010-01-01 Thread Larry Leszczynski
Hi Julien -

On Fri, 01 Jan 2010 14:26 -0800, "Julien Sobrier" 
wrote:

> Hello, I'm try to do a forward to a path rather than a controller. For
> example, if I get the url /foo/my/path, I want to redirect it to
> /my/path which belongs to a different controller.

In general you should be able to forward() to a path, not sure what is
going on in your case without seeing the error message.  But forwarding
to a path can get confused if that path is handled by a default action,
if that is the case then this might help:

   http://dev.catalyst.perl.org/wiki/wikicookbook/safedispatchusingpath


HTH,
Larry

___
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] Partial page cache plugin

2009-12-07 Thread Larry Leszczynski

On Sun, 06 Dec 2009 19:07 -0600, "Peter Karman" 
wrote:
> Julien Sobrier wrote on 12/6/09 2:04 AM:
> > Hello,
> > there is a plugin for caching an entire page.  I am looking for the same
> > type of plugin to cache part of the page, but did not find one. Waht is the
> > best way to achieve this in Catalyst?
> > 
> 
> If you are using Template Toolkit,
> 
> http://search.cpan.org/dist/Template-Plugin-Cache/

Agree, this will do what you want.  To have it use your Catalyst cache,
just do something like this:

   USE cache = Cache('cache' => c.cache);

You can use it to cache either a whole page or just part of one, since
you can "cache.inc()" or "cache.proc()" to INCLUDE or PROCESS any
template (or BLOCK? not sure...) from inside another one.


Larry

___
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] Request

2009-10-27 Thread Larry Leszczynski
Hi Octavian -

On Tue, 27 Oct 2009 23:16 +0200, "Octavian Râsnita" 
wrote:
> From: "Larry Leszczynski" 
> > Hi Octavian -
> >
> >> Is there a Catalyst Request method for getting the path and the
> >> query_string? (Everything's after the base).
> >>
> >> I want to use it in a TT template for changing the current language.
> >>
> >> The current URI is something like:
> >> http://www.site.com/prg?var1=val1&var2=val2
> >>
> >> The base for this URI is:
> >> http://www.site.com/en/
> >> (Because I overwritten prepare_path as in the example given on the Cat
> >> wiki)
> >>
> >> and the URL that should be printed with the new language is:
> >> http://www.site.com/ro/prg?var1=val1&var2=val2
> >
> > Not sure if this gets you all the way there, but you could call
> > "c.req.uri" with no arguments, that should give you the current request
> > including base, path and query string.  Then you could strip off
> > c.req.base from the beginning of that string.
> 
> Thank you Larry, but the problem is that the base was overwritten and it 
> contains some more than the uri, so I can't cut it from the URI.

It should work fine, we do something very similar.  The trick is that
after the prepare_path fixup (if you did it like in the wiki), when you
stringify c.req.uri, it will reflect the *new* base, not the original. 
Using your example:

   original request url:http://www.site.com/prg?var1=val1&var2=val2
   rewritten request url:  
   http://www.site.com/en/prg?var1=val1&var2=val2

So you should have:

   [%
  uri  = c.req.uri; #
  http://www.site.com/en/prg?var1=val1&var2=val2
  base = c.req.base;# http://www.site.com/en/

  pattern = '^' _ base;# pattern not
  tested...
  path_and_query = uri.replace(pattern, '');
   %]

So it's easy to strip "base" from the front of "uri" and get what you
need, without knowing what "base" is.


> Thank you Evan. Your solution was helpful.
> I didn't know that c.req.uri is not just a string, but an object that has 
> its own methods, and c.req.uri.path_query was the one I needed.

This could work, but given the same original url and prepare_path fixup,
you will have:

   [%
  uri = c.req.uri; #
  http://www.site.com/en/prg?var1=val1&var2=val2
  path_and_query = c.req.uri.path_query;   #   
  /en/prg?var1=val1&var2=val2
   %]

So now when you build the new url you have to be aware that
path_and_query contains the "/en" part that needs to be stripped.


Larry

___
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] Request

2009-10-27 Thread Larry Leszczynski
Hi Octavian -

> Is there a Catalyst Request method for getting the path and the 
> query_string? (Everything's after the base).
> 
> I want to use it in a TT template for changing the current language.
> 
> The current URI is something like:
> http://www.site.com/prg?var1=val1&var2=val2
> 
> The base for this URI is:
> http://www.site.com/en/
> (Because I overwritten prepare_path as in the example given on the Cat
> wiki)
> 
> and the URL that should be printed with the new language is:
> http://www.site.com/ro/prg?var1=val1&var2=val2

Not sure if this gets you all the way there, but you could call
"c.req.uri" with no arguments, that should give you the current request
including base, path and query string.  Then you could strip off
c.req.base from the beginning of that string.


HTH,
Larry

___
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] Choosing the language

2009-10-13 Thread Larry Leszczynski

> >http://dev.catalyst.perl.org/wiki/wikicookbook/urlpathprefixing
> 
> Thank you Larry. It seems to be what I need.
> 
> I've seen some uses of $self which were not defined in that example. 
> Shouldn't be __PACKAGE__ instead?

Sorry, copy/paste error - $self should not be in there.  I've tweaked
the wiki page.

___
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] Choosing the language

2009-10-12 Thread Larry Leszczynski
Hi (again) Octavian -

> Is there a recommendation for storing the language ID in the URL in order
> to 
> be as easy to get it from there?
> 
> I want to have unique links for each URL, so I can't just put it in the 
> cookies. Using ?lang=EN seems to be the easiest way, although it doesn't 
> look nice.
> 
> Putting it as the first element in the path info looks nice, but I don't 
> know how to get it from there in a single controller/action and not in
> every 
> action separately.

Here is one way to have it in the URL without all controllers needing to
be aware:

http://dev.catalyst.perl.org/wiki/wikicookbook/urlpathprefixing


HTH,
Larry

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

2009-10-12 Thread Larry Leszczynski
FYI, the company I work for is looking for a full-time Catalyst
developer:

   http://jobs.perl.org/job/11108

I'm just passing along the info - if you're interested, please reply via
the email address in the posting, not to me (or the list) directly.

Thanks!
Larry

___
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] [OT] Looking for a Perl-savvy job shop

2009-08-26 Thread Larry Leszczynski
Hi all -

At $work we are looking for a Perl-savvy job shop to handle
project-based work on an ongoing basis.  Looking for skills in Catalyst,
Moose, Template Toolkit, bonus points for RDBO.  Prefer US-based. 
Please contact me off-list.


Thanks!
Larry

___
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 do pass-through login?

2009-07-10 Thread Larry Leszczynski
Hi Gunnar -

> Thanks to all who answered my post regarding pass-through login! It put 
> me on the right track and it works like a charm now.
> 
> In my solution I have an action, Catalyst::Action::Restricted, which I 
> put on the subroutines which require a logged-in user 
> (:ActionClass('Restricted')). If no user is logged in, then the request 
> state is saved and the user forwarded to the login page.
> 
> I think it would be helpful to the next guy to improve the Cookbook with 
> a more elaborate example on how to implement this. The current paragraph 
> is a little thin, IMHO.

I'd be interested to see what you finally came up with.  Maybe you could
post to:

  http://dev.catalyst.perl.org/wiki/wikicookbook

?


Thanks!
Larry

___
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] offset the URI of an existing Cat App

2009-07-07 Thread Larry Leszczynski
Hi Ian -

> I have always written Cat Apps so they start at the '/' URI but now I 
> have been asked to 'offset' one so that:-
> 
> /becomes /foo
> /userbecomes /foo/user
> /admin/1 becames /foo/admin/1

One approach is to modify $c->prepare_path, similar to:

   http://dev.catalyst.perl.org/wiki/wikicookbook/urlpathprefixing

(The example was written for Catalyst 5.7 and will work with 5.8, but
there's probably a Moose-ier way to do the same in 5.8...)

Something like:

--

package MyApp;

use Catalyst::Runtime '5.70';
use base 'Catalyst';

__PACKAGE__->setup();

sub prepare_path
{
my $c = shift;
$c->NEXT::prepare_path(@_);

my @path_chunks = split m[/], $c->request->path, -1;

# Pull prefix off beginning of request path:
my $prefix = shift @path_chunks;

# Create modified request path from any remaining path chunks:
my $new_path = join('/', @path_chunks) || '/';
$c->request->path($new_path);

# Modify the path part of the request base
# to include the path prefix:
my $base = $c->request->base;
$base->path($base->path . "$prefix/");

return;
}

--

So if the url was "/foo/admin/1", the controllers will see a request for
"/admin/1".  Also, $c->uri_for('some/path') will generate
"/foo/some/path".



HTH,
Larry

___
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] I18N with quotation marks

2009-07-01 Thread Larry Leszczynski

> We create some custom scalar ops in a subclass of Catalyst::View::TT
> (code below) that let you do:
> 
>   

Actually, escape_dq won't work here:

   

but it will work if for some reason you have a double-quote delimited
JavaScript string.
Will probably need to convert the double quotes to %22 instead. 
Sorry...

>   alert('[% c.loc("Please select one").escape_sq %]');

This one does work though...

Larry


> 
> 
> package Platform::View::TT;
> 
> # This is "MyApp/View/TT.pm":
> 
> use strict;
> use warnings;
> 
> use base 'My::Catalyst::View::TT';
> 
> 1;
> 
> 
> 
> package My::Catalyst::View::TT;
> 
> use strict;
> use warnings;
> 
> use base 'Catalyst::View::TT';
> 
> $Template::Stash::SCALAR_OPS->{escape_q} = sub {
> my $s = shift;
> $s =~ s/\\//g;
> $s =~ s/"/\\"/g;
> $s =~ s/'/\\'/g;
> return $s;
> };
> 
> $Template::Stash::SCALAR_OPS->{escape_dq} = sub {
> my $s = shift;
> $s =~ s/\\//g;
> $s =~ s/"/\\"/g;
> return $s;
> };
> 
> $Template::Stash::SCALAR_OPS->{escape_sq} = sub {
> my $s = shift;
> $s =~ s/\\//g;
> $s =~ s/'/\\'/g;
> return $s;
> };
> 
> 1;
> 
> 
> 
> ___
> 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/

___
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] I18N with quotation marks

2009-07-01 Thread Larry Leszczynski
Hi Ton -

> However, if the translated value contains quotations (such as: s'il
> vous plait), then it could break the HTML:
>
> 
>
> or the javascript:
>
> alert('[% c.loc("Please select one") %]');

We create some custom scalar ops in a subclass of Catalyst::View::TT
(code below) that let you do:

  

  alert('[% c.loc("Please select one").escape_sq %]');

HTH,
Larry



package Platform::View::TT;

# This is "MyApp/View/TT.pm":

use strict;
use warnings;

use base 'My::Catalyst::View::TT';

1;



package My::Catalyst::View::TT;

use strict;
use warnings;

use base 'Catalyst::View::TT';

$Template::Stash::SCALAR_OPS->{escape_q} = sub {
my $s = shift;
$s =~ s/\\//g;
$s =~ s/"/\\"/g;
$s =~ s/'/\\'/g;
return $s;
};

$Template::Stash::SCALAR_OPS->{escape_dq} = sub {
my $s = shift;
$s =~ s/\\//g;
$s =~ s/"/\\"/g;
return $s;
};

$Template::Stash::SCALAR_OPS->{escape_sq} = sub {
my $s = shift;
$s =~ s/\\//g;
$s =~ s/'/\\'/g;
return $s;
};

1;



___
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] Problem using Catalyst::Plugin::I18N and Catalyst::Plugin::PageCache

2009-03-10 Thread Larry Leszczynski
Hi Jozef -

> > [debug] $c->languages from auto-detect: ["en-us", "en", "i-default"]
> >(this looks right based on my browser settings)
> > 
> > [debug] $c->language: i_default
> >(why does it pick "i-default" instead of "en-us" or "en"?)
> > 
> > [debug] Setting language to "en"...
> > [debug] $c->languages: ["en"]
> >(this looks right)
> > 
> > [debug] $c->language: i_default
> >(I expected "en" here)
> 
> $c->languages returns (by default) your browser preferences +
> "i-default". the
> $c->language loop through those and tries to find localization files by
> calling:
> 
> my $class = ref $c || $c;
> my $lang = ref "$class\::I18N"->get_handle( @{ $c->languages } );
> 
> which should be get_handle of
> http://search.cpan.org/perldoc?Locale::Maketext
> 
> do you have MyApp/I18N/en.po or friends?
> 
> cheers,
> jozef

Thanks for following up - it turned out my problem was related to
mismatched names on my MyApp/I18N/*.pm files and their corrresponding
package names.  I was using e.g. MyApp::I18N::en_GB but
Catalyst::Plugin::I18N was looking for MyApp::I18N::en_gb.

Thanks,
Larry

___
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] clear() method for Catalyst::Plugin::Cache?

2009-03-06 Thread Larry Leszczynski

On Fri, 06 Mar 2009 20:11 -0500, "Jason Kohles" 
wrote:
> On Mar 6, 2009, at 7:42 PM, Larry Leszczynski wrote:
> 
> > Does it make sense to add a clear() method to Catalyst::Plugin::Cache,
> > in addition to the existing get(), set() and remove()?  It seems  
> > like a
> > common action for cache manipulation.
> >
> > Any of the various Cache::Cache-based backend flavors should be able  
> > to
> > support it out of the box.  For specific backends that use a different
> > method name to accomplish clearing the cache (e.g.
> > Cache::Memcached::libmemcached::flush_all), would need to come up  
> > with a
> > way to map method names - maybe a config option?:
> >
> >__PACKAGE__->config->{'Plugin::Cache'}{backend} = {
> >class   => "Cache::Memcached::libmemcached",
> >method_map => {
> >   clear => 'flush_all',
> >  },
> >servers => ['127.0.0.1:11211'],
> >debug   => 2,
> >};
> >
> I think this code is a great example of why this is a bad idea as a  
> general practice.  If the only thing you are using memcached for is  
> session cache, then mapping clear to flush_all has the desired effect,  
> but if you are using memcached for more than just session caches, then  
> flush_all could be a very bad idea.

Actually, not using it for session caching at all, just other various
bits and pieces of data.  But I see your point about the danger of
clearing/flushing more than you might expect.  Regardless of cache
flavor, you could set up separate backend instances for different pools
of data (via e.g. different cache_roots for Cache::FileCache or
different server instances for Cache::Memcached::libmemcached) and make
sure you only clear() the intended backend.


Larry

___
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] clear() method for Catalyst::Plugin::Cache?

2009-03-06 Thread Larry Leszczynski
Does it make sense to add a clear() method to Catalyst::Plugin::Cache,
in addition to the existing get(), set() and remove()?  It seems like a
common action for cache manipulation.

Any of the various Cache::Cache-based backend flavors should be able to
support it out of the box.  For specific backends that use a different
method name to accomplish clearing the cache (e.g.
Cache::Memcached::libmemcached::flush_all), would need to come up with a
way to map method names - maybe a config option?:

__PACKAGE__->config->{'Plugin::Cache'}{backend} = {
class   => "Cache::Memcached::libmemcached",
method_map => {
   clear => 'flush_all',
  },
servers => ['127.0.0.1:11211'],
debug   => 2,
};
?

I can try to work up patches if there's a consensus that it makes sense
to do...

Larry

___
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] stripping path parts and then redispatch?

2009-02-24 Thread Larry Leszczynski

On Tue, 24 Feb 2009 05:54 +0200, "Octavian Râsnita" 
wrote:
> I think this solution should be put at least in a wiki if not in the POD 
> manual.
> 
> Octavian

I'll be happy to give it a go, if someone can suggest appropriate places
to add this to the POD and/or wiki...

Larry



> 
> - Original Message - 
> From: "Larry Leszczynski" 
> To: "Bill Moseley" ; "Catalyst Framework" 
> 
> Sent: Tuesday, February 24, 2009 3:44 AM
> Subject: Re: [Catalyst] stripping path parts and then redispatch?
> 
> 
> > Just wanted to pass along some solutions...
> >
> > To recap briefly:
> >
> > URLs are prefixed with the page language, e.g "/en/foo/bar".  The
> > language needs to be stripped off and stashed, and the remainder of the
> > request processed as if the language part had not been there, e.g.
> > "/foo/bar".
> >
> > I was trying to use $c->go("/foo/bar"), which works if there is a
> > Foo::bar() action, but which breaks if the action is supposed to be
> > Foo::default() with the argument "bar" (or Foo::Bar::default() with no
> > arguments).
> >
> >
> > 1) Bill Moseley suggested a different approach which is seeming to work
> > pretty well so far (thanks Bill), it involves subclassing
> > MyApp->prepare_path() to tweak the path at beginning of processing,
> > something like this:
> >
> >  sub prepare_path
> >  {
> >  my $c = shift;
> >
> >  $c->SUPER::prepare_path(@_);
> >
> >  my @path_chunks = split m[/], $c->request->path, -1;
> >
> >  return unless (   @path_chunks
> > && $valid_languages{$path_chunks[0]});
> >
> >  # Pull off first path chunk:
> >  my $language = shift @path_chunks;
> >  $c->stash->{language} = $language;
> >
> >  # Create a request path from the remaining chunks:
> >  my $path = join('/', @path_chunks) || '/';
> >
> >  # Stuff modified request path back into request:
> >  $c->request->path($path);
> >
> >  # Update request base to include whatever
> >  # was stripped from the request path:
> >  my $base = $c->request->base;
> >  $base->path($base->path . $language . '/');
> >  }
> >
> > A nice side effect is that tweaking $c->request->base to include the
> > language means the language is automatically included when you call
> > $c->uri_for().
> >
> >
> > 2) In the process of trying to get $c->go() to work for an arbitrary
> > path, I found a way that seems to make it work consistently even if the
> > path is supposed to hit a default action:
> >
> ># Create your request path to wherever:
> >my $path = "/foo/bar/baz";
> >
> ># Stuff modified request path back into request:
> >$c->request->path($path);
> >
> ># Create a new $c->action using $c->request->path.
> ># Updates $c->action and $c->request->args.
> >$c->dispatcher->prepare_action($c);
> >
> >$c->go($c->action, $c->request->args);
> >
> > This should work for any of $c->forward(), $c->detach(), $c->visit(),
> > $c->go().
> >
> >
> > Thanks for all the suggestions,
> > Larry
> >
> > ___
> > 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/ 
> 
> 
> ___
> 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/

___
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] stripping path parts and then redispatch?

2009-02-23 Thread Larry Leszczynski
Just wanted to pass along some solutions...

To recap briefly:

URLs are prefixed with the page language, e.g "/en/foo/bar".  The
language needs to be stripped off and stashed, and the remainder of the
request processed as if the language part had not been there, e.g.
"/foo/bar".

I was trying to use $c->go("/foo/bar"), which works if there is a
Foo::bar() action, but which breaks if the action is supposed to be
Foo::default() with the argument "bar" (or Foo::Bar::default() with no
arguments).


1) Bill Moseley suggested a different approach which is seeming to work
pretty well so far (thanks Bill), it involves subclassing
MyApp->prepare_path() to tweak the path at beginning of processing,
something like this:

  sub prepare_path
  {
  my $c = shift;

  $c->SUPER::prepare_path(@_);

  my @path_chunks = split m[/], $c->request->path, -1;

  return unless (   @path_chunks
 && $valid_languages{$path_chunks[0]});

  # Pull off first path chunk:
  my $language = shift @path_chunks;
  $c->stash->{language} = $language;

  # Create a request path from the remaining chunks:
  my $path = join('/', @path_chunks) || '/';

  # Stuff modified request path back into request:
  $c->request->path($path);

  # Update request base to include whatever
  # was stripped from the request path:
  my $base = $c->request->base;
  $base->path($base->path . $language . '/');
  }

A nice side effect is that tweaking $c->request->base to include the
language means the language is automatically included when you call
$c->uri_for().


2) In the process of trying to get $c->go() to work for an arbitrary
path, I found a way that seems to make it work consistently even if the
path is supposed to hit a default action:

# Create your request path to wherever:
my $path = "/foo/bar/baz";

# Stuff modified request path back into request:
$c->request->path($path);

# Create a new $c->action using $c->request->path.
# Updates $c->action and $c->request->args.
$c->dispatcher->prepare_action($c);

$c->go($c->action, $c->request->args);

This should work for any of $c->forward(), $c->detach(), $c->visit(),
$c->go().


Thanks for all the suggestions,
Larry

___
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] stripping path parts and then redispatch?

2009-02-23 Thread Larry Leszczynski
Hi Jason -

> >>> I have an existing site, and want to add the page language to the URLs
> >>> so that caching will work correctly, e.g. "/foo/bar" would now look like
> >>> "/en/foo/bar" or "/fr/foo/bar".
> >> Apart from the missing true return value from auto, this works:
> >>
> >> http://lists.scsys.co.uk/pipermail/catalyst/2009-February/021072.html
> > 
> > Thanks for the pointer.  But this approach only seems to work for Local
> > actions, not Private actions like default().  E.g. using these
> > controllers:
> > 
> > #
> > 
> > package MyApp::Controller::Foo;
> > use parent 'Catalyst::Controller';
> > 
> > sub default :Private {
> > my ($self, $c, @args) = @_;
> > $c->response->body("Foo args: @args");
> > }
> 
> That construct is deprecated. You can do basically the same thing with:
> 
>sub default : Path {
>...
>}
> 
> See:
> http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Intro.pod#Built-in_Private_Actions

Thanks, acknowledged.  However, changing "default:Private" to
"default:Path" doesn't solve the problem - the expected argument to
$c->go() for the path "/foo" is still "/foo/default", which is not
obvious just from looking at the path.


Larry

___
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] stripping path parts and then redispatch?

2009-02-23 Thread Larry Leszczynski
Hi Lars -

> > I have an existing site, and want to add the page language to the URLs
> > so that caching will work correctly, e.g. "/foo/bar" would now look like
> > "/en/foo/bar" or "/fr/foo/bar".
> 
> Apart from the missing true return value from auto, this works:
> 
> http://lists.scsys.co.uk/pipermail/catalyst/2009-February/021072.html

Thanks for the pointer.  But this approach only seems to work for Local
actions, not Private actions like default().  E.g. using these
controllers:

#

package MyApp::Controller::Foo;
use parent 'Catalyst::Controller';

sub default :Private {
my ($self, $c, @args) = @_;
$c->response->body("Foo args: @args");
}

sub bar :Local {
my ($self, $c, @args) = @_;
$c->response->body("Foo::Bar args: @args");
}

#

package MyApp::Controller::En;
use parent 'Catalyst::Controller';

sub default :Private {
my ($self, $c, @args) = @_;
my $path = $c->request->path;
$path =~ s{^en}{};
$c->go($path, []);
}

#

The paths "/en/foo/bar" or "/en/foo/bar/arg1" work as expected, but if I
try to hit "/en/foo" I get an error message:

   Couldn't go to command "/foo":
   Invalid action or component.

because the action name it wants is really "/foo/default", not just
"/foo".


For a path like "/a/b/c", I would need to figure out whether to do this:

# Will hit:  A::Bwith arg 'c'
#   or:  A::B::C with no args
#
$c->go("/a/b/c", []);

vs this:

$c->go("/a/default", ['b', 'c']);

vs this:

$c->go("/a/b/default", ['c']);

?


I'm guessing there must be a way to use the Dispatcher to figure out,
for a given path, how to make go() work consistently, but I have not yet
found the trick for making this work...


Thanks!
Larry

___
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] stripping path parts and then redispatch?

2009-02-22 Thread Larry Leszczynski
Hi Tomas -

> > I'm using Catalyst 5.8.5 so I can make use of any of forward, detach,
> > visit, go, etc.
> 
> Not helpful to your main email, but there is no such version as 5.8.5?
> 
> I assume you mean 5.8000_05, which is a developer release?

Yes, that's what I meant, sorry.

Larry

___
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] stripping path parts and then redispatch?

2009-02-22 Thread Larry Leszczynski
Hi all -

I have an existing site, and want to add the page language to the URLs
so that caching will work correctly, e.g. "/foo/bar" would now look like
"/en/foo/bar" or "/fr/foo/bar".  (The language is user-selected, not
from browser prefs, so setting the "Vary: Accept-Language" response
header won't help.)

I'd like to be able to capture and strip off the language, in e.g.
MyApp::Controller::Root::auto(), and then either forward or redispatch
to the existing controllers, but haven't been able to come up with a way
of generating the forwarding path/args that consistently works for all
action types.  E.g., how do I know if I should dispatch to action
"/foo/bar", or action "/foo" with argument "bar"?

I'm trying to avoid using chained actions, because as best as I can
figure out that would require all existing controllers to be rewritten
to be aware of the chaining.

Any ideas about how to do this, or of a different way to accomplish the
same thing?

I'm using Catalyst 5.8.5 so I can make use of any of forward, detach,
visit, go, etc.


Thanks!
Larry

___
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] [Announce] Catalyst-Runtime-5.8000_05

2009-02-10 Thread Larry Leszczynski

On Tue, 10 Feb 2009 21:29:49 +0100, "Florian Ragwitz" 
said:
> On Tue, Feb 10, 2009 at 01:26:24PM -0700, Larry Leszczynski wrote:
> > This version of Catalyst conflicts with the version of
> > Catalyst::Action::RenderView (0.08) you have installed.
> >
> > You will need to upgrade Catalyst::Action::RenderView after
> > installing
> > this version of Catalyst.
> >
> > However, I can find no newer versions of Catalyst::Action::RenderView on
> > CPAN.  Is it safe to install this new Catalyst?
> 
> The warning is wrong. It has been fixed in Catalyst-Runtime 5.8000_06.
> RenderView 0.08 works just fine with it.

Excellent, thanks Florian!

___
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] [Announce] Catalyst-Runtime-5.8000_05

2009-02-10 Thread Larry Leszczynski
Hi Marcus -

> Now that you're all done upgrading to 5.7100, it's time to help us out by
> testing the next developer release of 5.8000, 5.8000_05, which was
> uploaded to CPAN today.

When I "perl Makefile.PL", it tells me:

This version of Catalyst conflicts with the version of
Catalyst::Action::RenderView (0.08) you have installed.

You will need to upgrade Catalyst::Action::RenderView after
installing
this version of Catalyst.

However, I can find no newer versions of Catalyst::Action::RenderView on
CPAN.  Is it safe to install this new Catalyst?

Thanks!
Larry

___
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] Problem using Catalyst::Plugin::I18N and Catalyst::Plugin::PageCache

2009-02-04 Thread Larry Leszczynski
Hi all -

I have two problems that I think are related, I think I may just be
missing something simple...

First, I'm having trouble getting Catalyst::Plugin::I18N to use a
specific language (grabbed from user preferences).  Inside
MyApp::Controller::Root::auto() I am doing this:

$c->log->debug('$c->languages from auto-detect: ' .
dump($c->languages));
$c->log->debug('$c->language: ' . $c->language);

$c->log->debug('Setting language to "en"...');
$c->languages(['en']);

$c->log->debug('$c->languages: ' . dump($c->languages));
$c->log->debug('$c->language: ' . $c->language);

which results in this:

[debug] $c->languages from auto-detect: ["en-us", "en", "i-default"]
   (this looks right based on my browser settings)

[debug] $c->language: i_default
   (why does it pick "i-default" instead of "en-us" or "en"?)

[debug] Setting language to "en"...
[debug] $c->languages: ["en"]
   (this looks right)

[debug] $c->language: i_default
   (I expected "en" here)

Am I doing something wrong?

Next problem has to do with C::P::PageCache - it uses $c->language
internally when generating page cache keys, so my page cache keys always
have "i_default" in them.  I'm guessing it has to do with the problem
above...

I am using Catalyst 5.8000_04 and the following plugin versions (which I
think are all up-to-date):

Catalyst::Plugin::I18N  0.08
Catalyst::Plugin::PageCache  0.21
Catalyst::Plugin::Unicode  0.8

Any help much appreciated.

Thanks!
Larry

___
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] Subclass Catalyst::View::TT to use Template::Foo instead of Template?

2009-01-28 Thread Larry Leszczynski
Is there any straightforward way to create a subclass of
Catalyst::View::TT so that $self->{template} is an instance of
Template::Foo instead of Template?

In e.g. Catalyst::View::TT::Foo I could call $self->SUPER::new() and
then overwrite the resulting $self->{template} object, but at that point
I don't have access to the $config that was passed to Template->new(). 
It looks like I'd have to copy out all of the relevant info from
$self->{template}, and then use it to create a new Template::Foo, which
looks like it would be unwieldy and hard to maintain.

Or would it make sense to modify Catalyst::View::TT to accept a new
config argument like TEMPLATE_CLASSNAME (that defaults to "Template")?


Thanks in advance,
Larry

___
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] Bug with $c->request->query_keywords ?

2008-06-19 Thread Larry Leszczynski
I've run into what appears to be a query keyword bug using Catalyst
5.701[02]:

   % catalyst.pl MyApp
   % cd MyApp
   % perl script/myapp_server.pl

Request:

   http://localhost:3000/ -> works
   http://localhost:3000/?a=123   -> works
   http://localhost:3000/?123 -> fails

The error message is:

   [error] Caught exception in engine "Can't locate object
   method "query_keywords" via package "Catalyst::Request"
   at /Library/Perl/5.8.8/Catalyst/Engine.pm line 446."

It does not happen on boxes that are running 5.7007.  Is anyone else
seeing this?


Thanks,
Larry

___
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: difficulty in assigning an array to a stash

2007-11-12 Thread Larry Leszczynski

On Mon, 12 Nov 2007, Larry Leszczynski wrote:


  FOREACH options IN options;
  lv_id = options.lv_id;
  ... do stuff with lv_id ...
  END


Sorry, that should be:

FOREACH option IN options;
lv_id = option.lv_id;
... do stuff with lv_id ...
END


___
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] Re: difficulty in assigning an array to a stash

2007-11-12 Thread Larry Leszczynski

Hi Jagdish -


my @options = $c->model('myleavedb::txn_mdl')->search({emp_no =>
$c->user->emp_no},{columns => [qw/lv_id/]});


When you do the search via the model, @options will be an array of 
objects of the type defined in "myleavedb::txn_mdl".  Because of your 
"columns" specification, each of those objects will have the "lv_id" 
column/method available.




foreach my $option(@options) {
push (@new_options,$option->lv_id)
}
$c->stash->{myoptions} = [EMAIL PROTECTED];

I don't understand in what way @options and @new_options are different
from each other, but in a bumbling manner I have made the code work.


Your new code loops over the objects, pulls out lv_id values into 
@new_options, and passes [EMAIL PROTECTED] into the template.


Another way would be to pass [EMAIL PROTECTED] directly into the template, and 
in your template you would use something like:


   FOREACH options IN options;
   lv_id = options.lv_id;
   ... do stuff with lv_id ...
   END

Depending on circumstances this may be a better approach in the long 
run because, for example, later you may decide you need additional 
columns from @options, and you would be able to access those in 
your template as option.lv_id, option.some_other_method, etc.



Larry

___
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] Re: Subsessions?

2007-10-04 Thread Larry Leszczynski



On Wed, Oct 03, 2007 at 11:10:50AM +0200, Rainer Clasen wrote:
Nearly all URIs in this project look like //diary/list or 
//exercise/add. This means all actions have to be setup 
for chaining manually


On Thu, 4 Oct 2007, Rainer Clasen wrote:
With Chaining you have to specify where you actually chain to (even 
if it's "."). With ":Local" you automgagically end up in the current 
namespace, no need to bother making "." available.


Is this something that the PathPrefix[1] attribute would help with, to 
make the action relative to the current namespace?  E.g. create a base 
class for your athlete class, something like:


package MyApp::Base::Controller::Athlete;
use base 'Catalyst::Controller';

sub diary : Chained('/') PathPrefix Args(1)
{
my ($self, $c, $action) = @_;
my $athlete = $self->path_prefix;
}

?

Larry


[1] http://use.perl.org/~LTjake/journal/31738


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