Re: [Catalyst] Prevent reloading javascript files

2018-01-20 Thread Robert Rothenberg
Why not serve them directly through Apache?

On Fri, 19 Jan 2018, 10:13 Theo Bot,  wrote:

> Hi
>
> Is there a way to prevent your browser to reload javascript/css/images
> files on a page reload. I've tried to add use the appcache
>
> 
>
> In the myapp.appcache file:
> CACHE MANIFEST
> # 2018-01-19:v1
>
> # Cache section
> CACHE:
> /static/js/app.js
> /static/js/colorbox.js
>
>
> NETWORK:
> *
>
> However the manifest file doesn't seem to get parsed. I don't see it being
> loaded by firebug nor by the browserconsole.
>
> Any suggestions?
> --
> Kind regards,
>
> Theo Bot
>
> ___
> 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/


[Catalyst] CatalystX::Test::MockContext

2017-11-14 Thread Robert Rothenberg

Is anyone in touch with Eden Cardim, the author of CatalystX::Test::MockContext?

I have a PR in https://github.com/edenc/CatalystX-Test-MockContext/pull/2 
that seems to fix the module for newer versions of Catalyst.


I've e-mailed the author directly after not receiving a reply from the PR, 
and still not heard back.


Thanks,
Rob

___
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 avoid repeating methods in controllers ?

2013-07-21 Thread Robert Rothenberg
I prefer to put as much code as I can (especially "business logic" code)
into Moose role methods. This makes it easier to share code among multiple
controller methods, and it makes the code a little easier to read as well
as test (since the role methods don't require the Catalyst server to be
running per se: the context can be simulated using
CatalystX::Test::MockContext).

If the code really does require a controller, I create a base controller
class that uses configuration parameters from $self->{config}, and then
have the actual controllers use something like

  __PACKAGE__->config(
table => 'foo',
..
  );






On Wed, Jul 17, 2013 at 3:05 AM, cc loo  wrote:

> Hi all, i'm a network engineer by trade and is picking up perl/catalyst to
> upgrade my skills :)
>
> I have a couple of controllers each having same methods, chaining off
> their respective 'base' methods.
>
> I build my controllers off this guide here:
> http://search.cpan.org/~ether/Catalyst-Manual-5.9007/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#Refactor_to_Use_a_'base'_Method_to_Start_the_Chains
>
>
> So, i have
>
> controller_a with a method 'list' , chaining off 'base'
> controller_b with a method 'list', chaining off' 'base'
>
> Is there a more graceful manner of inheriting this method instead of
> copy/paste on every controller i have ?
>
>
> ___
> 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/


[Catalyst] Catalyst::Action::REST with multipart uploads

2013-03-29 Thread Robert Rothenberg
I'm wondering if it's possible to use Catalyst::Action::REST with multipart
uploads, so that one can POST or PUT a data structure with an attached file.

The use case would be a RESTful API for uploading attachments. The XML or
JSON data structure would contain metadata about the object, and the
possibly attached file would contain the object being uploaded.

The Catalyst::Action::REST distro includes a
Catalyst::Action::DeserializeMultiPart module, but I am unsure if this would
be used for just desrializing multiple data structures or can be used to
include binary attachments to th data structure.


___
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 with HTTP authentication

2013-03-25 Thread Robert Rothenberg
On 25/03/13 14:08 Tomas Doran wrote:
> 
> On 22 Mar 2013, at 13:34, Robert Rothenberg  wrote:
>> I'm unsure what to do here. Should I write a Plack::Middleware plugin that
>> translates the X-Proxy-REMOTE_USER header to an env->{REMOTE_USER}?
> 
> 
> That's exactly what's needed here :)

Ok. After faffing about, I've figured it out. I've created a module

  package Plack::Middleware::MyRemote;

  use parent qw( Plack::Middleware );

  use Plack::Util;

  sub call {
  my ($self, $env) = @_;

  $env->{REMOTE_USER} = $env->{HTTP_X_PROXY_REMOTE_USER}
if ($env->{HTTP_X_PROXY_REMOTE_USER});

  my $res = $self->app->($env);

  return $res;
  }

  1;

and modified myapp.psgi to

  use strict;
  use warnings;

  use MyApp;

  use Plack::Builder;

  my $app = Drain->apply_default_middlewares(Drain->psgi_app);

  builder {
 enable "Plack::Middleware::MyRemote";
 $app;
  };

that seems to work now.

In the Apache configuration, I need to add:

  RequestHeader unset X-Proxy-REMOTE_USER

  RewriteEngine On
  RewriteCond %{LA-U:REMOTE_USER} (.+)
  RewriteRule . - [E=RU:%1]
  RequestHeader add X-Proxy-REMOTE_USER %{RU}e

along with the requirement to log in for the specific directory.

I'd suggest updating the documentation for A::C::Remote accordingly. (I can
do this if you point me in the direction of the git repo)

This seems to work properly.








___
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] Setting an environment variable with the value of a header

2013-03-25 Thread Robert Rothenberg
On 25/03/13 14:11 Tomas Doran wrote:
> 
> On 25 Mar 2013, at 11:51, Robert Rothenberg  wrote:
>> 
>> The issue is getting Catalyst to use the header in place of the
>> environment variable.
> 
> 
> Erm, the remote user Authentication::Credential::Remote comes from a
> header, not the environment already.

Really? It seems to use the REMOTE_USER variable when I've tried it.

Looking at the source code, it seems to check the environment.

If Plack is translating headers into special environment variables, then
it's a matter of telling A::C::Remote a different source.  What would be the
name?

> E.g. if you run an app as external FCGI, it has it's startup environment,
> but the remote user comes per-request down FCGI (as a header)…

I'm running the Plack server directly, not FCGI, and using a reverse proxy.





___
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] Setting an environment variable with the value of a header

2013-03-25 Thread Robert Rothenberg
On 25/03/13 03:13 Alejandro Imass wrote:
> On Fri, Mar 22, 2013 at 2:32 PM, Robert Rothenberg  wrote:
>> I've not gotten replies to my posts regarding HTTP authentication, so I'm
>> starting a separate thread.
>>
>> I am running a Catalyst app as a separate server with a reverse proxy.
>>
>> If I pass the REMOTE_USER to the Catalyst app via a header such as
>> X-Proxy-REMOTE_USER, how do I set the REMOTE_USER value for in the Catalyst 
>> app?
>>
> 
> Is this FastCGI on Apache?? If so, the issue is not Catalyst bu that...

Not, but I know how to pass the variable via headers.

The issue is getting Catalyst to use the header in place of the environment
variable.



___
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] Setting an environment variable with the value of a header

2013-03-22 Thread Robert Rothenberg
I've not gotten replies to my posts regarding HTTP authentication, so I'm
starting a separate thread.

I am running a Catalyst app as a separate server with a reverse proxy.

If I pass the REMOTE_USER to the Catalyst app via a header such as
X-Proxy-REMOTE_USER, how do I set the REMOTE_USER value for in the Catalyst app?

I've tried looking at Plack settings, but haven't figured out how to do this.

(Another, perhaps easier alternative, is to write a
Catalyst::Authentication::Credential plugin that does this, but I assume
this isn't so unusual that it's already been done. Has 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] Catalyst with HTTP authentication

2013-03-22 Thread Robert Rothenberg
On 22/03/13 11:46 Robert Rothenberg wrote:

> I understand how to have an Apache reverse proxy send the REMOTE_USER as a
> header, with something like
> 
>   RequestHeader set X-Proxy-REMOTE-USER %{REMOTE_USER}
> 
> but how to I get Authentication::Credential::Remote to use the header
> instead of the environment variable?  Do I need an auto method in Root.pm
> that checks for the header and sets $c->req->remote_user()?

I have code such as

if (my $user = $c->req->header('X-Proxy-REMOTE-USER')) {

$c->engine->env({ REMOTE_USER => $user });

$c->authenticate({});

}

which works, but I get a warning "env as a writer is deprecated, you
probably need to upgrade Catalyst::Engine::PSGI".

I'm unsure what to do here. Should I write a Plack::Middleware plugin that
translates the X-Proxy-REMOTE_USER header to an env->{REMOTE_USER}?




___
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 with HTTP authentication

2013-03-22 Thread Robert Rothenberg
On 14/03/13 08:51 Tomas Doran wrote:
> 
> On 12 Mar 2013, at 17:10, Robert Rothenberg  wrote:
> 
>>> (Unless you mean you want to do the authentication on the proxy,
>>> rather than the app servers).
>> 
>> I want to do the latter.
> 
> You should still be able to use Authentication::Credential::Remote,
> you'll just need to re-configure your web server and proxy to do the
> right thing with headers (i.e. the proxy needs to send the username along
> in a header, and then the web server needs to pass that down into the
> environment.
> 
> Have a go and post some configs for your proxy / web server if it isn't
> working for you.

I understand how to have an Apache reverse proxy send the REMOTE_USER as a
header, with something like

  RequestHeader set X-Proxy-REMOTE-USER %{REMOTE_USER}

but how to I get Authentication::Credential::Remote to use the header
instead of the environment variable?  Do I need an auto method in Root.pm
that checks for the header and sets $c->req->remote_user()?



___
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] Re: Puzzlement about logging

2013-03-18 Thread Robert Rothenberg
I've found a solution, sort of.

After creating the Catalyst contexts (using CatalystX::Test::MockContext), I
add the following to the tests

  my $log = Test::Log::Dispatch->new();
  $c->log($log);

and then use the methods in $log to test the output of logs in the database
role tests.

It also seems to capture the output of logs in the controller tests.

BUT it still doesn't explain the inconsistent behaviour: why are the log
messages not being output to STDERR in one set of tests, and then being
output to STDERR in a way that isn't captured in another set of tests.

BTW, I did verify tha the $c->log object has the properly configured
Log::Dispatch output.


On 18/03/13 15:38 Robert Rothenberg wrote:
> I have a strange issue with testing the output to $c->log->info in some tests.
> 
> The app has various database roles that act as wrappers for tables,
> basically to ensure consistency of behaviour, such as whether the user has
> access to the table, emitting log messages that records were created/updated
> etc.  (The role methods take the Catalyst context as a parameter.)
> 
> When running the tests of database roles, no log messages are output.
> 
> BUT when running tests of the API controller methods using
> Test::WWW::Mechanize::Catalyst, log messages are output.
> 
> Even stranger, to set up these tests, we run the same database record
> creation methods to add records to test in the API.  These do output log
> messages, AND they cannot be captured to be tested using Capture::Tiny.
> 
> Has anyone run into something like this before?
> 


___
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] Puzzlement about logging

2013-03-18 Thread Robert Rothenberg
I have a strange issue with testing the output to $c->log->info in some tests.

The app has various database roles that act as wrappers for tables,
basically to ensure consistency of behaviour, such as whether the user has
access to the table, emitting log messages that records were created/updated
etc.  (The role methods take the Catalyst context as a parameter.)

When running the tests of database roles, no log messages are output.

BUT when running tests of the API controller methods using
Test::WWW::Mechanize::Catalyst, log messages are output.

Even stranger, to set up these tests, we run the same database record
creation methods to add records to test in the API.  These do output log
messages, AND they cannot be captured to be tested using Capture::Tiny.

Has anyone run into something like this before?

___
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 with HTTP authentication

2013-03-15 Thread Robert Rothenberg
On 14/03/13 08:51 Tomas Doran wrote:
> 
> On 12 Mar 2013, at 17:10, Robert Rothenberg  wrote:
> 
>>> (Unless you mean you want to do the authentication on the proxy, rather 
>>> than the app servers).
>>
>> I want to do the latter.
> 
> You should still be able to use Authentication::Credential::Remote, you'll 
> just need to re-configure your web server and proxy to do the right thing 
> with headers (i.e. the proxy needs to send the username along in a header, 
> and then the web server needs to pass that down into the environment.
> 
> Have a go and post some configs for your proxy / web server if it isn't 
> working for you.

I haven't found any decent documentation on that, so gave up and just used
to HTTP authentication plugin, which appears to be working.


___
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 with HTTP authentication

2013-03-12 Thread Robert Rothenberg
On 12/03/13 15:36 Tomas Doran wrote:
> 
> On 12 Mar 2013, at 13:20, Robert Rothenberg  wrote:
> 
>> On 11/03/13 15:37 Lukas Thiemeier wrote:
>>
>>> I am using Catalyst::Authentication::Credential::Remote in a current
>>> project. It lets the webserver do all the authentication. You can use
>>> any authentication method and storage which is supported by your
>>> webserver, including htpasswd files.
>>
>> How do you pass the remote user in a reverse proxy?
>>
>>
> 
> It's just http headers, it'll just transparently pass through the proxy.
> 
> (Unless you mean you want to do the authentication on the proxy, rather than 
> the app servers).

I want to do the latter.

___
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] Is there an authentication store for htdigest files?

2013-03-12 Thread Robert Rothenberg
I am using Catalyst::Authentication::Credential::HTTP and would like to use
digest authentication with htdigest files.

Is there an htdigest equivalent of Catalyst::Authentication::Store::Htpasswd?

___
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 with HTTP authentication

2013-03-12 Thread Robert Rothenberg
On 11/03/13 15:37 Lukas Thiemeier wrote:

> I am using Catalyst::Authentication::Credential::Remote in a current
> project. It lets the webserver do all the authentication. You can use
> any authentication method and storage which is supported by your
> webserver, including htpasswd files.

How do you pass the remote user in a reverse proxy?



___
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 with HTTP authentication

2013-03-12 Thread Robert Rothenberg
Thanks. That worked, but I'll take a look at
Catalyst::Authentication::Credential::Remote

___
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 with HTTP authentication

2013-03-11 Thread Robert Rothenberg
I have a project that requires using HTTP authentication.

There is a Catalyst::Authentication::Credential::HTTP module, but from the
documentation, it does not seem to support using htpasswd files, which I
need, because a separate web site will be using that file.

There is Catalyst::Authentication::Store::Htpasswd, but it does not work
with Catalyst::Authentication::Credential::HTTP.

I'm not clear on how to do this, without having to write my own handlers for
HTTP authentication.


___
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.90020

2013-02-28 Thread Robert Rothenberg
On 28/02/13 13:40 Alexander Hartmaier wrote:
> The Catalyst team is proud to announce the latest version of 
> Catalyst::Runtime.
> John Napiorkowski wrote a great blog post [1] about its new features and
> asks for your comments and suggestions for upcoming features.
> 
> |  ||! Catalyst::Action now defines 'match_captures' so it is no long
> considered|
> |||an optional method.  This might break you code if you have made custom|
> |||action roles/classes where you define 'match_captures'.  You must 
> change|
> |||your code to use a method modifier (such as 'around').|
> |  ||-| |New match method "Method($HTTP_METHOD)" where $HTTP_METHOD in (GET,
> POST,|
> |||PUT, HEAD, DELETE, OPTION) and shortcuts in controllers called "GET,
> POST|
> |||PUT, HEAD, DELETE, OPTION").  Tests and documentation.  Please note
> if you|
> |||are currently using Catalyst::ActionRole::MatchRequestMethods there 
> may|
> |||be compatibility issues.  You should remove that actionrole since the
> built|
> |||in behavior is compatible on its own.|
> |  ||-| |Initial debug screen now shows HTTP Method Match info|
> |  ||-| |security fixes in the way we handle redirects|
> |  ||-| |Make Catalyst::Engine and Catalyst::Base immutable|
> |  ||-| |Some test and documentation improvements|
> 
>

Will this break Catalyst::Action::REST?



___
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 server won't start

2013-01-29 Thread Robert Rothenberg
I am trying to start a Catalyst development server but it fails with the error:

  Attribute (_inotify) does not pass the type constraint because: Validation
failed for 'Linux::Inotify2' with value undef at constructor
File::ChangeNotify::Watcher::Inotify::new

this is fixed by either removing the -r option, or uninstalling Linux::Inotify2.

I'm not sure why this error has suddenly occurred. Anyone have ideas?

It occurs with Catalyst 5.90019 and 5.90011 and Catalyst::Devel 1.37 and 1.36.


___
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] DB values that change very rarely

2013-01-14 Thread Robert Rothenberg
I have a caching plugin that would be useful. Cache::HTTP::Preempt. Will
upload to CPAN soon but I am moving house now.
On Jan 14, 2013 8:18 AM, "Alexander Hartmaier" <
alexander.hartma...@t-systems.at> wrote:

> On 2013-01-11 19:05, Francisco Obispo wrote:
> > You really don't want this in DBIx::Class, you want fine grain control
> of when to fetch from the database, etc. Anyone can build their layer on
> top of DBIx::Class to implement caching.
> >
> > Using something like memcached would save you some database hits, you
> can either set the values to expire at a specified time / number of
> seconds, or you can set/delete keys as part of the procedures at
> insert/update/delete on the database.
> >
> > If you you Postgresql, you can actually take advantage of PgPool, which
> will give you the option to enable a caching layer…
> >
> > Francisco
> Please don't top post!
> I *do* want this in DBIC so that a prefetch specified in some query
> doesn't hit the database if the table is cached schema-wide. Any other
> caching technique would mean changing every piece of code whereas this
> would be transparent. I do know DBIx::Class quite well and don't think
> that's possible with a component.
> >
> >
> >
> > On Jan 11, 2013, at 4:01 AM, Alexander Hartmaier <
> alexander.hartma...@t-systems.at> wrote:
> >
> >> On 2013-01-10 16:15, Jesse Sheidlower wrote:
> >>> In one of my apps, I have a number of tables that contain values that
> >>> change very rarely. Think of something like a "category" table in an
> >>> e-commerce app--they're mostly static, but every now and then you need
> >>> to change or add or delete a category. These occasional changes do,
> >>> however, need to be made by a (privileged) user, rather than a
> >>> developer, so I can't just put them in the config file and edit this
> and
> >>> restart the app when necessary. Since I don't know when they might
> >>> change, I don't know how I could cache them, because when a change is
> >>> made it needs to take effect immediately.
> >>>
> >>> These tables are used on almost every request. The result is that most
> >>> of my controllers end up looking something like this, or having
> >>> something like this at the end of them:
> >>>
> >>> sub add : Local {
> >>>   my ( $self, $c ) = @_;
> >>>
> >>>   $c->stash->{title} = 'Add a new lemma';
> >>>
> >>>   $c->stash->{batches} = $c->model('WordsDB::Batch')->search();
> >>>   $c->stash->{statuses} = $c->model('WordsDB::Status')->search();
> >>>   $c->stash->{regions} = $c->model('WordsDB::Region')->search();
> >>>   $c->stash->{subjects} = $c->model('WordsDB::Subject')->search();
> >>>
> >>>   $c->stash->{template} = 'add.tt';
> >>> }
> >>>
> >>> This means that almost every page generation hits the database a whole
> bunch of
> >>> unnecessary times, and that all of my controllers are cluttered.
> >>>
> >>> This must be a fairly common problem. What's the best way to deal with
> >>> it--both the desire to persist what is mostly static data, and to keep
> >>> my controllers clean?
> >>>
> >>> Thanks.
> >>>
> >>> Jesse Sheidlower
> >>>
> >>> ___
> >>> 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/
> >> I'd LOVE to see that functionality in DBIx::Class::Schema so prefetches
> >> use the cached values to populate the related data instead of hitting
> >> the database.
> >>
> >> --
> >> Best regards, Alexander Hartmaier
> >>
> >>
> >>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> >> T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
> >> Handelsgericht Wien, FN 79340b
> >>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> >> Notice: This e-mail contains information that is confidential and may
> be privileged.
> >> If you are not the intended recipient, please notify the sender and then
> >> delete this e-mail immediately.
> >>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> >>
> >> ___
> >> 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/
> > Francisco Obispo
> > Director of Applications and Services - ISC
> > email: fobi...@isc.org
> > Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
> > PGP KeyID = B38DB1BE
> >
> >
> > ___
> > 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/
>
> --
> LG Alex
>
>
> 

[Catalyst] A plugin for handling If-Modified-Since?

2012-12-05 Thread Robert Rothenberg

I'm working on a RESTful API for an application (much thanks for
Catalyst::Controller::REST, by the way) and need to handle the
If-Modified-Since header to efficiently check when things have changed.

It seems my controllers will follow the pattern:

  1. Initial validation of the request and get the base object that
 the request is about.

  2. Check for If-Modified-Since header.

 If it is present and no older than the last-modified date of
 the object, return a 304 status with no body.

  3. Otherwise, set the Last-modified and Expires headers. (The latter
 to keep Firefox from caching the result too long.)

  4. If a HEAD request, exit.

 Otherwise return the object, which involves some more reads from the
 database etc.

I've looked at the Cache::HTTP plugin, but it doesn't do what I want, which
is to pre-empt running queries if they don't need to be run.

Is there another plugin for doing this sort of thing?

If not, I am thinking of writing a plugin that would work something like

  $c->if_unmodified( headers => $sub1, content => $sub2 );

where $sub1 would be code to set the last-modified and maybe weak etags
(based on the last-modified if nothing else is specified).

The method would check for a If-Match and If-Modified-Since headers, etc. If
they matched, it would return a 304 error, otherwise it would run $sub2.

Does this seem a worthwhile endeavor?


___
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] Test::HTML::Spelling

2012-11-26 Thread Robert Rothenberg
Not specifically Catalyst-related, but I imagine of interest to people on
this list.

I've written a module, Test::HTML::Spelling, and have posted it on github:

  https://github.com/robrwo/Test-HTML-Spelling

When it's been tweaked a bit more, I will upload it to CPAN.

In the meantime, I'd appreciate feedback.

I'm already using it for a production system (using a subclass of
Test::WWW::Mechanize::Catalyst that has a spelling_ok method added, among
other things).

Basically, it parses the HTML, and spellchecks elements (along with title
and alt attributes) but will ignore elements with the class "no-spellcheck"
so that you can ignore user-input or things like timezones.





___
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] Generating a large XML document (KML file) from a database

2012-11-26 Thread Robert Rothenberg
Thanks. I guessed that was something I needed to do.

One note: when initializing a new XML::Writer object, you can pass $c->res
as the OUTPUT, and XML::Writer will do the right thing, apparently, since it
has a print method.

Also, sending an empty string to body

  $c->res->body("")

is enough.



On 26/11/12 17:54 Francisco Obispo wrote:
> Ok, Now that I'm on my computer, I can write a decent response:
> 
> I had a similar problem with generating a fairly large CSV file.
> 
> you don't want to store this in a stash entry because it can get very large, 
> and 
> even it you were using a temp file to write the data to, the user
> would have to wait until the file is fully written and then
> transferred, which could translate to unresponsiveness.
> 
> I decided to use catalyst ->write() method to output directly
> to the socket, and generate the CSV on the fly.
> 
> On your example, you could use XML::Writer which allows you to 
> generate XML on the fly via:
> 
>   $c->write( $writer->startTag('hello',(attribute=>'value')) );
>   $c->write( $writer->characters('World!') );
>   $c->write( $writer->endTag()) ;
> 
> 
> Will generate to the output buffer:
> 
>   World!
> 
> You will need to generate a header with the right content type before you
> start sending out stuff to your output buffer:
> 
>  $c->response->content_type('text/comma-separated-values');
> 
>  $c->res->header( 'Content-Disposition',
>  qq[attachment; filename=download.csv] );
> 
> 
> This is how I generated mine for the CSV, you would have to fill the 
> right content_type: application/xxx?
> 
> And the name of the file in the Content-Disposition section.
> 
> Notice that you will not provide a Content-Length header, so the
> client will not know how much data you will be sending until its 
> done.
> 
> And catalyst won't know that you actually sent anything so to avoid
> Catalyst rendering the template, just set the body to something, in
> my case I did:
> 
> $c->response->body(qq{\n});
> 
> I know there are some methods to tell Catalyst to end instead
> of generating the template, but I couldn't get them to work properly.
> 
> 
> Regards
> 
> 
> Francisco Obispo 
> Director of Applications and Services - ISC
> email: fobi...@isc.org
> Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
> PGP KeyID = B38DB1BE
> 
> On Nov 26, 2012, at 8:58 AM, Robert Rothenberg  wrote:
> 
>> I need to output a large XML file (actually, a KML file of points) from a
>> database.
>>
>> I can't find any documentation for Catalyst::View::XML::Generator, or even
>> decent documentation for XML::Generator, on how to do this.
>>
>> It would appear to expect me to put the entire structure in the stash, which
>> I don't want to do, as it could contain thousands of points.
>>
>> Ideally I would pass an iterator function and it would do the rest.
>>
>>
>>
>>
>>
>>
>> ___
>> 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/


[Catalyst] Generating a large XML document (KML file) from a database

2012-11-26 Thread Robert Rothenberg
I need to output a large XML file (actually, a KML file of points) from a
database.

I can't find any documentation for Catalyst::View::XML::Generator, or even
decent documentation for XML::Generator, on how to do this.

It would appear to expect me to put the entire structure in the stash, which
I don't want to do, as it could contain thousands of points.

Ideally I would pass an iterator function and it would do the rest.






___
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] Trapping added errors with the correct caller

2012-10-15 Thread Robert Rothenberg
On 15/10/12 17:49 Alexander Hartmaier wrote:
> On 2012-10-15 18:03, Robert Rothenberg wrote:
>> On 15/10/12 15:21 Alexander Hartmaier wrote:
>>> I recommend to use a logging module like Log::Log4perl::Catalyst and do
>>> all your app logging there.
>> I use Log::Dispatch. (The application is already deployed, and it's not
>> feasible to change it to Log4perl now.)
> If you're already using a logger but the default Catalyst one that's fine.
>>
>> I don't see where in your code you trap calls to $c->error() and log them.
> All log messages are going to your logger object, Log::Dispatch in your
> case, not just errors.
> Just configure Log::Dispatch to do with them what you want it to do (log
> to a separate file, mail them, etc. ).

You don't seem to understand my original question.

The "end" method of the Root controller looks for errors in $c->error() and
logs them, then displays a custom error page.  The problem with doing that
is that it does not say where the error occurred.  So I want to modify
$c->error() to log it every time something is added, which is actually quite
easy.  But I want to use something like Sub::Uplevel so that the logger does
not say the wrapper module triggered the error.


___
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] Trapping added errors with the correct caller

2012-10-15 Thread Robert Rothenberg
On 15/10/12 15:21 Alexander Hartmaier wrote:
> I recommend to use a logging module like Log::Log4perl::Catalyst and do
> all your app logging there.

I use Log::Dispatch. (The application is already deployed, and it's not
feasible to change it to Log4perl now.)

I don't see where in your code you trap calls to $c->error() and log them.

> My log package for NAC::Web:NAC looks like this:
> 
> package NAC::Web::NAC::Log;
> use Moose;
> use Catalyst::Log;
> use namespace::autoclean;
> 
> BEGIN { extends 'Log::Log4perl::Catalyst'; }
> 
> =head1 NAME
> 
> NAC::Web::NAC::Log - Logger for NAC::Web::NAC
> 
> =cut
> 
> # import _dump method from Catalyst::Log
> *_dump = \&Catalyst::Log::_dump;
> 
> 1;
> 
> My app uses it with:
> 
> =item finalize_config
> 
> Initializes the logger after the config file merging and loading is done.
> 
> =cut
> 
> sub finalize_config {
> my $class = shift;
> $class->next::method(@_);
> $class->log(NAC::Web::NAC::Log->new($class->config->{log}));
> }
> 
> # Start the application
> __PACKAGE__->setup();
> 
> around 'prepare' => sub {
> my $orig = shift;
> my $self = shift;
> 
> Log::Log4perl::MDC->remove();
> 
> my $c = $self->$orig(@_);
> 
> Log::Log4perl::MDC->put( "username", $c->user->username )
> if $c->user_exists;
> 
> return $c;
> };
> 
> And this is how the app's prod config file looks like:
> 
> 
> log4perl.logger "WARN, FILE, MAIL"
> log4perl.appender.FILE
> "Log::Log4perl::Appender::File"
> log4perl.appender.FILE.filename
> "/home/nac/log/nac-web-nac.log"
> log4perl.appender.FILE.utf8 1
> log4perl.appender.FILE.syswrite 1
> log4perl.appender.FILE.layout
> "Log::Log4perl::Layout::PatternLayout"
> log4perl.appender.FILE.layout.ConversionPattern "%d{-MM-dd
> HH:mm:ss} %-5p %X{username} %m%n"
> log4perl.appender.MAIL
> "Log::Dispatch::Email::MailSend"
> log4perl.appender.MAIL.ThresholdERROR
> log4perl.appender.MAIL.from "n...@domain.com"
> log4perl.appender.MAIL.to
> "app-err...@domain.com"
>     log4perl.appender.MAIL.subject  "[NAC::Web::NAC]
> errors"
> log4perl.appender.MAIL.buffered 0
> log4perl.appender.MAIL.layout   "PatternLayout"
> log4perl.appender.MAIL.layout.ConversionPattern "%d{-MM-dd
> HH:mm:ss} %-5p %X{username} %m%n"
> 
> 
> Best regards, Alex (abraxxa)
> 
> On 2012-10-11 14:38, Robert Rothenberg wrote:
>> I would like to trap every error added to $c->error() and log it, noting the
>> caller (filename, line number) in the logs.
>>
>> I've not gotten Catalyst::Plugin::ErrorCatcher to work, so I wrote my own
>> plugin that overrides $c->error with the following method:
>>
>>   use MRO::Compat;
>>   use namespace::autoclean;
>>
>>   sub error {
>> my ($c, @args) = @_;
>>
>> foreach my $arg (@args) {
>> if ($arg) {
>>
>> $c->log->error($arg);
>> }
>> }
>>
>> return $c->next::method(@args);
>>  }
>>
>> But this only logs errors as coming from my plugin.
>>
>> Using Sub::Uplevel or fiddling with $Log::Dispatch::CallerDepth or
>> $Catalyst::Plugin::Log::Dispatch::CallerDepth doesn't seem to work.
>>
>> I also tried writing the plugin as a Moose::Role that adds my trap before
>> error, but then it claims to be from one of the internal Moose classes in my
>> logs.
>>
>> I can manually get the caller using caller(0) and add them to the log
>> messages, but that's a bit clumsy (and overrides log formats that don't
>> include the information).
>>
>> So... what is the best practice for trapping errors in a way that preserves
>> caller information?
>>
>>
>> ___
>> 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] Trapping added errors with the correct caller

2012-10-11 Thread Robert Rothenberg
On 11/10/12 14:16 Bill Moseley wrote:
> 
> 
> On Thu, Oct 11, 2012 at 5:38 AM, Robert Rothenberg  <mailto:rob...@gmail.com>> wrote:
> 
> 
> I would like to trap every error added to $c->error() and log it, noting 
> the
> caller (filename, line number) in the logs.
> 
> I've not gotten Catalyst::Plugin::ErrorCatcher to work, so I wrote my own
> plugin that overrides $c->error with the following method:
> 
>   use MRO::Compat;
>   use namespace::autoclean;
> 
>   sub error {
> my ($c, @args) = @_;
> 
> foreach my $arg (@args) {
> if ($arg) {
> 
> $c->log->error($arg);
> }
> }
> 
> 
> Isn't that what finalize already does?

I am using a custom error page.

More importantly: I also want to know where the error was triggered, hence
my question about using Sub::Uplevel.


___
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] Trapping added errors with the correct caller

2012-10-11 Thread Robert Rothenberg

I would like to trap every error added to $c->error() and log it, noting the
caller (filename, line number) in the logs.

I've not gotten Catalyst::Plugin::ErrorCatcher to work, so I wrote my own
plugin that overrides $c->error with the following method:

  use MRO::Compat;
  use namespace::autoclean;

  sub error {
my ($c, @args) = @_;

foreach my $arg (@args) {
if ($arg) {

$c->log->error($arg);
}
}

return $c->next::method(@args);
 }

But this only logs errors as coming from my plugin.

Using Sub::Uplevel or fiddling with $Log::Dispatch::CallerDepth or
$Catalyst::Plugin::Log::Dispatch::CallerDepth doesn't seem to work.

I also tried writing the plugin as a Moose::Role that adds my trap before
error, but then it claims to be from one of the internal Moose classes in my
logs.

I can manually get the caller using caller(0) and add them to the log
messages, but that's a bit clumsy (and overrides log formats that don't
include the information).

So... what is the best practice for trapping errors in a way that preserves
caller information?


___
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 handle role checking using a MockObject for Catalyst contexts

2012-08-22 Thread Robert Rothenberg
On 13/08/12 21:17 Wallace Reis wrote:
> On Aug 07, 2012, at 11:42 AM, Robert Rothenberg wrote:
>>> Personally, latterly, I've just been using Moose directly when I want to 
>>> mock a class:
>>>
>>> Moose::Meta::Class->create(….
> 
> And I love MX::Declare syntax sugar over this. ;)
> 
> Btw, there is another useful module out there:
> 
> https://metacpan.org/module/CatalystX::Test::MockContext

It's not very useful for me, since it only includes requests. I need logs
and authentication methods. :(


___
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 handle role checking using a MockObject for Catalyst contexts

2012-08-07 Thread Robert Rothenberg
On 06/08/12 18:36 Tomas Doran wrote:
> 
> On 6 Aug 2012, at 15:56, Robert Rothenberg wrote:
> 
>> My application has a lot of tests scripts (and even some utility scripts)
>> that create a Test::MockObject that imitates a Catalyst context.
>>
>> But it's largely a kluge, especially for handling authentication with things
>> like
>>
>>  $c->check_any_use_role(...)
>>
>> So, what are the best practices for generating a fake Catalyst context that
>> is, for all intents, logged-in as a particular user?
>>
> 
> Test::MockObject is fairly evil (it uses UNIVERSAL::can and UNIVERSAL::isa 
> which are fundamentally broken).. But this solution is entirely workable.
> 
> Personally, latterly, I've just been using Moose directly when I want to mock 
> a class:
> 
> Moose::Meta::Class->create(….
> 
> e.g. https://gist.github.com/199215 (from 
> http://bobtfish.livejournal.com/265829.html)
> 

Thanks. That looks like a much better solution.

Are there plans to make a CPAN module or include a mock context for tests in
the Catalyst distro?


___
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] How to handle role checking using a MockObject for Catalyst contexts

2012-08-06 Thread Robert Rothenberg
My application has a lot of tests scripts (and even some utility scripts)
that create a Test::MockObject that imitates a Catalyst context.

But it's largely a kluge, especially for handling authentication with things
like

  $c->check_any_use_role(...)

So, what are the best practices for generating a fake Catalyst context that
is, for all intents, logged-in as a particular user?

Regards,
Rob

___
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] Why does the installer include the 'xt' directory

2012-07-25 Thread Robert Rothenberg
On 24/07/12 21:04 Tomas Doran wrote:
> 
> On 24 Jul 2012, at 19:14, Robert Rothenberg wrote:
> 
>> On 24/07/12 18:34 Bill Moseley wrote:
>>>
>>>
>>> On Tue, Jul 24, 2012 at 9:35 AM, Robert Rothenberg >> <mailto:rob...@gmail.com>> wrote:
>>>
>>>
>>>> Try this:
>>>>
>>>>
>>>
>>> http://search.cpan.org/~bobtfish/Catalyst-Devel-1.37/lib/Module/Install/Catalyst.pm#catalyst_ignore(@ignore)
>>>
>>>
>>> Maybe run "make distclean" first?
>>>
>>> You are calling catalyst_ignore before calling catalyst in your Makefile.PL?
>>>
>>> If those are done then this always works.. :)
>>>
>>> vim $(perldoc -l Module::Install::Catalyst)
>>
>> Ok. Silly cause of the problem. The documentation says it is a regex, rather
>> than a file glob. Changing it from '.*[.]t$' to '*.t' seems to work.
>>
> 
> Doc patch please? :)

I'm not sure what it is. It doesn't work with regular expressions, but it
doesn't behave like proper file globs either.


___
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] Why does the installer include the 'xt' directory

2012-07-24 Thread Robert Rothenberg
On 24/07/12 18:34 Bill Moseley wrote:
> 
> 
> On Tue, Jul 24, 2012 at 9:35 AM, Robert Rothenberg  <mailto:rob...@gmail.com>> wrote:
>  
> 
> > Try this:
> >
> >
> 
> http://search.cpan.org/~bobtfish/Catalyst-Devel-1.37/lib/Module/Install/Catalyst.pm#catalyst_ignore(@ignore)
> 
> 
> Maybe run "make distclean" first?
> 
> You are calling catalyst_ignore before calling catalyst in your Makefile.PL?
> 
> If those are done then this always works.. :)
> 
> vim $(perldoc -l Module::Install::Catalyst)

Ok. Silly cause of the problem. The documentation says it is a regex, rather
than a file glob. Changing it from '.*[.]t$' to '*.t' seems to work.


___
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] Why does the installer include the 'xt' directory

2012-07-24 Thread Robert Rothenberg
On 24/07/12 18:34 Bill Moseley wrote:
> 
> 
> On Tue, Jul 24, 2012 at 9:35 AM, Robert Rothenberg  <mailto:rob...@gmail.com>> wrote:
>  
> 
> > Try this:
> >
> >
> 
> http://search.cpan.org/~bobtfish/Catalyst-Devel-1.37/lib/Module/Install/Catalyst.pm#catalyst_ignore(@ignore)
> 
> 
> Maybe run "make distclean" first?

Already tried that.

> You are calling catalyst_ignore before calling catalyst in your Makefile.PL?

Yes.

> If those are done then this always works.. :)
> 
> vim $(perldoc -l Module::Install::Catalyst)

Well, it's not working for me.

___
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] Why does the installer include the 'xt' directory

2012-07-24 Thread Robert Rothenberg
On 24/07/12 16:11 Bill Moseley wrote:
> 
> 
> On Tue, Jul 24, 2012 at 4:28 AM, Robert Rothenberg  <mailto:rob...@gmail.com>> wrote:
> 
> 
> Everything works fine, however, Module::Install::Catalyst installs the 
> 'xt'
> directory in lib/perl5/MyApp. Why does it do this, and how does one tell 
> it
> not to?
> 
> Try this:
> 
> http://search.cpan.org/~bobtfish/Catalyst-Devel-1.37/lib/Module/Install/Catalyst.pm#catalyst_ignore(@ignore)
>  

I did. It doesn;t seem to have any effect, because it still installs the xt
directory.


___
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] Why does the installer include the 'xt' directory

2012-07-24 Thread Robert Rothenberg
We are deploying our Catalyst apps by installing them into local::lib
directories for specific users. (Yes, I know many people prefer to just run
the application as-is from the source tree, but we don't.)

Everything works fine, however, Module::Install::Catalyst installs the 'xt'
directory in lib/perl5/MyApp. Why does it do this, and how does one tell it
not to?

___
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] user_exists dies when used from Test::WWW::Mechanize::Catalyst

2012-06-25 Thread Robert Rothenberg
On 25/06/12 13:40 Bill Moseley wrote:
> 
> 
> On Mon, Jun 25, 2012 at 7:12 AM, Robert Rothenberg  <mailto:rob...@gmail.com>> wrote:
> 
> 
> >
> > Do you really need the context?
> 
> Yes.
> 
> 
> Are there times when you may wish to use your DBIC classes outside of
> Catalyst and still need access control?  

> Even for cron jobs when we run them we need to set the "actor" so that the
> DBIC model code can determine if that actor is allowed to do that action.

No, because anything that is done outside of Catalyst will be done by the
"system" user.

> It's much more complex to set up and change a mock object, and have to 
> worry
> about whether it's set up correctly, than to log in as a particular user 
> and
> do actions that the user would normally do, and test how that affects the
> user's access permissions.
> 
> 
> I don't see that Test::WWW::Mechanize::Catalyst has a way to run
> ctx_request() from Catalyst::Test, but looks like a pretty easy hack.   I've
> used another trick with testing where I inject a controller into the app
> only when running tests where it was much easier to run the tests in an
> acton.   It's pretty rare that I need to test the context directly instead
> of the behavior of the app.   I get run a test as different users and look
> for the 403 or 200 responses.

We've tried it. It's apparently not so easy.

> But, your problem is if you want to then access the database directly from
> your script you need the context -- or something that satisfies the need of
> your DBIC code. 

That's not a problem. DBIC doesn't enforce access, nor does it need to. Only
the Catalyst application needs to enforce access.

> What about creating a new class with required attributes you need?  Then
> build that object once per request and pass that in to your DBIC code
> instead of the context object.   Then you can use that same class outside of
> Catalyst, as in your tests.
> 
> I suspect others will agree that in the long run having that tight bindig
> between Catalyst and DBIC will be a mistake. 

It's not a tight binding.



___
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] user_exists dies when used from Test::WWW::Mechanize::Catalyst

2012-06-25 Thread Robert Rothenberg
On 25/06/12 13:00 Bill Moseley wrote:
> 
> 
> On Mon, Jun 25, 2012 at 4:48 AM, Robert Rothenberg  <mailto:rob...@gmail.com>> wrote:
> 
> Several DBIC classes in our application have been customized with a method
> 
>  user_can_modify($c)
> 
> Do you really need the context? 

Yes.

> I think the suggestion is normally pass in
> the data you need, which I suspect is a user object.  Then you are not
> binding DBIC and Catalyst so tightly.
> 
> user_can_modify( $user ):

No. I need other information from the context, such as whether a user is
even logged in, the user's roles, and session information, among other things.

> Sure, you can mock up a context object, but for flexible to pass in only the
> data you really need.

It's much more complex to set up and change a mock object, and have to worry
about whether it's set up correctly, than to log in as a particular user and
do actions that the user would normally do, and test how that affects the
user's access permissions.



___
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] user_exists dies when used from Test::WWW::Mechanize::Catalyst

2012-06-25 Thread Robert Rothenberg
Several DBIC classes in our application have been customized with a method

  user_can_modify($c)

that takes a Catalyst context and checks if the user is logged in, and can
modify the record.  This seems to work fine when manually testing various
things.

But we want to write tests for this that use Test::WWW::Mechanize::Catalyst
to log a user in (and possibly run some actions that may change the user's
access), and then manually fetch a record from DBIC and test whether the
currently logged-in user can indeed modify the record.

I want the Catalyst context from a Test::WWW::Mechanize::Catalyst object,
which I assume can be gotten using

  $c = $m->catalyst_app

although this isn't documented as far as I can tell. It seems to work find
for some functions, e.g.

  $data = $c->model($TABLE)->find(...)

So my test script fetches some pages and logs a user in. But $c->user_exists
fails:

You must pass a package name and it cannot be blessed at
/usr/local/lib/perl/5.10.1/Class/MOP/Class.pm line 43
Class::MOP::Class::initialize('Class::MOP::Class', '') called at
/usr/local/lib/perl/5.10.1/Class/MOP/Attribute.pm line 297

Class::MOP::Attribute::get_raw_value('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0x5291f60)',
 'MyApp') called at /usr/local/lib/perl/5.10.1/Class/MOP/Attribute.pm line 291

Class::MOP::Attribute::get_value('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0x5291f60)',
 'MyApp') called at /usr/local/lib/perl/5.10.1/Moose/Meta/Attribute.pm line 841

Moose::Meta::Attribute::get_value('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0x5291f60)',
 'MyApp') called at 
/usr/local/share/perl/5.10.1/MooseX/Emulate/Class/Accessor/Fast/Meta/Accessor.pm
 line 13
Catalyst::Plugin::Authentication::_user('MyApp') called at
/usr/local/share/perl/5.10.1/Catalyst/Plugin/Authentication.pm line 56
Catalyst::Plugin::Authentication::user_exists('MyApp') called at 
t/test.t
line 37

Is this a bug in Moose or just a side effect due to my getting the Catalyst
context in an unorthodox way.

I'd rather not use Catalyst::Test, since it means having to replicate a lot
of the functionality of Test::WWW::Mechanize::Catalyst (not to mention that
we have various helper functions for testing our application that already
use TWMC.)





___
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/Starman server Cache::FastMmap problems when running with --background option on CentOS 6

2012-05-31 Thread Robert Rothenberg
I've changed a Catalyst application to use FastMmap session stores instead
of Files, because I am using OpenID which already requires it.

All tests pass, and the server runs fine manually:

  sudo -u myappuser /opt/perl/bin/perl -I /opt/myapp/lib/perl5
/opt/myapp/bin/myapp_server.pl -d --host 127.0.0.1 --port 3001 --keepalive
--fork --pidfile /var/opt/myapp/run/starman.pid

But when run it with the --background option, it fails with the error:

  Caught exception in engine "Lock failed: Bad file descriptor at
/opt/myapp/lib/perl5/i686-linux/Cache/FastMmap.pm line 1189." 

I am using CentOS 6.2 (2.6.32-220.el6.i686).

I can't seem to find anything about this error by Googling. Any idea what
the problem could be?


___
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] Module::Install::Catalyst and Test::Prereqs conflict?

2012-05-23 Thread Robert Rothenberg
On 23/05/12 18:42 Tomas Doran wrote:
> 
> On 23 May 2012, at 17:15, Robert Rothenberg wrote:
> 
>> On 23/05/12 17:06 Tomas Doran wrote:
>>>
>>> On 23 May 2012, at 11:26, Robert Rothenberg wrote:
>>>
>>>> I think that there is a problem using the Makefile.PL with Test::Prereqs 
>>>> and
>>>> similar modules.
>>>>
>>>> When I run prereqs_ok(), I get the following error:
>>>>
>>>> _get_prereqs: Error loading Makefile.PL: Can't call method
>>>> "load_all_extensions" on an undefined value at
>>>> /usr/local/share/perl/5.10.1/Module/Install.pm line 206,  line 4267.
>>>> BEGIN failed--compilation aborted at ./Makefile.PL line 4,  line 
>>>> 4267.
>>>
>>> What leads you to suspect that this is anything to do with 
>>> Module::Install::Catalyst?
>>>
>>> I'd have guessed at a bug between Test::Prereqs and Module::Install itself, 
>>> rather than the Catalyst specific extension..
>>
>> It occurs in some of the other modules that do the same thing, such as
>> Module::CPANTS::Kwalalitee::Prereq.

I can't figure out form a brief look at the source what might be causing it,
and asked on this list in case anyone else has come across the problem.


___
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] Module::Install::Catalyst and Test::Prereqs conflict?

2012-05-23 Thread Robert Rothenberg
On 23/05/12 17:06 Tomas Doran wrote:
> 
> On 23 May 2012, at 11:26, Robert Rothenberg wrote:
> 
>> I think that there is a problem using the Makefile.PL with Test::Prereqs and
>> similar modules.
>>
>> When I run prereqs_ok(), I get the following error:
>>
>> _get_prereqs: Error loading Makefile.PL: Can't call method
>> "load_all_extensions" on an undefined value at
>> /usr/local/share/perl/5.10.1/Module/Install.pm line 206,  line 4267.
>> BEGIN failed--compilation aborted at ./Makefile.PL line 4,  line 4267.
> 
> What leads you to suspect that this is anything to do with 
> Module::Install::Catalyst?
> 
> I'd have guessed at a bug between Test::Prereqs and Module::Install itself, 
> rather than the Catalyst specific extension..

It occurs in some of the other modules that do the same thing, such as
Module::CPANTS::Kwalalitee::Prereq.


___
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] Module::Install::Catalyst and Test::Prereqs conflict?

2012-05-23 Thread Robert Rothenberg
I think that there is a problem using the Makefile.PL with Test::Prereqs and
similar modules.

When I run prereqs_ok(), I get the following error:

_get_prereqs: Error loading Makefile.PL: Can't call method
"load_all_extensions" on an undefined value at
/usr/local/share/perl/5.10.1/Module/Install.pm line 206,  line 4267.
BEGIN failed--compilation aborted at ./Makefile.PL line 4,  line 4267.

not ok 1 -  Makefile.PL did not return a true value.
#

#   Failed test '   Makefile.PL did not return a true value.
# '
#   at /usr/local/share/perl/5.10.1/Test/Prereq.pm line 220.
#
# Looks like you failed 1 test of 1.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests




___
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] OpenID authentication just redirects back to the login page

2012-05-14 Thread Robert Rothenberg
On 14/05/12 17:34 Tomas Doran wrote:
> 
> On 14 May 2012, at 16:37, Robert Rothenberg wrote:
>>
>> Any idea's what's happening?
> 
> No, as we have no idea what code is executing, or how that code has been 
> configured.
> 
> Need debug logs from the app and details about your auth config to even start 
> guessing, sorry!

Well, I figured out the problem.

Basically, I checked that username/password were set and assumed if they
weren't that it was a new login page.

So I separated the methods that displayed the login page vs handling the
arguments, and used progressive realms. It works now.


___
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] OpenID authentication just redirects back to the login page

2012-05-14 Thread Robert Rothenberg
On 14/05/12 17:34 Tomas Doran wrote:
> 
> On 14 May 2012, at 16:37, Robert Rothenberg wrote:
>>
>> Any idea's what's happening?
> 
> No, as we have no idea what code is executing, or how that code has been 
> configured.
>
> Need debug logs from the app and details about your auth config to even
> start guessing, sorry!

Thankls. Details below.

The __PACKAGE__->config()'s authentication section includes as a realm:

authentication => {
default_realm => 'users',
realms=> {

openid => {
credential => {
class => 'OpenID',
},
ua_class => "LWPx::ParanoidAgent",
ua_args => {
whitelisted_hosts => [qw/ 127.0.0.1 localhost /],
},
},

users => {

# [Snip!]

 }


The users authentication works, BTW. I am trying to add an option for
OpenID. The Login controller's index method has the code:

my $username = lc($c->request->params->{username} // q{});
my $password = $c->request->params->{password}// q{};

my $openid_url = $c->req->params->{openid_identifier} // q{};

if  ($openid_url ne q{}) {

try {

if ($c->authenticate({ openid_identifier => $openid_url },
 'openid')) {

$log->debug("URL = " . $c->user->url);

# TODO if this works, fetch the user w/ $c->user->url?

} else {

$log->warn("Failed login '${openid_url}'");

$c->response->status(HTTP_UNAUTHORIZED);

$c->stash(
error_msg => $c->loc("Bad OpenID login"),
);

}

} catch {

$log->error("Login failure - ${ARG}");
$c->stash(
error_msg => $c->loc("Login failure."),
);

};
   }
elsif (($username ne q{}) && ($password ne q{})) {

if ($c->authenticate({ username => $username,
   password => $password,
   deleted  => 0} )) {

   # [snip!]

}

}

FWIW, I tried moving the code to a login method in the Root controller, out
of cargo-cultish insecurity. Same problem.


Debug logs (with specific details omitted for security, replaced with
"[snip!]"):

[info] MyApp powered by Catalyst 5.90011
HTTP::Server::PSGI: Accepting connections at http://0:3000/
[info] *** Request 1 (0.007/s) [24751] [Mon May 14 17:49:18 2012] ***
[debug] Path is "login"
[debug] "POST" request for "login" from "127.0.0.1"
[debug] Body Parameters are:
.--+--.
| Parameter| Value|
+--+--+
| openid_identifier| https://www.google.com/accounts/o8/- |
|  | id   |
| password |  |
| submit   | Login|
| username |  |
'--+--'

[error] Login failure - catalyst_detach

[debug] Redirecting to
"https://www.google.com/accounts/o8/ud?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.return_to=http%3A%2F%2Flocalhost%3A3000%2Flogin%3Fopenid-check%3D1%26oic.time%3D1337014159-f5836e98720e6c263f84&openid.claimed_id=[snip!]
[debug] Response Code: 302; Content-Type: text/html; charset=utf-8;
Content-Length: 725
[info] Request took 0.284954s (3.509/s)
.+---.
| Action | Time  |
++---+
| /auto  | 0.000248s |
| /login/index   | 0.276124s |
| /end   | 0.000382s |
'+---'


[info] *** Request 2 (0.014/s) [24751] [Mon May 14 17:49:19 2012] ***
[debug] Path is "login"
[debug] "GET" request for "login" from "127.0.0.1"
[debug] Query Parameters are:
.--+--.
| Parameter 

[Catalyst] OpenID authentication just redirects back to the login page

2012-05-14 Thread Robert Rothenberg
I am trying to add OpenID logins to my site. I've looked at several examples
of this, but whenever I run

  if ($c->authenticate({ openid_identifier => $openid_url }, 'openid')) {

  ...

  }


It redirects to the OpenID provider, and then redirects back to the login
page with added URL paramaters (oic.time, openid-check, openid.assoc_handle,
openid.claimed_id, openid.identity, etc.)

This doesn't seem like it's doing what it's supposed to be.

Any idea's what's happening?


___
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 "sudo" using the Authentication plugin

2012-05-12 Thread Robert Rothenberg

Actually, I came across

  Catalyst::Plugin::Authentication::Credential::NoPassword

in the latest version, which is apparently intended for the purpose of sudoing.

With a bit of fiddling, I was able to get it to work.


___
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 "sudo" using the Authentication plugin

2012-05-12 Thread Robert Rothenberg
Wait a minute: would your solution work with $c->check_any_user_role?

On 12/05/12 11:09 Robert Rothenberg wrote:
> On 11/05/12 19:18 Tomas Doran wrote:
>>
>> On 11 May 2012, at 17:45, Robert Rothenberg wrote:
>>
>>> We're working on an application with a lot of users, and where the passwords
>>> are encrypted (and future versions may also allow OpenID logins).
>>>
>>> Developers would like the ability for the "root" user to be able to become
>>> another user, for the purposes of debugging problems that real users might
>>> be having on a live system.
>>>
>>> How does one do this using the Authentication plugin?
>>>
>>> Obvious things to try like the $c->user($new_user) doesn't work, not does
>>> the (internal) $c->set_authenticated($user, $real) method.
>>>
>>
>> The recommended approach would be to keep $c->user 'pure', and to arrange to 
>> stash the current user in a top level base chain part, or top level auto.
>>
>> If everything then subsequently uses $c->stash->{current_user} - then you 
>> can do your sudo (or whatever other mechanism you may need in future) simply 
>> by swapping out the user here.
>>
>> This makes things a lot more pure - as the canonical user that $c->user will 
>> give you is (more) immutable..
>>
>> Also, if you swap the 'canonical' user part way through the request - when 
>> the session plugin comes to re-serialize the session at the end of request - 
>> you're pretty stuffed, as you're now writing out the wrong user… I.e. 
>> re-sudoing, or doing any root level action is likely to require you to log 
>> out and log in again - not what you actually want! :)
> 
> We don't mind having to log out and log back in again after sudoing.
> 
> I'm not looking forward to changing every use of $c->user in the code, and
> concerned about how this might interact with any plugins that rely on 
> $c->user.
> 
> Would you consider the ability to sudo a feature request for the
> Authentication plugin? (with appropriate thoughts about the security
> implications, of course).
> 
> Thanks,
> Rob
> 



___
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 "sudo" using the Authentication plugin

2012-05-12 Thread Robert Rothenberg
On 11/05/12 19:18 Tomas Doran wrote:
> 
> On 11 May 2012, at 17:45, Robert Rothenberg wrote:
> 
>> We're working on an application with a lot of users, and where the passwords
>> are encrypted (and future versions may also allow OpenID logins).
>>
>> Developers would like the ability for the "root" user to be able to become
>> another user, for the purposes of debugging problems that real users might
>> be having on a live system.
>>
>> How does one do this using the Authentication plugin?
>>
>> Obvious things to try like the $c->user($new_user) doesn't work, not does
>> the (internal) $c->set_authenticated($user, $real) method.
>>
> 
> The recommended approach would be to keep $c->user 'pure', and to arrange to 
> stash the current user in a top level base chain part, or top level auto.
> 
> If everything then subsequently uses $c->stash->{current_user} - then you can 
> do your sudo (or whatever other mechanism you may need in future) simply by 
> swapping out the user here.
> 
> This makes things a lot more pure - as the canonical user that $c->user will 
> give you is (more) immutable..
> 
> Also, if you swap the 'canonical' user part way through the request - when 
> the session plugin comes to re-serialize the session at the end of request - 
> you're pretty stuffed, as you're now writing out the wrong user… I.e. 
> re-sudoing, or doing any root level action is likely to require you to log 
> out and log in again - not what you actually want! :)

We don't mind having to log out and log back in again after sudoing.

I'm not looking forward to changing every use of $c->user in the code, and
concerned about how this might interact with any plugins that rely on $c->user.

Would you consider the ability to sudo a feature request for the
Authentication plugin? (with appropriate thoughts about the security
implications, of course).

Thanks,
Rob


___
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] How to "sudo" using the Authentication plugin

2012-05-11 Thread Robert Rothenberg
We're working on an application with a lot of users, and where the passwords
are encrypted (and future versions may also allow OpenID logins).

Developers would like the ability for the "root" user to be able to become
another user, for the purposes of debugging problems that real users might
be having on a live system.

How does one do this using the Authentication plugin?

Obvious things to try like the $c->user($new_user) doesn't work, not does
the (internal) $c->set_authenticated($user, $real) method.



___
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] Log::Dispatch plugin is not working when run in the background

2012-03-03 Thread Robert Rothenberg
On 02/03/12 20:29 Tomas Doran wrote:
> 
> On 2 Mar 2012, at 10:38, Robert Rothenberg wrote:
> 
>> This appears to be fixed by adding the
>>
>>  close_after_write true
>>
>> option. I'm not sure that I understand *why* not using this option causes it
>> to exit or just not write anything, but that seems to be what happens.
>>
>> I'm not sure if this is a Catalyst of Log::Dispatch issue.
> 
> It's a Catalyst issue.
> 
> --background is using MooseX::Daemonize, which closes all open file handles 
> when backgrounding.
> 
> close_after_write works around this by re-opening the file for each write, 
> however that's not amazing (as you do many more syscalls than necessary).
> 
> I have just pushed a fix for this into master - any chance you could try it 
> out and confirm that the issue is fixed for you?

A fix on the plugin, or Catalyst?

___
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] Re: Log::Dispatch plugin is not working when run in the background

2012-03-02 Thread Robert Rothenberg
This appears to be fixed by adding the

  close_after_write true

option. I'm not sure that I understand *why* not using this option causes it
to exit or just not write anything, but that seems to be what happens.

I'm not sure if this is a Catalyst of Log::Dispatch issue.

On 29/02/12 13:08 Robert Rothenberg wrote:
> On my development machine, Log::Dispatch works fine with the following
> option in myapp.conf:
> 
>  
>   class File::Locked
>   filename /var/opt/myapp/log/catalyst.log
>   min_level info
>   mode append
>   format "[%d] [%p] %m %n"
>  
> 
> but when it runs with the --background option, it exits rather than logging
> anything.  As far as I can tell, the user has the correct permissions.
> 
> On a testing server, where it runs in the background, it does not output
> anything, but does not exit. The user it runs as has permissions to write to
> the directory, and even creates the log file if it doesn't exist, but
> nothing is actually written to it.
> 
> Any ideas why this is happening?


___
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] Log::Dispatch plugin is not working on one machine

2012-02-29 Thread Robert Rothenberg
On my development machine, Log::Dispatch works fine with the following
option in myapp.conf:

 
  class File::Locked
  filename /var/opt/myapp/log/catalyst.log
  min_level info
  mode append
  format "[%d] [%p] %m %n"
 

but when it runs with the --background option, it exits rather than logging
anything.  As far as I can tell, the user has the correct permissions.

On a testing server, where it runs in the background, it does not output
anything, but does not exit. The user it runs as has permissions to write to
the directory, and even creates the log file if it doesn't exist, but
nothing is actually written to it.

Any ideas why this is happening?

___
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] Setting flash for tests

2012-02-17 Thread Robert Rothenberg
The Login controller, on a successful login, will redirect to the location
in $c->{flash}->{next}, if it is set. (Basically, if the user visits a page
that requires a login, he is redirected to the login page, and then is
redirected back to the original page.)

As far as I can tell, it works alright.

I am unsure how to test this using Catalyst::Test, though.

How can I set the "next" variable so as to test redirection?

Thanks,
Rob

___
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] Using Test::WWW::Mechanize::Catalyst on a test database

2012-02-16 Thread Robert Rothenberg
On 15/02/12 22:51 Kieren Diment wrote:
> 
> 
> On 16/02/2012, at 9:45 AM, Robert Rothenberg wrote:
> 
>> On 15/02/12 16:03 Jesse Sheidlower wrote:
>>> On Wed, Feb 15, 2012 at 03:25:51PM +, Robert Rothenberg wrote:
>>>> I would like to use Test::WWW::Mechanize::Catalyst with an alternative
>>>> database schema (since I want to test reading and writing on a database 
>>>> with
>>>> the same schema but known data that is not the live database), but it's not
>>>> clear to me from reading the documentation on how to do this, or even if
>>>> it's possible.
>>>
>>> Very much so. Have you looked at
>>>
>>> http://search.cpan.org/~hkclark/Catalyst-Manual-5.9002/lib/Catalyst/Manual/Tutorial/08_Testing.pod#SUPPORTING_BOTH_PRODUCTION_AND_TEST_DATABASES
>>
>> This isn't working. It's clearly trying to load the myapp_testing.conf file
>> (because it complains if I put in syntax errors), but the database
>> connection info is not being overridden, and it's wiping the production
>> database.
> 
> Can you produce a minimal test case demonstrating this and put it on the RT 
> queue for Catalyst::Manual please?

Turns out to be a configuration issue on my end. (Another dev renamed
something and didn't fix the configuration.) It works now.


___
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] Using Test::WWW::Mechanize::Catalyst on a test database

2012-02-16 Thread Robert Rothenberg
On 15/02/12 22:51 Kieren Diment wrote:
> 
> 
> On 16/02/2012, at 9:45 AM, Robert Rothenberg wrote:
> 
>> On 15/02/12 16:03 Jesse Sheidlower wrote:
>>> On Wed, Feb 15, 2012 at 03:25:51PM +, Robert Rothenberg wrote:
>>>> I would like to use Test::WWW::Mechanize::Catalyst with an alternative
>>>> database schema (since I want to test reading and writing on a database 
>>>> with
>>>> the same schema but known data that is not the live database), but it's not
>>>> clear to me from reading the documentation on how to do this, or even if
>>>> it's possible.
>>>
>>> Very much so. Have you looked at
>>>
>>> http://search.cpan.org/~hkclark/Catalyst-Manual-5.9002/lib/Catalyst/Manual/Tutorial/08_Testing.pod#SUPPORTING_BOTH_PRODUCTION_AND_TEST_DATABASES
>>
>> This isn't working. It's clearly trying to load the myapp_testing.conf file
>> (because it complains if I put in syntax errors), but the database
>> connection info is not being overridden, and it's wiping the production
>> database.
> 
> Can you produce a minimal test case demonstrating this and put it on the RT 
> queue for Catalyst::Manual please?

My test case uses Catalyst::Test instead of Test::WWW::Mechanize::Catalyst,
because I need to get the schema to run deploy() on it. (It's also helpful
in the tests to actually check that I am connected to the test schema!)

How do I get the schema from Test::WWW::Mechanize::Catalyst?


___
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] Using Test::WWW::Mechanize::Catalyst on a test database

2012-02-15 Thread Robert Rothenberg
On 15/02/12 16:03 Jesse Sheidlower wrote:
> On Wed, Feb 15, 2012 at 03:25:51PM +0000, Robert Rothenberg wrote:
>> I would like to use Test::WWW::Mechanize::Catalyst with an alternative
>> database schema (since I want to test reading and writing on a database with
>> the same schema but known data that is not the live database), but it's not
>> clear to me from reading the documentation on how to do this, or even if
>> it's possible.
> 
> Very much so. Have you looked at
> 
> http://search.cpan.org/~hkclark/Catalyst-Manual-5.9002/lib/Catalyst/Manual/Tutorial/08_Testing.pod#SUPPORTING_BOTH_PRODUCTION_AND_TEST_DATABASES

This isn't working. It's clearly trying to load the myapp_testing.conf file
(because it complains if I put in syntax errors), but the database
connection info is not being overridden, and it's wiping the production
database.



___
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] Using Test::WWW::Mechanize::Catalyst on a test database

2012-02-15 Thread Robert Rothenberg
On 15/02/12 16:03 Jesse Sheidlower wrote:
> On Wed, Feb 15, 2012 at 03:25:51PM +0000, Robert Rothenberg wrote:
>> I would like to use Test::WWW::Mechanize::Catalyst with an alternative
>> database schema (since I want to test reading and writing on a database with
>> the same schema but known data that is not the live database), but it's not
>> clear to me from reading the documentation on how to do this, or even if
>> it's possible.
> 
> Very much so. Have you looked at
> 
> http://search.cpan.org/~hkclark/Catalyst-Manual-5.9002/lib/Catalyst/Manual/Tutorial/08_Testing.pod#SUPPORTING_BOTH_PRODUCTION_AND_TEST_DATABASES

So this requires maintaining two database schemas?

(I guess I could have the script deploy to the test schema, though.)

Regards,
Rob

___
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] Using Test::WWW::Mechanize::Catalyst on a test database

2012-02-15 Thread Robert Rothenberg
I would like to use Test::WWW::Mechanize::Catalyst with an alternative
database schema (since I want to test reading and writing on a database with
the same schema but known data that is not the live database), but it's not
clear to me from reading the documentation on how to do this, or even if
it's possible.

I've found examples using Catalyst::Test with DBICx::TestDatabase, but I
cannot get it to work. The line

  $c->model('DBIC')->schema($schema);

fails with

  Can't call method "schema" on an undefined value...

Worse, the application uses some PostgreSQL extensions, so
DBICx::TestDatabase is not appropriate.

I am looking into Test::DBIx::Class as an alternative, but again, it's still
not clear how to change the database that Test::WWW::Mechanize uses.

Regards,
Rob

___
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] Setting rel_collision_map in myapp_create.pl

2012-02-09 Thread Robert Rothenberg
The application that I am working on uses myapp_create.pl to create the
model from the database schema.

The problem is that the DBIx::Schema::Loader is creating a relationship with
a name that is inappropriate, and conflicts with a relationship that I've
manually created.

In this case, there is a table of "group", "employee" and a third table
"employee_group" that links employees to groups. The group table has a
"leader" field that references an employee who is the group leader. DBIC has
decided to create a relationship on players called "groups" that basically
says what groups the employee is the leader of.  Not a very good name, and
of course conflicts with the "groups" relationship that I created, that
indicates what groups an employee is actually in. (Yes, there is an
"employee_groups" relation, but I added the "groups" relation to bridge that
indirection.)

Looking at the documentation for DBIx::Schema::Loader, there is an option
called rel_collision_map that can supposedly be used to fix this. I'm unsure
how it works, and even less sure how to pass a hash as an option to the
myapp_create.pl script.

If that option is supported, examples would be helpful.

___
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] What are the best practices for using phrasebooks inCatalyst applications?

2012-01-31 Thread Robert Rothenberg

Thanks. This works well.

One question: how do I configure Catalyst to watch the locales directory and
restart when they are changed (at least while in debugging mode)?

On 27/01/12 13:45 Octavian Rasnita wrote:
> :
> :
> If the terminology differs, then you may use I18N.
> 
> You could define your own "languages" for all the terminologies you need, set 
> the current "language" with:
> 
> $c->languages([$language]);
> 
> and then you'll just need to use something like:
> 
> [% l('widgets') | html %]
> 
> where l() is a macro defined with:
> 
> [% MACRO l(text,args) BLOCK; c.localize(text,args) || text; END ~%]
> 
> It may work unless the site already needs to use I18N for real languages.

___
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] uri_for method is returning relative URLs

2012-01-27 Thread Robert Rothenberg
On 21/01/12 21:49 Jason Galea wrote:

> On Jan 22, 2012 1:35 AM, "Robert Rothenberg"  <mailto:rob...@gmail.com>> wrote:
>> :
>> :
>> Ok, it's working now. Apparently including the default fastcgi_params, even
>> when they are edited to have the exact same values, does not seem to work.
> 
> For history's sake, can you just confirm what DID work for you?

Following the *exact* instructions in

https://metacpan.org/module/Catalyst::Manual::Deployment::nginx::FastCGI#Configuration


Basically, including the settings in the /etc/nginx/conf.d/myapp.conf file
rather than relying on the default settings in /etc/gninx/fastcgi.conf that
had the same values as the instructions.

___
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] What are the best practices for using phrasebooks in Catalyst applications?

2012-01-27 Thread Robert Rothenberg

I am working on a project where the terminology we are using for "objects"
in the system is diverging from terminology that the client is using for
those things.  And it also seems that other clients may use different names
for these objects. (And this is just for English-language interfaces.)

So I would like to use some kind of phrasebook, so that the source code can
use the same, consistent terminology, but the clients see their terminology
in the UI.

I'd prefer not to maintain a separate set of templates for each client,
since that requires keeping changes to templates consistent across sets, and
requires keeping changes to terminology consistent in a set.

So... is there an existing plugin that is used for such things?

Otherwise, I am thinking of writing a plugin that makes use of
Data::Phrasebook (or something similar), allows for configuration of the
phrasebook in the configuration file, and adds a new method to the Catalyst
context variable for querying the phrasebook, e.g. the template may have
something like

  [% c.phrase('widgets') | html %]

Does this make sense, or is there a better way to do this?

Thanks,
Rob



___
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] Setting the COMPILE_DIR for TT templates in the configuration file

2012-01-23 Thread Robert Rothenberg
On 23/01/12 17:39 André Walker wrote:
> On 01/22/2012 06:16 PM, Robert Rothenberg wrote:
>> It doesn't quite look like what I expect. Excerpts:
>>
>> "Plugin::Session" =>  {
>>   storage =>  "/tmp/myapp/session",
>>   },
>>
>>   "View::TT"=>  {
>>   COMPILE_DIR =>  "/tmp/myapp/template_cache",
>>   },
>>
>> Those are the defaults that are set in the module. I want to override them
>> in the conf file.
> Hold on. Does it mean that you're setting COMPILE_DIR to
> "/tmp/myapp/template_cache" on MyApp::View::TT and you're trying to override
> it on the config file?
> Can you show us View/TT.pm please? I'm pretty sure that changing the config
> in the component module overrides the *.conf file, but couldn't find it in
> the docs.

According to what I read in the docs, setting it in the conf file should
override the module.



___
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] Setting the COMPILE_DIR for TT templates in the configuration file

2012-01-23 Thread Robert Rothenberg
On 23/01/12 09:41 Alexander Hartmaier wrote:
> Have you loaded Catalyst::Plugin::ConfigLoader?


Yes, of course. (In the original e-mail, I did say that I can set some
things in the .conf file, but not the specific things that I am asking about.)

> 
> Am 2012-01-23 10:29, schrieb Robert Rothenberg:
>> On 23/01/12 09:14 Alexander Hartmaier wrote:
>>> Hi Robert,
>>> what config format are you using?
>>> If the file has the extension .conf Config::General is used and your
>>> example should work.
>> I am using the general format, but it doesn't work.


___
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] Setting the COMPILE_DIR for TT templates in the configuration file

2012-01-23 Thread Robert Rothenberg
On 23/01/12 09:14 Alexander Hartmaier wrote:
> Hi Robert,
> what config format are you using?
> If the file has the extension .conf Config::General is used and your
> example should work.

I am using the general format, but it doesn't work.

___
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] Setting the COMPILE_DIR for TT templates in the configuration file

2012-01-22 Thread Robert Rothenberg
On 22/01/12 19:58 Tomas Doran wrote:
> 
> On 22 Jan 2012, at 18:54, Robert Rothenberg wrote:
> 
>> 
>> COMPILE_DIR /var/opt/myapp/template_cache
>> 
>>
>> where MyApp::View::TT is the name of the view module.
>>
>> None of them work. How do I do this?
> 
> This should work.
> 
> http://localhost:3000/?dump_info=1
> 
> will dump the config that the app has actually read in and merged (assuming
> you've got debug mode on and you're using the standard RenderView plugin).
>
> Does the config dumped look like you expect? Can you show us?

It doesn't quite look like what I expect. Excerpts:

"Plugin::Session" => {
 storage => "/tmp/myapp/session",
 },

 "View::TT"=> {
 COMPILE_DIR => "/tmp/myapp/template_cache",
 },

Those are the defaults that are set in the module. I want to override them
in the conf file.

But setting in the conf file:


  storage /var/opt/myapp/session


or similarly for  does not change those values. (I know setting
other things such as the DSN in the conf works, so it's the right file).

Rob



> 
> Are you customising your TT view in any way (i.e. adding extra code yourself
> - specifically to the constructor). Do you have a make_immutable in there?
> (Can you show us the whole file?)
> 
> Cheers
> t0m
> 
> 
> ___
> 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/


[Catalyst] Re: Setting the COMPILE_DIR for TT templates in the configuration file

2012-01-22 Thread Robert Rothenberg
On 22/01/12 18:54 Robert Rothenberg wrote:
> I would like to set the COMPILE_DIR for TT templates in the configuration
> file, rather than hardcode it in the MyApp::View::TT file. I have tried the
> following:

Similarly, Catalyst creates a /tmp/myapp directory. I'd like it to be in
/var/opt/myapp/tmp. I'm unsure what to configure.


___
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] Setting the COMPILE_DIR for TT templates in the configuration file

2012-01-22 Thread Robert Rothenberg
I would like to set the COMPILE_DIR for TT templates in the configuration
file, rather than hardcode it in the MyApp::View::TT file. I have tried the
following:

compile_dir /var/opt/myapp/template_cache

COMPILE_DIR /var/opt/myapp/template_cache


  compile_dir /var/opt/myapp/template_cache



COMPILE_DIR /var/opt/myapp/template_cache


where MyApp::View::TT is the name of the view module.

None of them work. How do I do this?


___
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] Relocating the configuration file

2012-01-21 Thread Robert Rothenberg
Another question: I would like the configuration file to be in
/opt/myapp/etc instead of /opt/myapp/lib/MyApp.

How do I configure Catalyst to look for configuration files in an
alternative location?  I haven't found very clear documentation on this.

___
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] uri_for method is returning relative URLs

2012-01-21 Thread Robert Rothenberg
On 18/01/12 12:36 Tomas Doran wrote:
> 
> On 18 Jan 2012, at 12:03, Robert Rothenberg wrote:
> 
>> I'm relying on the default /etc/nginx/fastcgi.conf - which has the exact
>> same values that the document says.
> 
> Oh no it doesn't!
> 
>> Do I need to manually move them into the configuration for that virtual host?
> 
> Nope.
> 
> But the default config _is not correct_.

Ok, it's working now. Apparently including the default fastcgi_params, even
when they are edited to have the exact same values, does not seem to work.

Thanks.

___
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] Makefile.PL seems to be ignoring INSTALL_BASE

2012-01-21 Thread Robert Rothenberg
So we are trying to set up Catalyst on a freshly minted CentOS 6 machine.

On this machine, we've decided to build Perl 5.12.3 to use with web
applications and install in /opt/perl rather than use the vendor's Perl.

Moose, DBIx::Class, Catalyst and several other modules were installed in
/opt/perl/lib using cpanminus (/opt/perl/bin/cpanm).

We want to install the application in /opt/appname.

But when we run

  /opt/perl/bin/perl Makefile.PL INSTALL_BASE=/opt/appname

Module::Install wants to install the dependencies in /opt/perl instead of
/opt/appname.

The most recent ExtUtils::MakeMaker and related modules are installed.

We've been able to work around this by building the distribution and using
cpanminus to install it.

But this seems like a hack.

Is there a better way to tell the installer to install additional modules in
the base?

Thanks,
Rob

___
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] uri_for method is returning relative URLs

2012-01-18 Thread Robert Rothenberg
On 18/01/12 11:11 Tomas Doran wrote:
> 
> On 18 Jan 2012, at 09:58, Robert Rothenberg wrote:
>>
>> So is there something about FastCGI that is doing this?
> 
> You're getting the config wrong.
> 
> Every single case I've seen of anything like this in the last 12+ months
> (since I fixed it) has been where the user isn't correctly setting up the
> fastcgi_params in their nginx config.
> 
> It needs to be _exactly_ like this:
> 
> https://metacpan.org/module/Catalyst::Manual::Deployment::nginx::FastCGI#Configuration
> 
> 
> Otherwise it won't work as expected.

I'm relying on the default /etc/nginx/fastcgi.conf - which has the exact
same values that the document says.

Do I need to manually move them into the configuration for that virtual host?

___
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] uri_for method is returning relative URLs

2012-01-18 Thread Robert Rothenberg
On 17/01/12 18:09 Alexander Hartmaier wrote:
> uri_for falls back to interpreting the passed string as plain string,
> like a path to a static resource, not an action.
> To make sure it returns an url for an action use uri_for_action instead
> which will die if it can't the action.

It also does the same thing for static resources, like stylesheets and
JavaScript files.

More details: it turns out that this occurs when using the app_fastcgi.pl
server (through nginx).

When running app_server.pl and changing nginx to make use of
Catalyst::Engine::HTTP::Prefork, this problem doesn't occur.

So is there something about FastCGI that is doing this?


> 
> Am 2012-01-17 18:43, schrieb Robert Rothenberg:
>> I have a Catalyst app that I have been working on with another developer.
>>
>> In this application, the links in the templates use the uri_for method, e.g.
>>
>>Login
>>
>> This works fine on two machines that we have been developing on.
>>
>> I've recently installed it on a third machine with Perl 5.12.3 and Catalyst
>> 5.90007.  On that machine, the method seems to be returning relative URLs,
>> e.g. on the page "/login", c.uri_for("/logout") returns a link to
>> "/login/logout" instead of "/logout".
>>
>> Has anybody seen this issue before?
>>
>>
>>
>>
>>
>> ___
>> 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/
> 
> 
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
> Handelsgericht Wien, FN 79340b
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> Notice: This e-mail contains information that is confidential and may be
> privileged.
> If you are not the intended recipient, please notify the sender and then
> delete this e-mail immediately.
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> 
> ___
> 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/


[Catalyst] uri_for method is returning relative URLs

2012-01-17 Thread Robert Rothenberg

I have a Catalyst app that I have been working on with another developer.

In this application, the links in the templates use the uri_for method, e.g.

  Login

This works fine on two machines that we have been developing on.

I've recently installed it on a third machine with Perl 5.12.3 and Catalyst
5.90007.  On that machine, the method seems to be returning relative URLs,
e.g. on the page "/login", c.uri_for("/logout") returns a link to
"/login/logout" instead of "/logout".

Has anybody seen this issue before?





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