Re: [Catalyst] Simple question about "use Catalyst"

2015-10-19 Thread David Schmidt
My guess, it makes sure you run at least v5.80 possibly because older
versions are not supported anymore. I am sure someone will correct me
if I am wrong.

http://perldoc.perl.org/functions/use.html

"If the VERSION argument is present between Module and LIST, then the
use will call the VERSION method in class Module with the given
version as an argument. The default VERSION method, inherited from the
UNIVERSAL class, croaks if the given version is larger than the value
of the variable $Module::VERSION"

On 19 October 2015 at 15:21, Andrew  wrote:
>
> I ran catalyst.pl to create a new app (at least I think that's how I did it
> - it was a couple of days back now),
> and when I opened the main pm file, near the top was:
>
> use Catalyst::Runtime 5.80;
>
> I'd just installed Catalyst 5.90101 via cpanm, so wasn't sure why 5.80 was
> written there (for compatibility reasons?),
> so as I modify the script to suit my purposes, I've changed it to:
>
> use Catalyst::Runtime 5.90101;
>
> ...does it do anything, or make any difference?
> What was the significance of 5.80 being written there?
> Should I have left it as it was?
>
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Catalyst authentication w/ CAS

2015-09-09 Thread David Schmidt
Have you looked at the test application of the CAS module?

https://metacpan.org/source/KKANE/Catalyst-Authentication-Credential-CAS-0.05/t/lib/MyApp/lib/MyApp.pm

On 9 September 2015 at 05:40, Baron Fujimoto
 wrote:
> Hello,
>
> ObWarning: Total Catalyst noob here. I'm fairly familiar with Perl, but
> am just getting started with Catalyst. I'm more used to back-end, or
> command line type perl applications and utilities, but now I'm trying to
> develop a fairly simple web application and my survey of options turned
> up Catalyst. So far I've run through the tutorials up through
> Authorization at ,
> though I won't pretend I've grokked most of it yet.
>
> One of the reasons I've decided to try Catalyst, is that I would like to
> authenticate the app's users with JASIG's CAS, and I noted that there's a
> Catalyst::Authentication::Credential::CAS module.
>
> Is there a more fleshed out example of using this than in the metacpan
> documentation?
>
> I'm starting with trying to add CAS authentication to what is basically
> the Tutorial's Hello World app at the end of
> 
>
> Per the Authentication tutorial and the documentation for
> Catalyst::Authentication::Credential::CAS, I have the following in
> lib/MyApp.pm:
>
>
> use Catalyst qw/
> -Debug
> ConfigLoader
> Static::Simple
>
> StackTrace
>
> Authentication
>
> Session
> Session::Store::File
> Session::State::Cookie
> /;
>
> ...
> # modified to match the style in the AuthN tutorial
> __PACKAGE__->config(
> 'Plugin::Authentication' => {
> default_realm => 'default',
> default => {
> credential => {
> class  => 'CAS',
> uri=> 'https://cas.example.com/cas',
> #username_field => 'username', # optional
> #version=> '2.0',  # optional
> },
> },
> #store => {
> #  ...
> #},
> },
> );
>
> And in lib/MyApp/Controller/Root.pm:
>
> When the development server reloads, I get the following output:
>
> [debug] Debug messages enabled
> [debug] Statistics enabled
> [debug] Loaded Config ".../MyApp/myapp.conf"
> [debug] Setting up auth realm default
> [debug] No Store specified for realm "default", using the Null store.
> Global symbol "$c" requires explicit package name at
> +.../MyApp/script/../lib/MyApp/Controller/Root.pm line 74.
> Global symbol "$c" requires explicit package name at
> +.../MyApp/script/../lib/MyApp/Controller/Root.pm line 74.
> Global symbol "$c" requires explicit package name at
> +.../MyApp/script/../lib/MyApp/Controller/Root.pm line 75.
> Global symbol "$c" requires explicit package name at
> +.../MyApp/script/../lib/MyApp/Controller/Root.pm line 76.
> BEGIN not safe after errors--compilation aborted at
> +.../MyApp/script/../lib/MyApp/Controller/Root.pm line 79.
>
> I had commented out 'store' in the Plugin::Authentication config hash
> since I wasn't sure what to use there yet, and at least it seems nominally
> ok with a "Null" store for now.
>
> I'm not sure why the global symbol errors though, since since $c is used
> in the other methods.
>
> I apologize for what are probably very basic questions, but I would
> appreciate any guidance here.
>
> Aloha,
> -baron
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] Where best to store database connection information?

2015-02-16 Thread David Schmidt
the catalyst configloader can load more then just one file.

by default it loads "myapp.conf"

if a file named "myapp_local.conf" exists it is loaded aswell.

docs: 
https://metacpan.org/pod/distribution/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader/Manual.pod#Using-a-local-configuration-file

On 16 February 2015 at 15:42, Adam Witney  wrote:
> Hi,
>
> I have a Catalyst / DBIx::Class application and I have been storing the 
> database connection parameters in a config file which is sourced using 
> MYAPP_CONFIG_LOCAL_SUFFIX. But this seems a bit of a security problem having 
> the main password in a text file like this, especially if it goes into git.
>
> Is there a recommended or best practice place to store database connection 
> information?
>
> Thanks for any help
>
> Adam
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] How to get default()-like behavior outside of the Root controller

2015-02-09 Thread David Schmidt
On 9 February 2015 at 10:59, Dmitry L.  wrote:
> I'd rather split one application into several (admin app, survey app,
> etc) and "join" its via middleware.

I wrote a blog article a few months ago:
http://blogs.perl.org/users/davewood/2014/08/splitting-a-catalyst-app-and-recombining-it-with-plackbuilder.html

___
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 5.90080 on CPAN!

2015-01-19 Thread David Schmidt
you could install new versions of CPAN modules into a local::lib
directory and run your testsuite afterwards to see if the upgrade
works for you. if it doesnt work simply delete the local::lib
directory and you all updates are undone.

https://metacpan.org/pod/local::lib

another option that I like to use is to make a git repository out of
my perl5 folder, if something breaks I roll back.

On 19 January 2015 at 11:22, Craig Chant  wrote:
> Hi,
>
> Should I always update my Catalyst and if so, can someone please point me to 
> the upgrade step by step documentation.
>
> I remember the last time I re-installed Catalyst due to getting a new PC and 
> when firing up my dev machine it refused to run the app because it had been 
> developed on a different version of Catalyst.
>
> I've been reluctant to change / upgrade anything ever since and would 
> appreciate some guidance as I don't' think just replacing / upgrading the 
> Catalyst Runtime will work?
>
> I'm currently running ...
>
> Devel : Version 1.37
> Runtime: Version 5.90062
>
> Note: I use Perl Package Manager on Windows IIS, so anything with CLI *nix is 
> not helpful.
>
> Many thanks,
>
> Craig (SSPL)
>
> -Original Message-
> From: John Napiorkowski [mailto:jjn1...@yahoo.com]
> Sent: 09 January 2015 17:18
> To: The Elegant MVC Web Framework
> Subject: [Catalyst] Catalyst 5.90080 on CPAN!
>
> Hey All!
>
> We just cut 5.90080 release to stable.
>
> Get it => https://metacpan.org/release/JJNAPIORK/Catalyst-Runtime-5.90080
>
> Info and overview =>
> http://jjnapiorkowski.typepad.com/modern-perl/2015/01/perl-catalyst-590080-released-to-cpan.html
>
> Enjoy and shout out if you see trouble!
>
> jnap
>
> ___
> 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/
> This Email and any attachments contain confidential information and is 
> intended solely for the individual to whom it is addressed. If this Email has 
> been misdirected, please notify the author as soon as possible. If you are 
> not the intended recipient you must not disclose, distribute, copy, print or 
> rely on any of the information contained, and all copies must be deleted 
> immediately. Whilst we take reasonable steps to try to identify any software 
> viruses, any attachments to this e-mail may nevertheless contain viruses, 
> which our anti-virus software has failed to identify. You should therefore 
> carry out your own anti-virus checks before opening any documents. HomeLoan 
> Partnership will not accept any liability for damage caused by computer 
> viruses emanating from any attachment or other document supplied with this 
> e-mail. HomeLoan Partnership reserves the right to monitor and archive all 
> e-mail communications through its network. No representative or employee of 
> HomeLoan Partnership h
 as the authority to enter into any contract on behalf of HomeLoan Partnership 
by email. HomeLoan Partnership is a trading name of H L Partnership Limited, 
registered in England and Wales with Registration Number 5011722. Registered 
office: Pharos House, 67 High Street, Worthing, West Sussex, BN11 1DN. H L 
Partnership Limited is authorised and regulated by the Financial Conduct 
Authority.
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] Catalyst Advent Calendar 2014

2014-12-05 Thread David Schmidt
6 articles have been committed so far

http://dev.catalystframework.org/repos/Catalyst/trunk/examples/CatalystAdvent/root/2014/

On 5 December 2014 at 10:16, Duncan Garland
 wrote:
> John N published an appeal for help a few days ago.
>
> http://blogs.perl.org/users/john_napiorkowski/2014/12/catalyst-advent-2014.html
>
> Is the situation under control now or are we still very short of articles?
>
>
>
> The information contained in this message is for the intended addressee only
> and may contain confidential and/or privileged information. If you are not
> the intended addressee, please delete this message and notify the sender; do
> not copy or distribute this message or disclose its contents to anyone. Any
> views or opinions expressed in this message are those of the author and do
> not necessarily represent those of Motortrak Limited or of any of its
> associated companies. No reliance may be placed on this message without
> written confirmation from an authorised representative of the company.
>
> Registered in England 3098391 V.A.T. Registered No. 667463890
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Help on Catalyst::Plugin::RunAfterRequest

2014-10-06 Thread David Schmidt
If you run a long-running process inside of your webserver process the
process will not be available to handle new web requests anymore. you
probably want a job-queue of some sort.

http://stackoverflow.com/questions/25277158/run-asynchronous-methods-in-catalyst-perl

http://blogs.perl.org/users/davewood/2014/07/asynchronuous-task-distribution-with-anyevent-and-zeromq.html

cheers
david

On 6 October 2014 15:53, Antonio Soro  wrote:
> Hello,
> I plan to run server code in asynchronous mode after a response back to the
> client made from an action code in a Catalyst controller.
>
> I'm using Catalyst::Plugin::RunAfterRequest plugin in a Catalyst 5.80
> environment started in 'FastCGI' mode, called by Apache2 httpd server, with
> FastCgiExternalServer directive of mod_fastcgi.c module (v2.4.6), in a Linux
> UBUNTU box with Perl 5.12.4.
>
> It seems, in that environment, response for client request occurs after long
> time processing, differently that I run Catalyst Runtime in 'Server' mode
> where response back to the client occurs immediately and long time processing
> occurs delayed.
>
> Can somebody tell me this behavior is correct or there is something wrong?
> Are there better methods to call long-time-running code across
> Apache/FastCGI/Catalyst ?
>
> Thanks for feedback.
> Antonio Soro.
>
> ---
> Questa comunicazione e ogni eventuale file allegato sono confidenziali
> e destinati all'uso esclusivo del destinatario. Se avete ricevuto
> questo messaggio per errore Vi preghiamo di comunicarlo al mittente e
> distruggere quanto ricevuto.
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] Catalyst Unicode

2014-01-31 Thread David Schmidt
https://metacpan.org/pod/release/JJNAPIORK/Catalyst-Runtime-5.90053/lib/Catalyst/Upgrading.pod#Catalyst::Plugin::Unicode::Encoding-is-now-core


and in your test script, im pretty sure if you are using unicode chars
in your perl code you have to "use utf8" in it.

also, "use warnings" instead of "perl -w"

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode;
my $encoding = Encode::find_encoding("UTF-8");
warn "Encoding: $encoding\n";
my $t = "Ümläuts";
warn "Is utf8: ", Encode::is_utf8($t), " ", utf8::is_utf8($t), "\n";
$encoding->decode($t);
# utf8::decode($t);
warn "Is utf8: ", Encode::is_utf8($t), " ", utf8::is_utf8($t), "\n";
binmode STDOUT, ':utf8';
print "T=$t\n";


david@nio:~$ perl foo.pl
Encoding: Encode::utf8=HASH(0x1f22390)
Is utf8: 1 1
Is utf8:
T=Ümläuts

On 31 January 2014 12:29, Christian Lackas  wrote:
> Hi Everybody,
>
> I noticed that paramters in my Catalyst application are not
> automatically decoded to UTF-8, although I use
>
> use Catalyst qw/
> ...
> Unicode::Encoding
> ...
> /;
> __PACKAGE__->config(
> ...
> encoding => 'UTF-8',
> ...
> );
>
> I tracked this down to Catalyst::Plugin::Unicode::Encoding::\
> _handle_param_unicode_decoding() where I find the line
>
> $enc->decode($value, $CHECK)
>
> that does not seem to have the (my) expected outcome.
>
> Here is a small test script:
>
> #!perl -w
> use strict;
> use Encode;
> my $encoding = Encode::find_encoding("UTF-8");
> warn "Encoding: $encoding\n";
> my $t = "Ümläuts";
> warn "Is utf8: ", Encode::is_utf8($t), " ", utf8::is_utf8($t), "\n";
> $encoding->decode($t);
> # utf8::decode($t);
> warn "Is utf8: ", Encode::is_utf8($t), " ", utf8::is_utf8($t), "\n";
> binmode STDOUT, ':utf8';
> print "T=$t\n";
> --
> $ perl enc.pl
> Encoding: Encode::utf8=HASH(0x1994cb8)
> Is utf8:
> Is utf8:
> T=Ümläuts
>
> When I replace above '$encoding->decode($t)' with 'utf8::decode($t)'
> then it works as expected:
>
> $ perl enc.pl
> Encoding: Encode::utf8=HASH(0x1e02cb8)
> Is utf8:
> Is utf8: 1 1
> T=Ümläuts
>
> What am I doing wrong here? Or do I misunderstand what this code should
> do? Any hints are highly appreciated. Thanks.
>
> Christian
>
> --
> Dr. Christian Lackas, Managing Partner
> inviCRO, LLC -- In Imaging Yours
> P: +1 617 963 0263, F: +49 2203 9034722, E: lac...@invicro.com
> http://www.invicro.com/  http://www.spect-ct.com/
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] Can't detach from root / create action object

2013-11-27 Thread David Schmidt
You should tell us what you want to achieve.

"I want to pass an action to detach()" is not a proper problem description.


The documentation is pretty clear on what is expected.
https://metacpan.org/pod/Catalyst#c-detach-action-arguments

$c->detach( $action [, \@arguments ] )
$c->detach( $class, $method, [, \@arguments ] )
$c->detach()

Have you checked the Catalyst Tutorial. It should provide examples for detach()
There is also the test suite which you can grep for detach.





On 27 November 2013 13:00, Craig Chant  wrote:
> I seem to be going round in circles unable to understand how I create an
> action object so I can pass it to detach as the IRC has told me to pass in
> an action and not what I thought which was ‘controller_name, subroutine’.
>
>
>
> E.G.
>
>
>
> $c->detach(‘my_controller_name’,’index’);
>
>
>
> But it seems that this signature is  (‘class_name’, ‘subroutine’)
>
>
>
> I’m having a problem with Catalyst randomly deciding when it is OK to have a
> controller and a model called the same, as I have in the same root auto
> subroutine ,
>
>
>
> $c->detach(‘splashscreen’,’index’).
>
>
>
> Where I have both a controller called ‘SplashScreen’ and a model called
> ‘SplashScreen’, and the detach works fine.
>
>
>
> However, for another controller / model pair called ‘ComplianceUpdates’,
>
>
>
> This doesn’t work
>
>
>
> $c->detach(‘complianceupdates’,’index’).
>
>
>
> and errors with…
>
> Couldn't forward to "ComplianceUpdates". Does not implement "process"
>
> Couldn't detach to command "complianceupdates": Invalid action or component.
>
> So If I am to use
>
>
>
> $c->detach($action);
>
>
>
> How do I create a Catalyst::Action object.
>
>
>
> What attributes am I meant to be setting in the object before I pass it in,
> and where are the docs for this as I can’t find them.
>
>
>
> All help is appreciated.
>
>
>
>
>
> Craig Chant
>
> Information Technology Manager
>
>
>
>
>
>   Direct Line: 01903 227 753   Main Line: 01903 602 664   Website:
> www.homeloanpartnership.com
>
>
>
>
>
> This Email and any attachments contain confidential information and is
> intended solely for the individual to whom it is addressed. If this Email
> has been misdirected, please notify the author as soon as possible. If you
> are not the intended recipient you must not disclose, distribute, copy,
> print or rely on any of the information contained, and all copies must be
> deleted immediately. Whilst we take reasonable steps to try to identify any
> software viruses, any attachments to this e-mail may nevertheless contain
> viruses, which our anti-virus software has failed to identify. You should
> therefore carry out your own anti-virus checks before opening any documents.
> HomeLoan Partnership will not accept any liability for damage caused by
> computer viruses emanating from any attachment or other document supplied
> with this e-mail. HomeLoan Partnership reserves the right to monitor and
> archive all e-mail communications through its network. No representative or
> employee of HomeLoan Partnership has the authority to enter into any
> contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is
> a trading name of H L Partnership Limited, registered in England and Wales
> with Registration Number 5011722. Registered office: Pharos House, 67 High
> Street, Worthing, West Sussex, BN11 1DN. H L Partnership Limited is
> authorised and regulated by the Financial Conduct Authority.
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
<><>___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst starter template

2013-09-02 Thread David Schmidt
Quite late but when I read your email again i had to think of this
other module which does a similiar thing and thought I'd mention it
here.

https://github.com/marcelgruenauer/CatalystX-Crudite

CatalystX-Crudite is a framework for writing Catalyst-based CMS web
applications. It includes out-of-the-box user and role management and
many starter templates. It builds upon CatalystX-Resource and
CatalystX-SimpleLogin.

In order for crudite_starter to work, you need to install this
distribution. The starter templates are stored as per-dist shared
files using File::ShareDir, so they can't be found from the
uninstalled repository. I hope to improve this in a later version.


On 17 August 2013 21:21, Ynon Perek  wrote:
> Hi All,
>
> After working with catalyst for some time, I found catalyst.pl too
> minimalistic for my needs.
>
> So I created a small script called ctstarter.pl that adds some features to
> the base template you get for a new project. Currently it adds:
>
> 1. A starter DB and migrations (using DBIx::Class::Migration)
> 2. Code and DB tables for managing users and roles (using
> CatalystX::SimpleLogin)
> 3. A Twitter Bootstrap web view with templates (using
> Catalyst::Helper::View::Bootstrap)
> 4. Two helper scripts: one to upgrade the DB and the other to reset admin
> password.
>
> You can find the source and usage instructions here:
> https://github.com/ynonp/ctstarter.pl
>
> Any feedbacks is appreciated.
>
> Cheers,
>   Ynon
>
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Adding CaptureArgs for the whole controller?

2013-04-02 Thread David Schmidt
By using one action that captures args and all other actions chain from.


something like this:
https://github.com/davewood/catalystx-resource/blob/master/lib/CatalystX/Resource/Controller/Resource.pm

On 2 April 2013 22:07, Alex Povolotsky  wrote:
> Hello!
>
> I'm implementing some sort of simple CRM, and I'd like to handle a chain
> like
>
> /domain/*/service/*/edit with controller App::Controller::Domain::Service,
> not with App::Controller::Domain
>
> How can I set CaptureArgs for the whole App::Controller::Domain::Service?
> I'd like to handle captured arg somewhere in begin or auto
>
> Alex
>
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] I'm loosing the plot here? - Controller behaviour that makes no sense

2012-10-31 Thread David Schmidt
Tomas asked for the debug output of the failing response.
You pasted only the server startup debug output.

On 31 October 2012 10:46, Craig Chant  wrote:
> Sorry IRC?
>
> I did post the debug and output , has this email not been received?
>
> -Original Message-
> From: Tomas Doran [mailto:bobtf...@bobtfish.net]
> Sent: 30 October 2012 22:26
> To: The elegant MVC web framework
> Subject: Re: [Catalyst] I'm loosing the plot here? - Controller behaviour 
> that makes no sense
>
>
> On 30 Oct 2012, at 20:08, Craig Chant wrote:
>
>> The path/controller/action is resolving correctly now, but any 
>> response->body change I make in the 'index :Path' action, isn't showing  
>> when i refresh my browser?
>
> You're not showing us the debug output of the failing request, so it's very 
> hard to help debug that request.
>
> If you want this form of interactive help, you'd be much better off dropping 
> into irc for interactive help, rather than the mailing list, which by it's 
> nature is more asynchronous.
>
> Hope to see you in irc!
>
> 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/
> This Email and any attachments contain confidential information and is 
> intended solely for the individual to whom it is addressed. If this Email has 
> been misdirected, please notify the author as soon as possible. If you are 
> not the intended recipient you must not disclose, distribute, copy, print or 
> rely on any of the information contained, and all copies must be deleted 
> immediately. Whilst we take reasonable steps to try to identify any software 
> viruses, any attachments to this e-mail may nevertheless contain viruses, 
> which our anti-virus software has failed to identify. You should therefore 
> carry out your own anti-virus checks before opening any documents. HomeLoan 
> Partnership will not accept any liability for damage caused by computer 
> viruses emanating from any attachment or other document supplied with this 
> e-mail. HomeLoan Partnership reserves the right to monitor and archive all 
> e-mail communications through its network. No representative or employee of 
> HomeLoan Partnership has the authority to enter into any contract on behalf 
> of HomeLoan Partnership by email. HomeLoan Partnership is a trading name of H 
> L Partnership Limited, registered in England and Wales with Registration 
> Number 5011722. Registered office: 26-34 Old Street, London, EC1V 9QQ. H L 
> Partnership Limited is authorised and regulated by the Financial Services 
> Authority.
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] Can't get view / template to work ?

2012-10-30 Thread David Schmidt
On 31 October 2012 00:00, Tomas Doran  wrote:
>
> On 30 Oct 2012, at 16:52, Craig Chant wrote:
>
>> I seem stuck with implementing my first view / template.
>>
>> I have a controller Login.pm
>>
>> I ran the view helper script ‘create view HTML HTML::template’
>>
>
> This can't possibly have worked? You mean create view HTML HTML::Template 
> right?
>
>> As per the tutorial I’ve added the following to the config section of 
>> MyApp.pm
>>
>> TEMPLATE_EXTENSION => '.tp',
>
> This needs to be inside the following block
>
>> 'View::HTML' => {
>> #Set the location for templates files
>> INCLUDE_PATH => [
>> __PACKAGE__->path_to( 'root', 'src' ),
>> ],
>> },

C::M::Tutorial says otherwise

http://search.cpan.org/~zarquon/Catalyst-Manual-5.9004/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod#Create_a_Catalyst_View


>>
>> I have created a template in ‘root/src/login’  of login.tp
>>
>> In my controller I have …
>>
>> sub login :Path :Args(0) {
>> my ( $self, $c) = @_;
>>
>> $c->stash(template => 'login.tp');
>>
>> }
>>
>> But all I get is…
>>
>
> No idea.
>
>>
>> What am I doing wrong?
>>
>
> Not showing us the full debug output of starting the server and making the 
> request.
>
> Sorry to be harsh - but it's impossible to divine what code your app is 
> running without that output…
>
> 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/


Re: [Catalyst] I'm loosing the plot here? - Controller behaviour that makes no sense

2012-10-30 Thread David Schmidt
Can you show us the startup output of your development server (start it in
debug mode)

david

On 30 October 2012 18:39, Craig Chant  wrote:

>  Please advise why the following URL
>
>
>
> ‘mydomain:port/login’
>
>
>
> Produces “Matched Members::Controller::Login in Login.”
>
>
>
> When the Login controller has …
>
>
>
> package Members::Controller::Login;
>
> use Moose;
>
> use namespace::autoclean;
>
>
>
> BEGIN { extends 'Catalyst::Controller'; }
>
>
>
> sub index :Path :Args(0) {
>
> my ( $self, $c ) = @_;
>
>
>
> $c->response->body('this sucks');
>
> }
>
>
>
> sub loginPage :Path :Args(0) {
>
> my ( $self, $c) = @_;
>
>
>
> $c->stash(template => 'login');
>
> }
>
>
>
>
>
> __PACKAGE__->meta->make_immutable;
>
>
>
> 1;
>
>
>
> The devel server shows…
>
>
>
> Caught exception in Members::View::HTML->process "HTML::Template->new() :
> Cannot open included file login : file not found. at
> C:/Perl/lib/HTML/Template.pm line 1813
>
> For the same URL , when neither output should show?
>
>
>
> Is something seriously wrong with Catalyst and IIS7 / ActiveState Perl ?
>
>
>
> I thought the URL was ‘domain:port/controller/action’ ?
>
>
>
> Is this how it is meant to work?
>
>
>
> All I get for ‘mydomain:port/login/loginPage’ – is a 404 not found?
>
>
>
> Why won’t any of this work?
>
>
>
>
>
> *Craig Chant*
>
> I.T. Manager
>
> [image: Description: cid:image001.png@01CD5F4A.17E848D0]
>
> Main Line01903 602664
>
> Direct Line   01903 227753
>
> Visit our website http://www.homeloanpartnership.com
>
> *HomeLoan Partnership have been named the Best Mortgage Network, 2012, at
> the myintroducer.com Industry Awards*
>
>
>  This Email and any attachments contain confidential information and is
> intended solely for the individual to whom it is addressed. If this Email
> has been misdirected, please notify the author as soon as possible. If you
> are not the intended recipient you must not disclose, distribute, copy,
> print or rely on any of the information contained, and all copies must be
> deleted immediately. Whilst we take reasonable steps to try to identify any
> software viruses, any attachments to this e-mail may nevertheless contain
> viruses, which our anti-virus software has failed to identify. You should
> therefore carry out your own anti-virus checks before opening any
> documents. HomeLoan Partnership will not accept any liability for damage
> caused by computer viruses emanating from any attachment or other document
> supplied with this e-mail. HomeLoan Partnership reserves the right to
> monitor and archive all e-mail communications through its network. No
> representative or employee of HomeLoan Partnership has the authority to
> enter into any contract on behalf of HomeLoan Partnership by email.
> HomeLoan Partnership is a trading name of H L Partnership Limited,
> registered in England and Wales with Registration Number 5011722.
> Registered office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership
> Limited is authorised and regulated by the Financial Services Authority.
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
<>___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Global 'helper' methods

2012-10-30 Thread David Schmidt
Perhaps it is feasible for you to bypass object inflation.

1)
"DBIx::Class is not built for speed, it's built for convenience and
ease of use, but sometimes you just need to get the data, and skip the
fancy objects."

http://search.cpan.org/~frew/DBIx-Class-0.08200/lib/DBIx/Class/Manual/Cookbook.pod#Skip_row_object_creation_for_faster_results

2)
"If the HashRefInflator solution above is not fast enough for you, you
can use a DBIx::Class to return values exactly as they come out of the
database"
http://search.cpan.org/~frew/DBIx-Class-0.08200/lib/DBIx/Class/Manual/Cookbook.pod#Get_raw_data_for_blindingly_fast_results

___
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] Canot get application working on IIS7 via FastCGI

2012-10-18 Thread David Schmidt
> As for the Data::Dumper information you requested, you will need to give me 
> more guidance because I can't get it to output anything?
>
> Firstly I cannot find the context variable '$c' , there is a '$ctx' , I 
> assume this is what was meant?
>
> I added
>
> dump($env);
> dump($ctx->request->uri);
> dump($ctx->request->base);

I am just guessing here but what I think you ought to do is

1)
enable debug output of your application by adding the -Debug flag to
your use Catalyst statement

2)
use Data::Dumper;
$ctx->log->debug(Dumper($ctx->request->uri))
...

___
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] Canot get application working on IIS7 via FastCGI

2012-10-17 Thread David Schmidt
> Though while we are on the subject of  Catalyst plug-ins, I do get this 
> message in the devel server output when it's started.
>
> [warn] Deprecated 'static' config key used, please use the key 
> 'Plugin::Static::Simple' instead
>
> I've looked at the main application MyApp.pm in the lib folder and the 
> plug-ins loaded are :-
>
> use Catalyst qw/
> -Debug
> ConfigLoader
> Static::Simple
> StackTrace
> Session
> Session::Store::FastMmap
> Session::State::Cookie
> /;
>
> I've tried putting Plugin::Static::Simple insted but that falls over because 
> it can't locate the plug-in module, I've checked PPM and I have 
> 'Plugin::Static::Simple' Catalyst CPAN module installed so am little stumped 
> especially with the limited beginners knowledge I have of your framework so 
> perhaps you could advise.



Doesnt really matter in this case. It just warns you to use

MyApp->config(
'Plugin::Static::Simple' => {
...
}
);

instead of

MyApp->config(
static => {
...
}
);

___
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] Canot get application working on IIS7 via FastCGI

2012-10-17 Thread David Schmidt
> Sorry again for not providing enough information, I will try to give you what 
> you need but I
> will need a little help doing that also, can you advise where the logs for 
> the app when
> running over IIS7-> FastCGI are? Is there a file somewhere that gets written 
> to each time
> the fastcgi.pl script gets executed with this information in it?

I am pretty sure that you have to look where your webserver logs to.
With Apache it is possible to configure the log and errorlog location.
I suppose the same is possible for IIS7
Google it.

> Also can you guide me to where this change needs to be made
> 'Catalyst::Engine::prepare_path method ' for Data::Dumper:Dumper, where is 
> the file that
> needs editing located? , Also is there a Catalyst method to spit out the data 
> via
> Data::Dumper already integrated into the framework, or do I need to import it 
> myself?

Look for the file Catalyst/Engine.pm. then search for "prepare_path"

___
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 update data of already logged-in user?

2012-07-11 Thread David Schmidt
The object returned by $c->user is not what you are looking for.

I assume you are using DBIC.

Get the "real" user object with $c->user->get_object()

http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10021/lib/Catalyst/Authentication/User.pm#get_object(_)

cheers
david



On 11 July 2012 17:37, Sergey Dmitriev  wrote:
> Hello,
>
> My question is simple. I have object of already authenticated user in $u by
> using
>
> my $u = $c->user()
>
> So, getter $u->email reflects actual email. How then can I update already
> loaded user object? E.g. i need something like:
>
> print $u->email; # old@email
>
> $u->email = 'new@email';
>
> print $u->email; # new@email
>
> How to achieve this simple way? Do I need to update user rec in DB then
> re-load user from DB? Then, which is the simplest way to re-trieve user
> again?
>
> Thank you.
> Sergey
>
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Can't get value from model

2012-06-13 Thread David Schmidt
On 13 June 2012 23:34, Kenneth S Mclane  wrote:
> David Schmidt  wrote on 06/13/2012 04:15:57 PM:
>
>> From:
>>
>> David Schmidt 
>>
>> To:
>>
>> The elegant MVC web framework 
>>
>> Date:
>>
>> 06/13/2012 04:16 PM
>>
>> Subject:
>>
>> Re: [Catalyst] Can't get value from model
>>
>> Hi Kenneth,
>>
>> that's a DBIC question
>>
>>
>> anyways, what is the output of ...
>>
>> if ( $dept ) {
>>    warn "REF: " . ref $dept . " DEPT_ID: " . $dept->department_id;
>> } else {
>>    warn "No dept found";
>> }
>>
>> ... after your query?
>>
>> On 13 June 2012 22:54, Kenneth S Mclane  wrote:
>> > I am trying to get the value from a model call into a variable so I can
>> > use
>> > it for creating a DB record. I have tried multiple ways and cannot get
>> > the
>> > value to return. Here is my current attempt:
>> >
>> > my $dept =
>> > $c->model('ORANGES::Departments')->search_rs({'department_code'
>> > => $departmentcode}, {
>> >                 columns => ['department_id'] });
>> >
>> > This returns "1".
>> >
>> > I tried this:
>> >
>> > my $dept =
>> > $c->model('ORANGES::Departments')->search_rs({'department_code'
>> > => $departmentcode}, {
>> >                 columns => ['department_id'] })->single;
>> >
>> > and got a hash reference. I know I am missing something very simple. If
>> > I
>> > was putting this into the stash I know I could access the value, but I
>> > am at
>> > a loss as to how to get to it inside my code.
>> >
>> >
> [error] Caught exception in dbms::Controller::Account->add "Can't locate
> object method "department_id" via package "DBIx::Class::ResultSet" at
> /home/ksmclane/catalyst/dbms/script/../lib/dbms/Controller/Account.pm line
> 49."
>
>
> ___
> 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/
>

your $dept is a resultset not a row item
use the following code to get $dept

my $dept =
$c->model('ORANGES::Departments')->search_rs(
   { 'department_code' => $departmentcode},
   { columns => ['department_id'] }
)->single;

warn ...; # what I wrote earlier

assuming the rest of your code is corrent this should return a row
object with a department_id accessor ($dept->department_id)

___
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] Can't get value from model

2012-06-13 Thread David Schmidt
Hi Kenneth,

that's a DBIC question


anyways, what is the output of ...

if ( $dept ) {
   warn "REF: " . ref $dept . " DEPT_ID: " . $dept->department_id;
} else {
   warn "No dept found";
}

... after your query?

On 13 June 2012 22:54, Kenneth S Mclane  wrote:
> I am trying to get the value from a model call into a variable so I can use
> it for creating a DB record. I have tried multiple ways and cannot get the
> value to return. Here is my current attempt:
>
> my $dept = $c->model('ORANGES::Departments')->search_rs({'department_code'
> => $departmentcode}, {
>                 columns => ['department_id'] });
>
> This returns "1".
>
> I tried this:
>
> my $dept = $c->model('ORANGES::Departments')->search_rs({'department_code'
> => $departmentcode}, {
>                 columns => ['department_id'] })->single;
>
> and got a hash reference. I know I am missing something very simple. If I
> was putting this into the stash I know I could access the value, but I am at
> a loss as to how to get to it inside my code.
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] DBIx::Class::ResultSet::all(): DBI Exception: DBD::DB2::db prepare_cached failed: [IBM][CLI Driver][DB2/AIX64] SQL0204N "DBUSERNAME.ACCOUNT_VIEW" is an undefined name.

2012-04-26 Thread David Schmidt
$rs->all returns an array so you should call it in list context like this.

$c->stash(
   accounts => [ $c->model('ORANGES::AccountView')->all ]
);

no idea if that changesyour error msg but it is a start.

david

On 26 April 2012 21:05, Kenneth S Mclane  wrote:
> I do not understand this error at all. It is tacking the DB user name onto
> the model name. Any hints why this is happening?
>
> This is my list sub:
>
> sub list :Local {
>         my ($self, $c) = @_;
>         $c->stash(accounts => $c->model('ORANGES::AccountView')->all);
>         $c->stash(template => 'accountview/list.tt2');
> }
>
> The model exists, if I remove the "->all" I get a different error but at
> least the stash gets populated with a bunch of info ABOUT the model, not the
> actual data. With it left in I never get anything but the error.
>
> Any help appreciated.
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Remove Catalyst and start over?

2012-03-23 Thread David Schmidt
run moose-outdated.

"moose-outdated is a tool that ships with Moose to help you spot
dependency problems"

On 23 March 2012 18:06, Robyn Jonahs  wrote:
> Hi,
>
> I am new to perl and Catalyst. I am working with an Os X 10.6 system with
> perl perl 5, version 12, subversion 3 (v5.12.3). I used CPAN
>
> cpan> i
> CPAN
> Bundle    Bundle::CPAN   (ANDK/Bundle-CPAN-1.861.tar.gz)
> Module  = CPAN   (ANDK/CPAN-1.9800.tar.gz)
> 2 items found
>
> to install Catalyst::Devel in the system perl archive a few days ago.
>
> I can't seem to start a new catalyst application and old ones that I tried
> to make years ago when I first decided to try to learn Cat won't start
> either. I think that I want to remove Catalyst from the system perl and
> install perl locally and then cat locally.
>
>
>
> My question is how do I remove this recent install of catalyst::devel?
>
>
>
> Thanks so much in advance!!!
> QC
>
>
>
> Alternately I don't know what to do to make the one I just installed work
>
> FYI
>
> 1. When I try to start a new catalyst app it says that it can't find
> catalyst.pl
>   This is the same as root (via sudo) or in my user login
>
> 2. When I try to run an old cat app I seem to get Moose errors
> LolCatalyst-Lite$ cd script/
> script$ ./lolcatalyst_lite_server.pl
> "load_first_existing_class" is not exported by the Class::Load module
> Can't continue after import errors at
> /usr/local/ActivePerl-5.12/site/lib/Moose/Util.pm line 12
> BEGIN failed--compilation aborted at
> /usr/local/ActivePerl-5.12/site/lib/Moose/Util.pm line 12.
> Compilation failed in require at
> /usr/local/ActivePerl-5.12/site/lib/Moose/Meta/Class.pm line 28.
> BEGIN failed--compilation aborted at
> /usr/local/ActivePerl-5.12/site/lib/Moose/Meta/Class.pm line 28.
> Compilation failed in require at
> /usr/local/ActivePerl-5.12/site/lib/Moose.pm line 28.
> BEGIN failed--compilation aborted at
> /usr/local/ActivePerl-5.12/site/lib/Moose.pm line 28.
> Compilation failed in require at
> /usr/local/ActivePerl-5.12/site/lib/Catalyst/Engine.pm line 3.
> BEGIN failed--compilation aborted at
> /usr/local/ActivePerl-5.12/site/lib/Catalyst/Engine.pm line 3.
> Compilation failed in require at (eval 2) line 2.
>     ...propagated at /usr/local/ActivePerl-5.12/lib/base.pm line 94.
> BEGIN failed--compilation aborted at
> /usr/local/ActivePerl-5.12/site/lib/Catalyst/Engine/HTTP.pm line 6.
> Compilation failed in require at ./lolcatalyst_lite_server.pl line 6.
> BEGIN failed--compilation aborted at ./lolcatalyst_lite_server.pl line 7.
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] $C -> uri_for containing current path in catalyst 5.90010

2012-03-08 Thread David Schmidt
forgot to include my catalyst version

[info] Foo powered by Catalyst 5.90010

On 8 March 2012 20:49, David Schmidt  wrote:
> I tested your code
>
> sub exampleRedirect :Path(/oldPath) Args(0) {
>    my ( $self, $c ) = @_;
>    my %data = %{ $c->req->params };
>    my $url =  $c->uri_for( $self->action_for('newSub'), \%data );
>    $c->response->redirect( $url , 301 );
>    $c->log->debug(': ' . $url);
> }
>
> sub newSub :Path(/this/someOtherPath) Args(0) {}
>
>
> [debug] Redirecting to "http://myapp.at:3000/this/someOtherPath?cheese=nice";
>
>
>
> On 8 March 2012 20:05,   wrote:
>> Hi.
>>
>>
>>
>> We were trying to use catalyst 5.90010 to run a webapp, and almost
>> everything is totally lovely, apart from a few redirects.
>>
>>
>>
>> In version 5.90006 it all seems to be working well.
>>
>>
>>
>> The rewrite is along the lines of:
>>
>>
>>
>> sub exampleRedirect :Path( "/oldPath" ) Args(0)
>>
>> {
>>
>>     my ( $self, $c ) = @_;
>>
>>     my %data = %{ $c -> req -> params };
>>
>>     # … actions on %data removed
>>
>>     my $url =  $c -> uri_for( $c -> controller('This') ->
>> action_for('newSub'), \%data );
>>
>>     $c -> response -> redirect( $url , 301 ) ;
>>
>> }
>>
>>
>>
>> sub newSub :Path(“/this/someOtherPath”) Args(0)
>>
>> {
>>
>>     …
>>
>> }
>>
>>
>>
>> When the server is called, on 5.90006, for
>> http://somedomain/oldPath?cheese=nice, $url becomes
>> http://somedomain/this/someOtherPath?cheese=nice
>>
>>
>>
>> On 5.9.0010, the same url becomes
>> http://somedomain/oldPath/this/someOtherPath?cheese=nice
>>
>>
>>
>> Obviously checked http headers and output $url above.
>>
>>
>>
>> Can anyone shed some light on this? It’s probably something stupid I’ve
>> done, as I cannot find much in google.
>>
>>
>>
>> Steve
>>
>>
>>
>>
>> ___
>> List: Catalyst@lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>

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


Re: [Catalyst] $C -> uri_for containing current path in catalyst 5.90010

2012-03-08 Thread David Schmidt
I tested your code

sub exampleRedirect :Path(/oldPath) Args(0) {
my ( $self, $c ) = @_;
my %data = %{ $c->req->params };
my $url =  $c->uri_for( $self->action_for('newSub'), \%data );
$c->response->redirect( $url , 301 );
$c->log->debug(': ' . $url);
}

sub newSub :Path(/this/someOtherPath) Args(0) {}


[debug] Redirecting to "http://myapp.at:3000/this/someOtherPath?cheese=nice";



On 8 March 2012 20:05,   wrote:
> Hi.
>
>
>
> We were trying to use catalyst 5.90010 to run a webapp, and almost
> everything is totally lovely, apart from a few redirects.
>
>
>
> In version 5.90006 it all seems to be working well.
>
>
>
> The rewrite is along the lines of:
>
>
>
> sub exampleRedirect :Path( "/oldPath" ) Args(0)
>
> {
>
>     my ( $self, $c ) = @_;
>
>     my %data = %{ $c -> req -> params };
>
>     # … actions on %data removed
>
>     my $url =  $c -> uri_for( $c -> controller('This') ->
> action_for('newSub'), \%data );
>
>     $c -> response -> redirect( $url , 301 ) ;
>
> }
>
>
>
> sub newSub :Path(“/this/someOtherPath”) Args(0)
>
> {
>
>     …
>
> }
>
>
>
> When the server is called, on 5.90006, for
> http://somedomain/oldPath?cheese=nice, $url becomes
> http://somedomain/this/someOtherPath?cheese=nice
>
>
>
> On 5.9.0010, the same url becomes
> http://somedomain/oldPath/this/someOtherPath?cheese=nice
>
>
>
> Obviously checked http headers and output $url above.
>
>
>
> Can anyone shed some light on this? It’s probably something stupid I’ve
> done, as I cannot find much in google.
>
>
>
> Steve
>
>
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Resources to learn catalyst

2012-03-02 Thread David Schmidt
http://perl-tutorial.org/

After reading "Learning Perl" you could start "Intermediate Perl".

I really like the "modern perl"
book.http://www.onyxneon.com/books/modern_perl/index.html
You can even get it for free, there is a PDF download link.

The best book for Catalyst is probably "The definitive Guide to Catalyst
http://shadow.cat/blog/matt-s-trout/the-definitive-guide-to-catalyst/
http://www.amazon.com/Definitive-Guide-Catalyst-Maintainable-Applications/dp/1430223650
If you are interested in buying second hand, I have read mine a couple
of times and would like to sell it.

cheers
david


On 1 March 2012 20:25, Vinicius Abrahao  wrote:
> On Thu, Mar 1, 2012 at 2:27 PM, Chankey Pathak  wrote:
>> I am new to catalyst. I know Perl at beginner level (finished reading
>> Learning Perl).
>
> Hi, I am new at Catalyst too...
>
>> I am following the catalyst tutorial at CPAN.
>
> That's a great point to start..
>
>
>> Let me know some more resources to learn catalyst.
>
> You can find nice articles here: http://www.catalystframework.org/calendar/
>
>> Thanks :)
>
> Welcome :)
>
>
> []s
>
> Vinícius
>
> --
> Vinícius Abrahão Bazana Schmidt
> Desenvolvimento
> Dextra Sistemas
> www.dextra.com.br
> +55 19 3256-6722 Ramal 246
>
> Este email é confidencial. Mais informações em:
> This message is confidential. More information at:
> www.dextra.com.br/confidencial.htm
>
>
> --
> vi[nnix]™
> vischmidt.wordpress.com
> twitter.com/vischmidt
> github.com/vinnix
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

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


Re: [Catalyst] Setting flash for tests

2012-02-18 Thread David Schmidt
Do you know about CatalystX::SimpleLogin it does exactly what you
described and probably is thoroughly tested.

as far as the testing is concerned i'd simply test the entire
procedure as it would take place in a real workflow.

1) GET /site_that_needs_login
2) check result is a redirect to loginform
3) POST /login with credentials
4) check result is redirect to /site_that_needs_login

You can also use
http://search.cpan.org/~mstrout/Catalyst-Runtime-5.90010/lib/Catalyst/Test.pm#%28$res,_$c%29_=_ctx_request%28_..._%29;
in order to access the context object and check $c->flash->{next}

On 17 February 2012 16:23, Robert Rothenberg  wrote:
> 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/

___
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] Listing all actions in app

2012-02-16 Thread David Schmidt
If you start your app in debug mode you get a list of all actions.

or ...

# catalyst.pl Foo
# cd Foo
# vim list_actions.pl
  1 #!/usr/bin/env perl
  2 use strict;
  3 use warnings;
  4 use v5.10.1;
  5 use FindBin qw/$Bin/;
  6 use lib "$Bin/lib";
  7 use Data::Dumper;
  8 use Foo;
  9
 10 my $app = Foo->new();
 11
 12 my @controllers = map { $app->controller($_) } $app->controllers;
 13 for my $controller (@controllers) {
 14 my @actions = $controller->get_action_methods;
 15 say $_->name . ': ' . join(',', @{$_->attributes}) for @actions;
 16 }


david@kvm6:~/Foo$ perl list_actions.pl
_DISPATCH: Private
_BEGIN: Private
_AUTO: Private
_ACTION: Private
_END: Private
index: Path,Args(0)
default: Path
end: ActionClass('RenderView')



On 16 February 2012 18:34, Paolo Gianrossi  wrote:
> Hi List!
>
> I have an app and I would like to be able to list (in a , but
> whatever), all public actions in all controllers of my app.
>
> Is there an easy way to do this?
>
> Thanks a lot!
>
> cheers
> paolino
>
> --
> Paolo Gianrossi
>
> (An unmatched left parenthesis
>  creates an unresolved tension
>  that will stay with you all day
>                                    -- xkcd
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Catalyst::TraitFor::Controller::Sendfile

2012-01-09 Thread David Schmidt
Time to continue ...

I want to support X-Sendfile and X-Accel-Redirect

Currently I have a Catalyst::TraitFor::Controller. but that doesn't
feel right. Should it be a plugin?

c->sendfile(...) seems more appropriate then c->controller(...)->sendfile

or rather a Catalyst::TraitFor::Request like
http://cpansearch.perl.org/src/MAROS/CatalystX-I18N-1.09/lib/CatalystX/I18N/TraitFor/Response.pm

But will that cause overhead for each request instance creation?

On 11 December 2011 13:57, Tomas Doran  wrote:
>
> On 11 Dec 2011, at 12:27, David Schmidt wrote:
>
>>
>> https://github.com/davewood/catalyst-traitfor-controller-sendfile/blob/master/lib/Catalyst/TraitFor/Controller/Sendfile.pm
>>
>> I want to continue working on it and have a few questions.
>>
>> - Is it still needed?
>
>
> Yes.
>
>
>> - What should be changed?
>
>
> https://github.com/davewood/catalyst-traitfor-controller-sendfile/blob/master/lib/Catalyst/TraitFor/Controller/Sendfile.pm#L92
>
> https://github.com/davewood/catalyst-traitfor-controller-sendfile/blob/master/lib/Catalyst/TraitFor/Controller/Sendfile.pm#L99
>
> This totally won't work any more (in 5.9) I'm afraid.
>
>
>> - any input regarding missing tests?
>
>
> Erm, IIRC your code is relying on / assuming that you're doing a sendfile on
> something that actually exists on the local (i.e. the web server's) local
> disk.
>
> This often isn't the case. (For example nginx's X-Accel-Redirect redirects
> to another path served by the web server, rather than a file on local disk).
>
> I think this is possible currently, but it's not documented / tested that
> the file could be entirely synthetic (and not correspond to a real file on
> the file system).
>
> 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/


Re: [Catalyst] YA CRUD module

2011-12-22 Thread David Schmidt
(02:28:32 PM) phenny: davewood: 21 Dec 16:54Z  tell davewood
there isn't really a smarter way yet, I'd just always extend that base
class

I am going to use ActionRole::MatchRequestMethod so C::C::ActionRole
is a requirement anyways now.

thanks.

On 22 December 2011 14:21, David Schmidt  wrote:
> I came across another issue.
>
> CatalystX::Resource injects a controller into the app. the controller
> extends Catalyst::Controller.
>
> If I want to use Catalyst::ActionRole::ACL to deal with Authorization
> on my resources the controller needs to extend C::C::ActionRole.
>
> Should I extend from C::C::ActionRole or is there a smarter way to
> change the base class only when the extra functionality is required?
>
> david

___
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] YA CRUD module

2011-12-22 Thread David Schmidt
I came across another issue.

CatalystX::Resource injects a controller into the app. the controller
extends Catalyst::Controller.

If I want to use Catalyst::ActionRole::ACL to deal with Authorization
on my resources the controller needs to extend C::C::ActionRole.

Should I extend from C::C::ActionRole or is there a smarter way to
change the base class only when the extra functionality is required?

david

___
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] Reasonable way to get $c->config into Result class?

2011-12-12 Thread David Schmidt
http://wiki.catalystframework.org/wiki/wikicookbook/configpass2schema

I hope that solves your problem. I am in a bit of a hurry and didn't
read your mail very carefully

david

On 13 December 2011 01:49, will trillich  wrote:
> We have a Catalyst app where incidents can have attachments, and the
> attachments are stored in the filesystem (MySql backend is lethargic for
> in-DB binary blobs).
>
> Right now we're using a package global for storing the file-path-root, but
> obviously this should be handled via config somehow. Is there an elegant way
> to use MyApp.conf to set up a file-path that can get to $self->config
> consistently?
>
> If we use
>     package MyApp::Schema::DB::Result::Incident;
>     #...
>     has 'config' => ( is => 'rw' );
>     #...
> then in the Controller we have to inject something into $incident->config
> manually at create-time like so:
>
>     package MyApp::Web::Controller::Incident;
>     #...
>     my $incident = $c->model('MyApp::Incident')->find({ id => $id });
>     $incident->config( $c->config );
>
> But that only works in the context of a controller. If instead, we're coming
> in from a related record, such as an attachment, then
> $attachment->incident->config won't have any info, and no way to get it.
>
> I can see where DBIx::Class::Schema::Config allows pre-configuring
> credentials to connect to a database, but that's not what we're looking for
> here.
>
> Right now we have the file-path config stored in a global (yecch!) in the
> Result class, but would much rather have it in myapp.conf somehow...
>
> Clue stick welcome.
>
>
> --
> --
> will trillich -- http://faq.serensoft.com/
> "The truth is that many people set rules to keep
> from making decisions." -- Mike Krzyzewski
>
> ___
> 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::TraitFor::Controller::Sendfile

2011-12-11 Thread David Schmidt
https://github.com/davewood/catalyst-traitfor-controller-sendfile/blob/master/lib/Catalyst/TraitFor/Controller/Sendfile.pm

I want to continue working on it and have a few questions.

- Is it still needed?
- What should be changed?
- any input regarding missing tests?

___
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] YA CRUD module

2011-12-10 Thread David Schmidt
prove -l t
t/01_basic.t .. ok
t/02_crud.t ... ok
t/03_redirect_mode_list.t . ok
t/04_redirect_mode_show.t . ok
t/05_redirect_mode_show_parent.t .. ok
t/06_sortable.t ... ok
All tests successful.
Files=6, Tests=232, 18 wallclock secs ( 0.02 usr  0.21 sys + 10.34
cusr  6.65 csys = 17.22 CPU)
Result: PASS


time for a devel release :)

https://github.com/davewood/CatalystX-TraitFor-Controller-Resource

documentation needs some cleaning up though

On 6 December 2011 22:41, David Schmidt  wrote:
> I added quite some tests and generally see good progress.
>
> However ... I just tried the LoadableClass thingy.
>
> the error message before i installed MooseX::Types::LoadableClass was
>
> #   Failed test 'use TestApp;'
> #   at t/01_basic.t line 9.
> #     Tried to use 'TestApp'.
> #     Error:  Couldn't instantiate component
> "TestApp::Controller::Resource::Artist", "Could not find a class for
> trait: Form at /usr/local/share/perl/5.10.1/CatalystX/Component/Traits.pm
> line 145"Compilation failed in require at (eval 8) line 2.
> # BEGIN failed--compilation aborted at (eval 8) line 2.
>
>
> didnt really make sense to me
> after installing MooseX::Types::LoadableClass
> the error changed to
>
> #   Failed test 'use TestApp;'
> #   at t/01_basic.t line 9.
> #     Tried to use 'TestApp'.
> #     Error:  Couldn't instantiate component
> "TestApp::Controller::Resource::Artist", "Attribute (form_class) does
> not pass the type constraint because: Validation failed for
> 'MooseX::Types::LoadableClass::LoadableClass' with value undef at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Attribute.pm line 1131
> #       
> Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0xb5b9960)',
> 'Form::Resource::Artist',
> 'Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0xb592450)') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Attribute.pm line 491
> #       
> Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0xb5b9960)',
> 'Moose::Meta::Instance=HASH(0xb57c9c0)',
> 'Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0xb592450)',
> 'HASH(0xb54e818)') called at
> /usr/local/lib/perl/5.10.1/Class/MOP/Class.pm line 524
> #       
> Class::MOP::Class::_construct_instance('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xb59ba50)',
> 'HASH(0xb54e818)') called at
> /usr/local/lib/perl/5.10.1/Class/MOP/Class.pm line 497
> #       
> Class::MOP::Class::new_object('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xb59ba50)',
> 'HASH(0xb54e818)') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Class.pm line 269
> #       
> Moose::Meta::Class::new_object('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xb59ba50)',
> 'HASH(0xb54e818)') called at
> /usr/local/lib/perl/5.10.1/Moose/Object.pm line 28
> #       Moose::Object::new('Moose::Meta::Class::__ANON__::SERIAL::11',
> 'TestApp', 'HASH(0xb11d888)') called at constructor
> CatalystX::Resource::Controller::Resource::new (defined at
> /home/david/CatalystX-TraitFor-Controller-Resource/lib/CatalystX/Resource/Controller/Resource.pm
> line 343) line 4
> #       
> CatalystX::Resource::Controller::Resource::new('Moose::Meta::Class::__ANON__::SERIAL::11',
> 'TestApp', 'HASH(0xb11d888)') called at
> /usr/local/share/perl/5.10.1/MooseX/Traits/Pluggable.pm line 139
> #       
> MooseX::Traits::Pluggable::_build_instance_with_traits('TestApp::Controller::Resource::Artist',
> 'TestApp::Controller::Resource::Artist', 'TestApp') called at
> /usr/local/share/perl/5.10.1/MooseX/Traits/Pluggable.pm line 97
> #       
> MooseX::Traits::Pluggable::new_with_traits('TestApp::Controller::Resource::Artist',
> 'TestApp', 'HASH(0xb53c890)') called at
> /usr/local/share/perl/5.10.1/CatalystX/Component/Traits.pm line 145
> #       
> CatalystX::Component::Traits::COMPONENT('TestApp::Controller::Resource::Artist',
> 'TestApp', 'HASH(0xacb6948)') called at
> /usr/local/share/perl/5.10.1/Catalyst.pm line 2525
> #       eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line 
> 2525
> #       Catalyst::setup_component('TestApp',
> 'TestApp::Controller::Resource::Artist') called at
> /usr/local/share/perl/5.10.1/CatalystX/InjectComponent.pm line 152
> #       
> CatalystX::InjectComponent::_setup_component('CatalystX::InjectComponent',
> 'TestApp', 'TestApp::

Re: [Catalyst] YA CRUD module

2011-12-06 Thread David Schmidt
TestApp.pm
line 65
#   require TestApp.pm called at (eval 8) line 2
#   main::BEGIN() called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 0
#   eval {...} called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 0
#   eval 'package main;
# use TestApp @{$args[0]};
# 1;
#
# ;' called at /usr/local/share/perl/5.10.1/Test/More.pm line 885
#   Test::More::_eval('package main;\x{a}use TestApp
@{$args[0]};\x{a}1;\x{a}', 'ARRAY(0xa01a5a0)') called at
/usr/local/share/perl/5.10.1/Test/More.pm line 860
#   Test::More::use_ok('TestApp') called at t/01_basic.t line 9
#   main::BEGIN() called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 0
#   eval {...} called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 0"Compilation failed in require at (eval 8) line 2.
# BEGIN failed--compilation aborted at (eval 8) line 2.



On 5 December 2011 16:04, David Schmidt  wrote:
> I updated my code so it does pretty much what CatalystX::SimpleLogin does.
> Namely to inject a Controller then applying or removing traits.
> Unlike SimpleLogin I want to be able to inject many Controllers.
>
> here is what I came up with:
>
>  1 use Catalyst qw/+CatalystX::Resource/;
>  2
>  3 __PACKAGE__->config(
>  4     CatalystX::Resource => {
>  5         controllers => {
>  6             Artist => {
>  7                 resultset_key => 'artists_rs',
>  8                 resources_key => 'artists',
>  9                 resource_key => 'artist',
>  10                 model => 'DB:Artists',
>  11                 traits => ['-Delete'],
>  12             },
>  13             Song => {
>  14                 parent_key => 'artist',
>  15                 parents_accessor => 'songs',
>  16                 resources_key => 'songs',
>  17                 resource_key => 'song',
>  18                 model => 'DB::Songs',
>  19             },
>  20         },
>  21     },
>  22 );
>  23
>  24 after 'setup_components' => sub {
>  25     my $class = shift;
>  26     my $controllers
>  27         = $class->config->{'CatalystX::Resource'}{'controllers'};
>  28     while (my ($controller, $config) = each(%$controllers)) {
>  29         CatalystX::InjectComponent->inject(
>  30             into => $class,
>  31             component => 'CatalystX::Resource::Controller::Resource',
>  32             as => 'Controller::Resource::' . $controller,
>  33         );
>  34     }
>  35 };
>
> I wonder if it works. will test it when i have the time.
>
> On 5 December 2011 12:51, David Schmidt  wrote:
>> Here is a simple testcase of what I did. Once i noticed that i
>> required a method defined in the same role it made sense.
>>
>> #!/usr/bin/env perl
>>
>> use strict;
>> use warnings;
>> use Test::More;
>>
>> {
>>    package MyRole;
>>    use Moose::Role;
>>
>>    requires 'a';
>>    has a => (is => 'rw');
>> }
>>
>> {
>>    package MyClass;
>>    use Moose;
>>    with 'MyRole';
>> }
>>
>> my $foo = MyClass->new({ a => 'foo' });
>> can_ok ($foo, 'a');
>>
>> done_testing;
>>
>>
>> 'MyRole' requires the method 'a' to be implemented by 'MyClass' at
>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application.pm line 53
>>        
>> Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)',
>> 'Moose::Meta::Role=HASH(0x9dc55e8)',
>> 'Moose::Meta::Class=HASH(0x9ce8170)') called at
>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application/ToClass.pm line
>> 33
>>        
>> Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)',
>> 'Moose::Meta::Role=HASH(0x9dc55e8)',
>> 'Moose::Meta::Class=HASH(0x9ce8170)', 'HASH(0x9c817c8)') called at
>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role.pm line 482
>>        Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x9dc55e8)',
>> 'Moose::Meta::Class=HASH(0x9ce8170)') called at
>> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 154
>>        Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)',
>> undef, 'MyRole') called at /usr/local/lib/per

Re: [Catalyst] YA CRUD module

2011-12-05 Thread David Schmidt
I updated my code so it does pretty much what CatalystX::SimpleLogin does.
Namely to inject a Controller then applying or removing traits.
Unlike SimpleLogin I want to be able to inject many Controllers.

here is what I came up with:

  1 use Catalyst qw/+CatalystX::Resource/;
  2
  3 __PACKAGE__->config(
  4 CatalystX::Resource => {
  5 controllers => {
  6 Artist => {
  7 resultset_key => 'artists_rs',
  8 resources_key => 'artists',
  9 resource_key => 'artist',
 10 model => 'DB:Artists',
 11 traits => ['-Delete'],
 12 },
 13 Song => {
 14 parent_key => 'artist',
 15 parents_accessor => 'songs',
 16 resources_key => 'songs',
 17 resource_key => 'song',
 18 model => 'DB::Songs',
 19 },
 20 },
 21 },
 22 );
 23
 24 after 'setup_components' => sub {
 25 my $class = shift;
 26 my $controllers
 27 = $class->config->{'CatalystX::Resource'}{'controllers'};
 28 while (my ($controller, $config) = each(%$controllers)) {
 29 CatalystX::InjectComponent->inject(
 30 into => $class,
 31 component => 'CatalystX::Resource::Controller::Resource',
 32 as => 'Controller::Resource::' . $controller,
 33 );
 34 }
 35 };

I wonder if it works. will test it when i have the time.

On 5 December 2011 12:51, David Schmidt  wrote:
> Here is a simple testcase of what I did. Once i noticed that i
> required a method defined in the same role it made sense.
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use Test::More;
>
> {
>    package MyRole;
>    use Moose::Role;
>
>    requires 'a';
>    has a => (is => 'rw');
> }
>
> {
>    package MyClass;
>    use Moose;
>    with 'MyRole';
> }
>
> my $foo = MyClass->new({ a => 'foo' });
> can_ok ($foo, 'a');
>
> done_testing;
>
>
> 'MyRole' requires the method 'a' to be implemented by 'MyClass' at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application.pm line 53
>        
> Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)',
> 'Moose::Meta::Role=HASH(0x9dc55e8)',
> 'Moose::Meta::Class=HASH(0x9ce8170)') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application/ToClass.pm line
> 33
>        
> Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)',
> 'Moose::Meta::Role=HASH(0x9dc55e8)',
> 'Moose::Meta::Class=HASH(0x9ce8170)', 'HASH(0x9c817c8)') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Role.pm line 482
>        Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x9dc55e8)',
> 'Moose::Meta::Class=HASH(0x9ce8170)') called at
> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 154
>        Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)',
> undef, 'MyRole') called at /usr/local/lib/perl/5.10.1/Moose/Util.pm
> line 93
>        Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)',
> 'MyRole') called at /usr/local/lib/perl/5.10.1/Moose.pm line 65
>        Moose::with('Moose::Meta::Class=HASH(0x9ce8170)', 'MyRole')
> called at /usr/local/lib/perl/5.10.1/Moose/Exporter.pm line 356
>        Moose::with('MyRole') called at ./test.pl line 18
>
>
>
> On 5 December 2011 11:58, Tomas Doran  wrote:
>>
>> On 4 Dec 2011, at 23:46, David Schmidt wrote:
>>
>>> just thought i'll keep you up to day so you dont waste time trying to
>>> help with a problem i already solved.
>>>
>>> Turns out the error cause was in one of the roles. It required a
>>> method declared in the same role.
>>
>>
>> This has to be a Moose bug in some way.
>>
>> Moose should be able to complain that you are requiring a method you've
>> already provided, and/or it shouldn't fail.
>>
>> Any chance of a small(ish) test case for this one?
>>
>>
>> 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/


Re: [Catalyst] YA CRUD module

2011-12-05 Thread David Schmidt
Here is a simple testcase of what I did. Once i noticed that i
required a method defined in the same role it made sense.

#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;

{
package MyRole;
use Moose::Role;

requires 'a';
has a => (is => 'rw');
}

{
package MyClass;
use Moose;
with 'MyRole';
}

my $foo = MyClass->new({ a => 'foo' });
can_ok ($foo, 'a');

done_testing;


'MyRole' requires the method 'a' to be implemented by 'MyClass' at
/usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application.pm line 53

Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)',
'Moose::Meta::Role=HASH(0x9dc55e8)',
'Moose::Meta::Class=HASH(0x9ce8170)') called at
/usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application/ToClass.pm line
33

Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)',
'Moose::Meta::Role=HASH(0x9dc55e8)',
'Moose::Meta::Class=HASH(0x9ce8170)', 'HASH(0x9c817c8)') called at
/usr/local/lib/perl/5.10.1/Moose/Meta/Role.pm line 482
Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x9dc55e8)',
'Moose::Meta::Class=HASH(0x9ce8170)') called at
/usr/local/lib/perl/5.10.1/Moose/Util.pm line 154
Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)',
undef, 'MyRole') called at /usr/local/lib/perl/5.10.1/Moose/Util.pm
line 93
Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)',
'MyRole') called at /usr/local/lib/perl/5.10.1/Moose.pm line 65
Moose::with('Moose::Meta::Class=HASH(0x9ce8170)', 'MyRole')
called at /usr/local/lib/perl/5.10.1/Moose/Exporter.pm line 356
Moose::with('MyRole') called at ./test.pl line 18



On 5 December 2011 11:58, Tomas Doran  wrote:
>
> On 4 Dec 2011, at 23:46, David Schmidt wrote:
>
>> just thought i'll keep you up to day so you dont waste time trying to
>> help with a problem i already solved.
>>
>> Turns out the error cause was in one of the roles. It required a
>> method declared in the same role.
>
>
> This has to be a Moose bug in some way.
>
> Moose should be able to complain that you are requiring a method you've
> already provided, and/or it shouldn't fail.
>
> Any chance of a small(ish) test case for this one?
>
>
> 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/


Re: [Catalyst] YA CRUD module

2011-12-04 Thread David Schmidt
just thought i'll keep you up to day so you dont waste time trying to
help with a problem i already solved.

Turns out the error cause was in one of the roles. It required a
method declared in the same role.

The CatalystX::SimpleLogin (using CatalystX::InjectComponent and
CatalystX::Component::Traits) way actually worked.
Now I have to figure out how to inject more then just one Controller.

good night

On 4 December 2011 17:24, David Schmidt  wrote:
> davewood: I have a problem with CatalystX::Component::Traits. When i
> apply 2 traits and one requires some methods provided by the other an
> error appears saying ... "Couldn't instantiate component ... requires
> the methods ..."
>
> Caelum: davewood: you can't do that, the traits are applied all at once
>
>
>
> Guess I'll try to inject a controller and add the traits then. like
> CatalystX::SimpleLogin does it.
>
>
>
>
> On 4 December 2011 14:37, David Schmidt  wrote:
>> Hi t0m
>>
>> I am currently stuck at configuring/applying roles via TestApp::config
>>
>> I want to apply the role via catalyst config in MyApp.pm
>>
>> __PACKAGE__->config(
>>   'Controller::Resource' => {
>>      resultset_key => 'cds_rs',
>>      resources_key => 'cds',
>>      resource_key => 'cd',
>>      model => 'DB::CDs',
>>      traits => ['
>>         '+CatalystX::Controller::TraitFor::Resource',
>>         '+CatalystX::Controller::TraitFor::Role::List',
>>      ],
>>   },
>> );
>>
>> Using 'CatalystX::Component::Traits'; I get a test to run when I only
>> apply the Resource trait. But once I add the List role the following
>> error appears.
>>
>> $ prove -l t/04_with_role.t
>> t/04_with_role.t .. Couldn't instantiate component
>> "TestApp::Controller::Root",
>> "'CatalystX::TraitFor::Controller::Resource|CatalystX::TraitFor::Controller::Role::List'
>> requires the methods 'resources_key' and 'resultset_key' to be
>> implemented by 'Moose::Meta::Class::__ANON__::SERIAL::11' at
>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application.pm line 53
>>        
>> Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0xa3732a0)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application/ToClass.pm line
>> 33
>>        
>> Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0xa3732a0)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)',
>> 'HASH(0xa3813e8)') called at
>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role.pm line 482
>>        
>> Moose::Meta::Role::apply('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
>> /usr/local/share/perl/5.10.1/MooseX/MethodAttributes/Role/Meta/Role/Application.pm
>> line 26
>>        Class::MOP::Class:::around('CODE(0x9966858)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
>> /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 161
>>        
>> Class::MOP::Method::Wrapped::__ANON__('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
>> /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 91
>>        
>> Moose::Meta::Class::__ANON__::SERIAL::12::apply('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
>> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
>> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 157
>>        
>> Moose::Util::_apply_all_roles('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)',
>> undef, 'CatalystX::TraitFor::Controller::Resource',
>> 'CatalystX::TraitFor::Controller::Role::List') called at
>> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 93
>>        
>> Moose::Util::apply_all_roles('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)',
>> 'CatalystX::TraitFor::Controller::Resource',
>> 'CatalystX::Tr

Re: [Catalyst] YA CRUD module

2011-12-04 Thread David Schmidt
davewood: I have a problem with CatalystX::Component::Traits. When i
apply 2 traits and one requires some methods provided by the other an
error appears saying ... "Couldn't instantiate component ... requires
the methods ..."

Caelum: davewood: you can't do that, the traits are applied all at once



Guess I'll try to inject a controller and add the traits then. like
CatalystX::SimpleLogin does it.




On 4 December 2011 14:37, David Schmidt  wrote:
> Hi t0m
>
> I am currently stuck at configuring/applying roles via TestApp::config
>
> I want to apply the role via catalyst config in MyApp.pm
>
> __PACKAGE__->config(
>   'Controller::Resource' => {
>      resultset_key => 'cds_rs',
>      resources_key => 'cds',
>      resource_key => 'cd',
>      model => 'DB::CDs',
>      traits => ['
>         '+CatalystX::Controller::TraitFor::Resource',
>         '+CatalystX::Controller::TraitFor::Role::List',
>      ],
>   },
> );
>
> Using 'CatalystX::Component::Traits'; I get a test to run when I only
> apply the Resource trait. But once I add the List role the following
> error appears.
>
> $ prove -l t/04_with_role.t
> t/04_with_role.t .. Couldn't instantiate component
> "TestApp::Controller::Root",
> "'CatalystX::TraitFor::Controller::Resource|CatalystX::TraitFor::Controller::Role::List'
> requires the methods 'resources_key' and 'resultset_key' to be
> implemented by 'Moose::Meta::Class::__ANON__::SERIAL::11' at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application.pm line 53
>        
> Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0xa3732a0)',
> 'Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application/ToClass.pm line
> 33
>        
> Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0xa3732a0)',
> 'Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)',
> 'HASH(0xa3813e8)') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Role.pm line 482
>        
> Moose::Meta::Role::apply('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
> /usr/local/share/perl/5.10.1/MooseX/MethodAttributes/Role/Meta/Role/Application.pm
> line 26
>        Class::MOP::Class:::around('CODE(0x9966858)',
> 'Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
> /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 161
>        
> Class::MOP::Method::Wrapped::__ANON__('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
> /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 91
>        
> Moose::Meta::Class::__ANON__::SERIAL::12::apply('Moose::Meta::Class::__ANON__::SERIAL::12=HASH(0xa3684e8)',
> 'Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)') called at
> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 157
>        
> Moose::Util::_apply_all_roles('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)',
> undef, 'CatalystX::TraitFor::Controller::Resource',
> 'CatalystX::TraitFor::Controller::Role::List') called at
> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 93
>        
> Moose::Util::apply_all_roles('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa355838)',
> 'CatalystX::TraitFor::Controller::Resource',
> 'CatalystX::TraitFor::Controller::Role::List') called at
> /usr/local/lib/perl/5.10.1/Moose/Meta/Class.pm line 98
>        
> Moose::Meta::Class::create('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa2f59a0)',
> 'Moose::Meta::Class::__ANON__::SERIAL::11', 'roles',
> 'ARRAY(0xa33d798)', 'weaken', '', 'superclasses', 'ARRAY(0x9ba6ac8)')
> called at /usr/local/lib/perl/5.10.1/Class/MOP/Package.pm line 121
>        
> Class::MOP::Package::create_anon('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xa2f59a0)',
> 'superclasses', 'ARRAY(0x9ba6ac8)', 'roles', 'ARRAY(0xa33d798)',
> 'cache', 1) called at /usr/local/lib/perl/5.10.1/Class/MOP/Clas

Re: [Catalyst] YA CRUD module

2011-12-04 Thread David Schmidt
tApp::Controller::Root',
'TestApp', 'HASH(0xa1306b8)') called at
/usr/local/share/perl/5.10.1/Catalyst.pm line 2525
eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line 2525
Catalyst::setup_component('TestApp',
'TestApp::Controller::Root') called at
/usr/local/share/perl/5.10.1/Catalyst.pm line 2452
Catalyst::setup_components('TestApp') called at
/usr/local/share/perl/5.10.1/Catalyst.pm line 1179
Catalyst::setup('TestApp') called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 24
require TestApp.pm called at t/04_with_role.t line 9
main::BEGIN() called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 0
eval {...} called at
/home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm
line 0"Compilation failed in require at t/04_with_role.t line 9.
BEGIN failed--compilation aborted at t/04_with_role.t line 9.
# Looks like your test exited with 9 before it could output anything.
t/04_with_role.t .. Dubious, test returned 9 (wstat 2304, 0x900)
Failed 3/3 subtests

Test Summary Report
---
t/04_with_role.t (Wstat: 2304 Tests: 0 Failed: 0)
  Non-zero exit status: 9
  Parse errors: Bad plan.  You planned 3 tests but ran 0.
Files=1, Tests=0,  1 wallclock secs ( 0.00 usr  0.06 sys +  0.37 cusr
0.68 csys =  1.11 CPU)
Result: FAIL


# t/04_with_role.t
  1 use strict;
  2 use warnings;
  3
  4 use FindBin;
  5 use lib "$FindBin::Bin/lib";
  6
  7 use Test::More tests => 3;
  8
  9 use TestApp;
 10
 11 my $testapp = TestApp->new();
 12
 13 my $controller = $testapp->controller('Root');
 14 isa_ok ( $controller, 'TestApp::Controller::Root' );
 15
 16 my $action;
 17 $action = $controller->action_for('base');
 18 ok ( defined($action), 'Action "base" exists.' );
 19
 20 my $action = $controller->action_for('list');
 21 ok ( defined($action), 'Action "list" exists.' );

# TestApp.pm
  1 package TestApp;
  2
  3 use strict;
  4 use warnings;
  5 use Catalyst;
  6
  7 use Moose;
  8 use namespace::autoclean;
  9
 10 __PACKAGE__->config(
 11 name => 'TestApp',
 12 'Controller::Root' => {
 13 resultset_key   => 'cds_rs',
 14 resources_key   => 'cds',
 15 resource_key=> 'cd',
 16 model   => 'DB::CDs',
 17 traits => [
 18 '+CatalystX::TraitFor::Controller::Resource,
 19 '+CatalystX::TraitFor::Controller::Role::List'',
 20 ],
 21 }
 22 );
 23
 24 __PACKAGE__->setup();
 25
 26 1;


  1 package TestApp::Controller::Root;
  2
  3 use Moose;
  4 BEGIN { extends 'Catalyst::Controller'; }
  5 with 'CatalystX::Component::Traits';
  6
  7 __PACKAGE__->config->{namespace} = '';
  8
  9 sub index : Path Args(0) {
 10 my ($self, $c) = @_;
 11 $c->res->body('index');
 12 }
 13
 14 1;


On 31 October 2011 22:08, Tomas Doran  wrote:
>
> On 31 Oct 2011, at 14:49, David Schmidt wrote:
>
>> It's about time I publish my first CPAN module and it happens to be
>> yet another CRUD module.
>>
>> Feedback greatly appreciated.
>
>
>
> I haven't looked at this in depth - but it generally looks nice (other than
> lack of tests).. But some comments:
>
> You don't need strict or warnings. MX::MethodAttributes::Role gives you all
> the same stuff Moose::Role does, which includes strict and warnings.
>
> It might be nice if you could split the roles up..
>
> So there would be a (very base) role, and then separate
> List/Show/Edit/Create/Delete roles, and the main role would just compose
> everything...
>
> But that would allow you to more easily / naturally only use a subset of the
> functionality, whilst implementing some of the code in a more custom manor..
> Of course you can do this by adding around method modifiers to methods -
> however having several classes with half a dozen modifiers each which
> redirect to a 404 (to remove edit / delete functionality) is a lot less nice
> than only composing a subset of the roles (if for no other reason than that
> the wrapped things will show up in the debug table)..
>
> The documentation on parent_key doesn't quite seem to make sense, and the
> predicate naming there is also not clear.. (It may make sense why it isn't
> called what you expect - but could do with a comment?)
>
> form_class could be made a MooseX::Types::LoadableClass to avoid the
> explicit class load.
>
> I intensely dislike your sub _redirect - couldn't you instead compute a
> private path, and pass that to $c->

Re: [Catalyst] Catalyst and XMLRPC

2011-11-05 Thread David Schmidt
I believe this is the way to go ...
http://search.cpan.org/~bphillips/Catalyst-Action-REST-0.93/lib/Catalyst/Controller/REST.pm

On 4 November 2011 14:30, Jose Luis Martinez
 wrote:
> El 04/11/2011 13:59, Dmitry L. escribió:
>>
>> Catalyst::Cookbook and found advice to use Catalyst::Plugin::XMLRPC, but
>> on Catalyst::Plugin::XMLRPC cpan page it is marked as deprecated.
>>
>> Could you give me an advice which module to use or how I can build this
>> app?
>
> Try out Catalyst::Plugin::Server.
>
> Watch out for one thing: it depends on Clone::Fast, and it looks like cpan
> and cpanm can't locate the dist.
>
> wget
> http://search.cpan.org/CPAN/authors/id/J/JJ/JJORE/Clone-Fast-0.92.tar.gz
>
> untar it, and install it first.
>
> If Clone::Fast fails, please report back to me. I'm the maint for
> Catalyst::Plugin::Server, and wouldn't want to be depending on a very broken
> module.
>
> Best Regards,
>
> Jose Luis Martinez
> jlmarti...@capside.com
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/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] YA CRUD module

2011-10-31 Thread David Schmidt
It's about time I publish my first CPAN module and it happens to be
yet another CRUD module.

Feedback greatly appreciated.

https://github.com/davewood/CatalystX-TraitFor-Controller-Resource

One thing I have yet to do is writing tests. :)

david

ps: there is 
http://search.cpan.org/~abraxxa/Catalyst-Controller-DBIC-API-2.004002/lib/Catalyst/Controller/DBIC/API.pm
which does the same and more much better.

___
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] noob tutorial help

2011-05-12 Thread David Schmidt
13 (0.001/s) [] [Wed May 11 22:58:54 2011] ***
>> [debug] "GET" request for "hello" from "127.0.0.1"
>> [debug] Path is "/"
>> [debug] Arguments are "hello"
>> [debug] Response Code: 404; Content-Type: text/html; charset=utf-8; Conten
>> th: 14
>> [info] Request took 0.005385s (185.701/s)
>> .+---.
>> | Action | Time  |
>> ++---+
>> | /default   | 0.000275s |
>> | /end   | 0.000350s |
>> '+---'
>>
>> [info] *** Request 14 (0.002/s) [] [Wed May 11 22:59:11 2011] ***
>> [debug] "GET" request for "/" from "127.0.0.1"
>> [debug] Path is "/"
>> [debug] Response Code: 200; Content-Type: text/html; charset=utf-8; Conten
>> th: 5613
>> [info] Request took 0.005551s (180.148/s)
>> .+---.
>> | Action | Time  |
>> ++---+
>> | /index | 0.000433s |
>> | /end   | 0.000502s |
>> '+---'
>>
>> [info] *** Request 15 (0.002/s) [] [Wed May 11 23:04:22 2011] ***
>> [debug] "GET" request for "hello" from "127.0.0.1"
>> [debug] Path is "/"
>> [debug] Arguments are "hello"
>> [debug] Response Code: 404; Content-Type: text/html; charset=utf-8; Conten
>> th: 14
>> [info] Request took 0.006333s (157.903/s)
>> .+---.
>> | Action | Time  |
>> ++---+
>> | /default   | 0.000263s |
>> | /end   | 0.000402s |
>> '+---'
>>
>> On Thu, May 12, 2011 at 1:06 AM, David Schmidt  wrote:
>>
>>>
>>>
>>> On Thu, May 12, 2011 at 9:03 AM, Brian Wolf  wrote:
>>>
>>>> hi, i am trying out the latest catalyst (installed runtime,and devel) ,
>>>> i am working through the tutorial , but example at the beginning to add the
>>>> hello to root.pm, the catalyst page is fine on  and
>>>> http://localhost:3000/  works, but when i tried making the edit to
>>>> root.pm file as shown in tutorial to do a simple url dispatch
>>>> http://localhost:3000/ hello  page not found
>>>>
>>>> ___
>>>> 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/
>>>>
>>>>
>>> Can you send us the output of the development server. Should look
>>> something like this ...
>>>
>>> david@foo:~/myapp/MyApp$ ./script/myapp_server.pl -d
>>> [debug] Debug messages enabled
>>> [debug] Statistics enabled
>>> [debug] Loaded plugins:
>>>
>>> ..
>>> | Catalyst::Plugin::ConfigLoader
>>> 0.30   |
>>>
>>> ''
>>>
>>> [debug] Loaded dispatcher "Catalyst::Dispatcher"
>>> [debug] Loaded engine "Catalyst::Engine::HTTP"
>>> [debug] Found home "/home/david/myapp/MyApp"
>>> [debug] Loaded Config "/home/david/myapp/MyApp/myapp.conf"
>>> [debug] Loaded components:
>>>
>>> .-+--.
>>> | Class   |
>>> Type |
>>>
>>&

Re: [Catalyst] noob tutorial help

2011-05-12 Thread David Schmidt
On Thu, May 12, 2011 at 9:03 AM, Brian Wolf  wrote:

> hi, i am trying out the latest catalyst (installed runtime,and devel) , i
> am working through the tutorial , but example at the beginning to add the
> hello to root.pm, the catalyst page is fine on  and http://localhost:3000/
>   works, but when i tried making the edit to root.pm file as shown in
> tutorial to do a simple url dispatch  http://localhost:3000/ hello
>    page not found
>
> ___
> 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/
>
>
Can you send us the output of the development server. Should look something
like this ...

david@foo:~/myapp/MyApp$ ./script/myapp_server.pl -d
[debug] Debug messages enabled
[debug] Statistics enabled
[debug] Loaded plugins:
..
| Catalyst::Plugin::ConfigLoader  0.30
|
''

[debug] Loaded dispatcher "Catalyst::Dispatcher"
[debug] Loaded engine "Catalyst::Engine::HTTP"
[debug] Found home "/home/david/myapp/MyApp"
[debug] Loaded Config "/home/david/myapp/MyApp/myapp.conf"
[debug] Loaded components:
.-+--.
| Class   | Type
|
+-+--+
| MyApp::Controller::Root   |
instance |
'-+--'

[debug] Loaded Private actions:
.--+--+--.
| Private  | Class| Method
|
+--+--+--+
| /default | MyApp::Controller::Root|
default  |
| /end | MyApp::Controller::Root|
end  |
| /index   | MyApp::Controller::Root|
index|
'--+--+--'

[debug] Loaded Path actions:
.-+--.
| Path| Private
|
+-+--+
| /   | /index
|
| /   | /default
|
'-+--'

[info] MyApp powered by Catalyst 5.80032
You can connect to your server at http://foo:3000
___
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] Help System - Can a controller's index capture the remainder of the path as a series of arguments?

2011-03-31 Thread David Schmidt
On Thu, Mar 31, 2011 at 6:22 PM, Bill Crawford
 wrote:
> On 31 March 2011 17:21, Bill Crawford  wrote:
>> sub help : Chained('/') Args {
>>    my ( $self, $c, @path ) = @_;
>>
>>    my $path = join('/', @path);
>>    ...
>> }
>
> Uh, : Chained('/') PathPart('help') Args { ...
>
> ___
> 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/
>

And use

http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80032/lib/Catalyst/Request.pm#$req-%3Epath

for creating the link of the help button

___
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 Model Class Variable from Catalyst Config

2011-03-28 Thread David Schmidt
On Mon, Mar 28, 2011 at 6:49 PM, Derek Wueppelmann  wrote:
> I want to be able to setup a configuration variable in my Catalyst config
> that will then be set as the value for one of my model's class variables.
> I have a model that will want to use a base path to store some files, However
> the Model doesn't know how to access Catalyst and so it can't get the data it
> needs. The other issue is that I need it as a class variable so that all of
> the instances of a particular class can access the same value once set. I'm
> thinking about calling an after method in the root Catalyst app module to set
> the variable, but I'm not sure which one I should modify.
>
> Anybody with some suggestions?
>
> --
>  o)   Derek Wueppelmann           (o
> (D .   dwuep...@gmail.com          D).
> ((`     http://www.monkeynet.ca   ( ) `
>
>
> ___
> 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/
>

Usually that's achieved by adding an attribute to your model and then
providing the value at model instantiation time

Example:
http://wiki.catalystframework.org/wiki/wikicookbook/configpass2schema

___
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] Formhandler and Auth

2011-03-07 Thread David Schmidt
On Mon, Mar 7, 2011 at 1:03 AM, Eric Berg  wrote:
> On 3/4/11 11:03 AM, Gerda Shank wrote:
>>
>> On 3/4/11 8:23 AM, Eric Berg wrote:
>>>
>>> I'm trying to do some progressive engagement by allowing one of my forms
>>> to be filled out before a user is required to log in, but once the form is
>>> filled, I need them to log in so that I can get the user ID, which is part
>>> of the record for that form's row in my db.
>>
>> So after the form is submitted, you want to save the form contents
>> somehow, then present a login form, then after the user logs in, save it to
>> the database?
>
> Yes.  What I did previously was just to save a hash of the values, but I'm
> not sure how to pass that to formhandler given that my db constraints
> currently require the values for this form to have a creator_id, which is
> just what I need from the login.  So, I'm thinking at this point that I need
> to find a way to pass a hash of form values back to formhandler..that's got
> to be possible, and must be done after I get the form submission or I'll
> have to loosen up the constraints on my db to allow me to insert rows
> without a creator ID.  I'm looking into that now.
>>
>> Is the part you're not sure of how/where to save the form contents? There
>> are the usual options for preserving data across several requests, i.e.
>> stash, database, etc.
>
> I've been stashing a hash of form params.  I have to test this out, but I
> have to figure out if I can validate the form without the creator_id's being
> present.  I added it to the form, because formhandler was barfing when I
> used the simple form of stashing the new_result({}), then returning
> $self->form($c) in my add().   I have to figure out how to validate the form
> wtihout having it submitted to teh db, because that causes an error when the
> creator_id is missing, or add the creator_id (hidden and empty) to the form
> and only validate after login.  I guess I just have to try a few things.  If
> any of you good folks have banged your head against this and have ideas,
> they'd certainly be welcome.
>>
>> Then you'd have to decide how you want to save the data. You *could* use
>> FormHandler to do that, but if you have an already validated set of data, it
>> might be simpler to just save it to the database yourself.
>
> May be.  Probably, since I'm trying to wrest control from formhandler so I
> can validate a form without the creator_id, then redirect to login, then
> take the values of the form and the logged-in user's id and commit that to
> the db.  One change that is causing me problems is that I moved from the
> approach of having the form be a simple attribute (has 'form') where I was
> doing all the processing in the show and add methods to the approach where I
> implemented $self->form() per the sample referenced in
> HTML::FormHandler::Manual::Catalyst.
>
> Thinking through this in writing this, I believe that what I have to do is
> reimplement the form as a simple attribute and then handle the process() as
> needed in the add() method.  I think that's where I shot myself in the foot.
>
> Thank you muchly.  I'll post my successful results for the benefit of those
> who follow.
>
> Eric
>>
>> I'm not quite sure if I addressed the particular issues you were having;
>> if not, please clarify :)
>>
>> Gerda
>>
>>
>> ___
>> 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/
>

I think I got 2 solutions for your problem.

1)
I split the form into MyFormBase.pm and MyForm

MyFormBase is a plain FormHandler class

MyForm on the other hand extends from MyFormBase and
HTML::FormHandler::Model::DBIC

I send a MyFormBase form to the user, validate it, store the values
$form->values (or something like that) in the session/flash and later
on use these values to fill an MyForm form.

https://github.com/davewood/Nolabel/tree/master/lib/Nolabel/Form

2) get the values from the form, store them in the session/flash, make
the database insert manually.

___
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] Formhandler and Auth

2011-03-04 Thread David Schmidt
On Fri, Mar 4, 2011 at 2:23 PM, Eric Berg  wrote:
> I'm trying to do some progressive engagement by allowing one of my forms to
> be filled out before a user is required to log in, but once the form is
> filled, I need them to log in so that I can get the user ID, which is part
> of the record for that form's row in my db.
>
> I'm using  HTML::FormHandler::Model::DBIC and generally sticking to the
> example here:
> http://search.cpan.org/~gshank/HTML-FormHandler-0.32005/lib/HTML/FormHandler/Manual/Catalyst.pod#A_Controller_Example
>
> The problem is that I don't know how to check to see if the form has been
> submitted and validated so that I know when to forward to /login.
>
> It feels to me like the approach laid out at the URL above is a bit simple
> for this approach, but so far I haven't figured out how to do anything more
> low-level.  Seems like setting the form as an attribute of the controller
> and then doing the processing and validating in my methods/actions might be
> the way to go.
>
> Anyone have any examples or advice?
>
> Thanks.
>
> Eric
>
> ___
> 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/
>
>

Been a while since I last used HFH but how about

$form->validated;

that should only return true if the form was validated and from
skimming through the docs validation is only done if form parameters
are present.

david

___
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] Weird problem with Catalyst::Authentication, and redirects

2011-01-26 Thread David Schmidt
On Wed, Jan 26, 2011 at 12:18 PM, Ben van Staveren
 wrote:
> Hi Denny & list,
>
>> Have you tried turning it off and then on again?  ;)
>>
> Repeatedly :)
>
>> More seriously, I have found on multiple occasions that the Catalyst
>> Auth stuff can seem to get itself into an inconsistent state, such that
>> it starts behaving oddly (usually mine will successfully log in, but
>> fail to keep track of that fact), and the only way to fix it is to
>> delete the contents of the session store (database, in my case), delete
>> all the cookies for the site, and possibly wipe the browser cache too.
>>
>> Other than that I'm not sure what to suggest.  Where does the auto
>> return to?  Is it possible it's coming back from there to before the
>> dashboard redirect, and so the redirect URL is getting overwritten
>> before the output is constructed?  (I've not used auto, so no idea if
>> this is a stupid question or not.)
>>
> On the off-hand of being wrong, as far as I know, auto is called before
> anything else is really done, so your dispatch chain ends up going
>
> auto -> action -> end
>
> I think. Anyways, I did clear the session store, zapped all the cookies, and
> the behaviour's still there. I did some Data::Dumper action, and even after
> the RenderView action class had it's way with things, the status is still
> set to 302, a Location header is present in the output, but it did render
> the template that it's not supposed to render.
>
> Even if I do a "$c->detach('end') and return 0", it will render a template,
> which by all accounts, it's not supposed to be doing.
>
> Doing a telnet to the dev server and querying it does return the proper
> headers for a redirect as well; Status: 302 and Location: /login - but it
> also renders the output body, for some really freaky reason.
>
> The main issue for me is that this behaviour seems to be triggered by
> something I did in controller code somewhere, but I could swear up and down
> that I haven't done anything that touches even remotely near authentication
> or the Auth guts, so I'm totally and utterly stumped. And it's kind of
> important this works, deadlines and such things :(
>
> --
>
> Ben van Staveren
> phone: +62 81 70777529
> email: benvanstave...@gmail.com
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



If all you want to do is redirecting the user to /login if he isn't
logged in you could try CatalystX::SimpleLogin.
Using auto for that stuff is kinda deprecated according to what I
overheard in the irc channel.

I couldn't find an error in what little information you have provided.
I'd probably go and

-) check if all relevant modules are up to date.
-) try with a different browser
-) create a simple app and try this particular code there.

david

___
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] In HTML::FormHandler search form (no DB schema) -- how to populate a SELECT field via DBIx::Class?

2011-01-20 Thread David Schmidt
On Thu, Jan 20, 2011 at 11:20 AM, Alexander Hartmaier
 wrote:
> Why not solve it the exact same way?
> Defined a schema attribute an pass your schema when constructing the
> form object.
> Maybe you only want to pass the country rs instead, whatever fits your
> needs best.
>
> Also note that HFH will automatically detect a belongs_to and populate
> the Select without a need for the options_country sub!
>
> Come to #formhandler if you have more questions.
>
> --
> Best regards, Alex
>
>
> On Sun, 2011-01-16 at 16:41 +0100, will trillich wrote:
>> Short version: If you have a HTML::FormHandler search form without a
>> "has_field '+item_class'" (there's no data-base row corresponding to
>> its contents) how to you reach your DBIx::Class schemas to populate a
>> drop-down menu?
>>
>>
>>
>>
>> Long version: This is in the context of a Catalyst app -- however, I
>> do know this is either FormHandler question or a DBIC question, and
>> not intrinsically a Catalyst question, but... hoping the wise folks
>> here can nudge me in the right direction...
>>
>>
>> We have several DBIC resultsets including Incident and Country. The
>> Incident record has this relationship:
>> __PACKAGE__->belongs_to( 'country' =>
>> 'Incident::Schema::DB::Result::Country' );
>>
>>
>> (And the country schema has_many incidents, of course)
>>
>>
>> For the CRUD form related to the actual incident table, we have a
>> matching HTML::FormHandler package with its
>> has '+item_class'
>> as expected. This makes it easy to create a
>> sub options_country {
>>   my $self = shift;
>>   return unless $self->schema;
>>   my $rs = $self->schema->resultset('Country');
>>   #...
>> }
>> subroutine for the form, for populating a country drop-down menu in
>> the HTML.
>>
>>
>> But!
>>
>>
>> For the SEARCH form, we are not interested in CRUD, plus we have extra
>> fields (for example, we want the user to be able to bracket dates with
>> a start-field and an end-field) so there's no one-to-one correlation
>> with the database table -- meaning there's no "item_class" for the
>> search form. And hence no schema to rely on.
>>
>>
>> What we're looking for now -- unless there's a better more obvious
>> paradigm -- is a way to get from an instance of the schema-object,
>> back to the resultset, for searching.
>> sub options_country {
>>   my $self = shift; # note $c is not available here :(
>>   # $self->schema will be UNDEF here
>>   my $obj = Spill::Schema::DB::Result::Country->new; # Hard-wired,
>> yes, is there a better way?
>>   my $rs = $obj->???
>>   # ?
>> }
>>
>>
>> I've looked at
>> - $obj->result_source (Can't call method "resolve" on an undefined
>> valued in DBIx/Class/Row)
>> - $obj->result_source_instance->resultset (Can't call method
>> "default_resultset_attributes" on an undef value in
>> DBIx/Class/ResultSource)
>> - $obj->result_source_instance->resultset_class->search({},{}) (Can't
>> use string as a HASH ref in DBIx/Class/ResultSet)
>> and a couple other dead ends.
>>
>>
>> It's likely to be something obvious I've overlooked. :( Suggestions?
>>
>> --
>> The first step towards getting somewhere is to decide that you are not
>> going to stay where you are.  -- J.P.Morgan
>>
>
>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> 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/
>

I agree with Alexander,

this cookbook section should be helpful

http://search.cpan.org/~gshank/HTML-FormHandler-0.32005/lib/HTML/FormHandler/Manual/Cookbook.pod#Server-provided_dynamic_value_for_field

___
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] Retrieve all users belong to a category and all its sub categories

2010-12-09 Thread David Schmidt
On Thu, Dec 9, 2010 at 9:37 AM, linuxsupport  wrote:
> I have 3 tables, users, user_cat, and cat, table structure and relationship
> are setup as follows.
>
> User.pm
>
> __PACKAGE__->add_columns(
>   "id",
>   { data_type => "integer", is_nullable => 0 },
>   "username",
>   { data_type => "text", is_nullable => 1 },
>   "password",
>   { data_type => "text", is_nullable => 1 },
>   "email_address",
>   { data_type => "text", is_nullable => 1 },
>   "first_name",
>   { data_type => "text", is_nullable => 1 },
>   "last_name",
>   { data_type => "text", is_nullable => 1 },
>   "active",
>   { data_type => "integer", is_nullable => 1 },
> );
> __PACKAGE__->set_primary_key("
> id");
>
> __PACKAGE__->has_many("usercats", "Example::Schema::Result::UserCat",{
> "foreign.user_id" => "self.id" },);
> __PACKAGE__->many_to_many(cats => 'usercats', 'cat');
>
> UserCat.pm
>
> __PACKAGE__->add_columns(
>   "user_id",
>   { data_type => "integer", is_nullable => 0 },
>   "cat_id",
>   { data_type => "integer", default_value => 0, is_nullable => 0 },
> );
> __PACKAGE__->set_primary_key("user_id", "cat_id");
>
> __PACKAGE__->belongs_to("user", "Example::Schema::Result::User", { id =>
> "user_id" },{ join_type => "LEFT" },);
> __PACKAGE__->belongs_to("cat", "Example::Schema::Result::Cat", { id =>
> "cat_id" },{ join_type => "LEFT" },);
>
> Cat.pm
>
> __PACKAGE__->add_columns(
>   "id",
>   { data_type => "integer", is_nullable => 0 },
>   "cat_name",
>   { data_type => "text", is_nullable => 0 },
>  "parent_id",
>   { data_type => "integer", is_nullable => 0 },
> );
> __PACKAGE__->set_primary_key("id","parent_id");
>
> __PACKAGE__->has_many("usercat","Example::Schema::Result::UserCat",{
> "foreign.cat_id" => "self.id" },);
> __PACKAGE__>many_to_many("allcat", "usercat', "cat");
>
> I am able to retrieve all users in any particular category using "allcat"
> many_to_many relationship.
>
> In cat table I have both category and sub category, if a row have parent_id
>> 0 then it is sub category.
>
> How can I get all users belong to one category and its sub categories?
>
> Thanks in advance.
>
>
> ___
> 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/
>
>

That's entirely a DBIx::Class question. You might want to ask in
#dbix-class on irc.perl.org or at the DBIx::Class mailinglist
http://lists.scsys.co.uk/mailman/listinfo/dbix-class

david

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


Re: [Catalyst] Transferring control via root/auto

2010-12-07 Thread David Schmidt
On Tue, Dec 7, 2010 at 4:53 PM, Thompson  wrote:
> Here is my problem,
>
> If a user logs in for the 1st time I want to force them to change their
> password.  I have a specific action in my Users controller to handle
> that.  What I'm having a problem with is (redirecting or forwarding or
> detaching - i've tried them all) from the root/auto function to my
> specific controller function.  I either get an internal server error or
> page isn't redirecting properly, depending what i use.  I've put my
> logic in the root/auto because regardless of the request changing their
> password is mandatory.
>
> Here is my current root/auto using redirect.
>
> sub auto : Private {
>          my ($self, $c) = @_;
>
>          if ($c->user_exists()&&  $c->check_any_user_role('User')
> &&  $c->user->changePassword  ) {
>
> $c->res->redirect($c->uri_for($c->controller('Users')->action_for('loginedit'),
> [$c->user->id] ));
>                 $c->detach();
>          }
>
>          return 1;
>      }
>
> Any help would be appreciated.
> Rob T
>
> ___
> 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 wouldn't put that into an auto method. I remember t0m saying that
you can use Chained Dispatchtype instead of auto most of the time.

Anyways, the error message of your devel server would sure help
finding the problem.

david

___
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] One controller from other

2010-12-04 Thread David Schmidt
On Sun, Dec 5, 2010 at 6:32 AM, linuxsupport  wrote:
> Yes, other controller has just logic it use a model to get user list from
> database.
> However, I forgot to pass $c context. it is working as following
>
> $c->controller('User')->users($c);
>
> Thanks
> Aniruddh
>
> On Sun, Dec 5, 2010 at 1:25 AM, David Schmidt  wrote:
>>
>> On Sat, Dec 4, 2010 at 4:00 PM, linuxsupport 
>> wrote:
>> > Hi,
>> >
>> > How can I access one controller from other?
>> >
>> > I have 2 controllers called Myapp::Controller::User and
>> > Myapp::Controller::Admin
>> >
>> > In Myapp::Controller::User I have following method.
>> >
>> > sub user_list :Path Args:(0) {
>> >    some function to display all the users.
>> > }
>> >
>> > Myapp::Controller::Admin has following method
>> >
>> > sub users :Path Args(0) {
>> >   Here I want to display all users by calling Myapp::Controller::User
>> >   $c->controller('Myapp::Controller::User')->user_list is not working
>> > }
>> >
>> > any suggestion?
>> >
>> > 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/
>> >
>> >
>>
>> Don't abuse your Controller as a model.
>> Controllers ideally only contain logic important for the GUI flow.
>> Returning a list of users should be provided by a models method.
>>
>> david
>>
>> ___
>> 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/
>
>

It's still wrong to call a method on another controller to get a list of users.
You should definitely read more about MVC.
start here: 
http://search.cpan.org/~zarquon/Catalyst-Manual-5.8005/lib/Catalyst/Manual/About.pod#The_MVC_pattern

___
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] Custom 404 Error Page

2010-12-04 Thread David Schmidt
On Sat, Dec 4, 2010 at 5:30 PM, linuxsupport  wrote:
> Hi,
>
> I want to implement custom error page for 404.
>
> I want to show a particular page when user sends a request to non-existence
> page instead of displaying "Page not found" (default).
>
> Many 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/
>
>

http://search.cpan.org/~jkutej/Catalyst-Plugin-CustomErrorMessage-0.06/lib/Catalyst/Plugin/CustomErrorMessage.pm

That should get you started.

david

___
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] One controller from other

2010-12-04 Thread David Schmidt
On Sat, Dec 4, 2010 at 4:00 PM, linuxsupport  wrote:
> Hi,
>
> How can I access one controller from other?
>
> I have 2 controllers called Myapp::Controller::User and
> Myapp::Controller::Admin
>
> In Myapp::Controller::User I have following method.
>
> sub user_list :Path Args:(0) {
>    some function to display all the users.
> }
>
> Myapp::Controller::Admin has following method
>
> sub users :Path Args(0) {
>   Here I want to display all users by calling Myapp::Controller::User
>   $c->controller('Myapp::Controller::User')->user_list is not working
> }
>
> any suggestion?
>
> 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/
>
>

Don't abuse your Controller as a model.
Controllers ideally only contain logic important for the GUI flow.
Returning a list of users should be provided by a models method.

david

___
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] Which Form Validation Libs?

2010-11-30 Thread David Schmidt
another great module which from my perception is used the most lately is

HTML::FormHandler
http://search.cpan.org/~gshank/HTML-FormHandler-0.32005/

greetings
david

On Tue, Nov 30, 2010 at 9:24 AM, Mike Raynham
 wrote:
> On 30/11/10 03:34, Eric Berg wrote:
>>
>> I see that there are a number of form validation libraries that purport
>> to work with Catalyst. I've been using CGI::Formbuilder for years and
>> have been relatively happy with it.
>>
>> I need something for my new Catalyst app. I have already created my
>> forms in my TT templates, but I need validation for most of the regular
>> stuff, including zip codes, states, credit card info, etc.
>>
>> You guys got any recommendations?
>>
>> Thanks.
>>
>> Eric
>
>
> I have just started to look at Data::FormValidator:
>
> "Data::FormValidator lets you define profiles which declare the required and
> optional fields and any constraints they might have."
>
> You can use the built-in constraints, use existing CPAN modules (e.g.,
> Email::Valid), and add your own custom constraints - maybe incorporating
> MooseX::Types and MooseX::Types::Structured, as suggested by Darren Duncan.
>
> It doesn't generate form HTML for you, but I prefer to manually create this
> anyway.
>
>
> Regards,
>
> Mike
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

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


Re: [Catalyst] Multiple chain sources?

2010-11-22 Thread David Schmidt
On Mon, Nov 22, 2010 at 9:24 AM, David Schmidt  wrote:
> On Mon, Nov 22, 2010 at 6:15 AM, Matthew Braid  wrote:
>> Hi all,
>>
>> Just wondering - is it possible for an action to have multiple chain paths?
>>
>> I'd like my site to have a path like /user/N/profile (/user/N being a
>> chain path, /profile being an end node off that path), but also have a
>> path like /my/profile (where /my is a chain path that acts as if the
>> user put their own ID on the end of /user/N).
>>
>> Currently I have /user/N as a chain path, /my as a chain path, and
>> then a profile action (path: /profile) that chains off of /user/N and
>> a this_profile action (path: /profile) that chains off of /my that
>> simply calls the profile action like so:
>>
>> # in the User controller
>>
>> sub user :Chained('/') :PathPart('user') :CaptureArgs(0) {
>>  # This is only here so a (not shown) chain makes '/user' a valid path
>> }
>>
>> sub specific_user :Chained('user') :PathPart('') :CaptureArgs(1) {
>>  # Captured arg goes in $c->stash->{userid}
>> }
>>
>> sub this_user :Chained('/') :PathPart('my') :CaptureArgs(0) {
>>  # The current user's ID goes in $c->stash->{userid}
>> }
>>
>> sub profile :Chained('specific_user') :PathPath('profile') :Args(0) {
>>  # Do stuff using $c->stash->{userid}
>> }
>>
>> sub this_profile :Chained('this_user') :PathPart('profile') :Args(0) {
>>  # Dummy - redirect to the main 'profile' action
>>  shift->profile(@_);
>> }
>>
>> This works, but is it the best way to do it?
>>
>> TIA,
>> MDB
>>
>> ___
>> 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/
>>
>
> Usually my setup looks like this
>
> # put resultset into stash
> sub base : Chained('/') PathPart('users') CaptureArgs(0) {
>    $c->stash(users_rs => $c->model('DB::Users');
> }
>
> # find user in resultset, check for existance
> sub base_with_id : Chained('base') PathPart('') CaptureArgs(1) {
>    my ($self, $c, $id ) = @_;
>    my $user = $c->stash->{users}->find($id);
>    if ($user) {
>        $c->stash(user => $user);
>    } else {
>        $c->stash(error_msg => 'not_found');
>        $c->detach('/error404');
>    }
> }
>
> sub index : Chained('base') ...
> sub show : Chained('base_with_id') ...
> sub create : Chained('base') ...
> sub edit : Chained('base_with_id') ...
> sub delete : Chained('base_with_id') ...
> sub profile : Chained('base_with_id') ...
>
> If I want a /my/profile now I'd just add another sub
>
> # put user_id in stash, then make full chain dispatch
> sub my_profile : Path('/my/profile') Args(0) Does('NeedsLogin') {
>    my ($self, $c) = @_;
>    $c->go($self->action_for('profile'), [ $c->user->id ]);
> }
>
> OR
>
> # put user obj in stash, then visit just "profile"
> sub my_profile : Path('/my/profile') Args(0) Does('NeedsLogin') {
>    my ($self, $c) = @_;
>    $c->stash(user => $c->user->obj;
>    $c->detach($self->action_for('profile'));
> }
>

ERRATA:

in sub base_with_id
my $user = $c->stash->{users_rs}->find($id);

___
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] Multiple chain sources?

2010-11-22 Thread David Schmidt
On Mon, Nov 22, 2010 at 6:15 AM, Matthew Braid  wrote:
> Hi all,
>
> Just wondering - is it possible for an action to have multiple chain paths?
>
> I'd like my site to have a path like /user/N/profile (/user/N being a
> chain path, /profile being an end node off that path), but also have a
> path like /my/profile (where /my is a chain path that acts as if the
> user put their own ID on the end of /user/N).
>
> Currently I have /user/N as a chain path, /my as a chain path, and
> then a profile action (path: /profile) that chains off of /user/N and
> a this_profile action (path: /profile) that chains off of /my that
> simply calls the profile action like so:
>
> # in the User controller
>
> sub user :Chained('/') :PathPart('user') :CaptureArgs(0) {
>  # This is only here so a (not shown) chain makes '/user' a valid path
> }
>
> sub specific_user :Chained('user') :PathPart('') :CaptureArgs(1) {
>  # Captured arg goes in $c->stash->{userid}
> }
>
> sub this_user :Chained('/') :PathPart('my') :CaptureArgs(0) {
>  # The current user's ID goes in $c->stash->{userid}
> }
>
> sub profile :Chained('specific_user') :PathPath('profile') :Args(0) {
>  # Do stuff using $c->stash->{userid}
> }
>
> sub this_profile :Chained('this_user') :PathPart('profile') :Args(0) {
>  # Dummy - redirect to the main 'profile' action
>  shift->profile(@_);
> }
>
> This works, but is it the best way to do it?
>
> TIA,
> MDB
>
> ___
> 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/
>

Usually my setup looks like this

# put resultset into stash
sub base : Chained('/') PathPart('users') CaptureArgs(0) {
$c->stash(users_rs => $c->model('DB::Users');
}

# find user in resultset, check for existance
sub base_with_id : Chained('base') PathPart('') CaptureArgs(1) {
my ($self, $c, $id ) = @_;
my $user = $c->stash->{users}->find($id);
if ($user) {
$c->stash(user => $user);
} else {
$c->stash(error_msg => 'not_found');
$c->detach('/error404');
}
}

sub index : Chained('base') ...
sub show : Chained('base_with_id') ...
sub create : Chained('base') ...
sub edit : Chained('base_with_id') ...
sub delete : Chained('base_with_id') ...
sub profile : Chained('base_with_id') ...

If I want a /my/profile now I'd just add another sub

# put user_id in stash, then make full chain dispatch
sub my_profile : Path('/my/profile') Args(0) Does('NeedsLogin') {
my ($self, $c) = @_;
$c->go($self->action_for('profile'), [ $c->user->id ]);
}

OR

# put user obj in stash, then visit just "profile"
sub my_profile : Path('/my/profile') Args(0) Does('NeedsLogin') {
my ($self, $c) = @_;
$c->stash(user => $c->user->obj;
$c->detach($self->action_for('profile'));
}

___
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] Trouble using Catalyst::Controller::FormBuilder

2010-11-10 Thread David Schmidt
On Wed, Nov 10, 2010 at 2:37 PM, Eric Berg  wrote:
> I'm trying to get Catalyst::Controller::FormBuilder to work, but am running
> into some problems.  Per the docs, the config should be like this:
>
> use base 'Catalyst::Controller::FormBuilder';
>
> But my class is from a brand-new Catalyst install, so it's using extends
> like this:
>
> BEGIN {extends 'Catalyst::Controller'; }
>
>
> So I changed it to this:
>
> BEGIN {extends 'Catalyst::Controller::FormBuilder'; }
>
> And now I'm seeing this error:
>
> Couldn't load class (GLR) because: Couldn't instantiate component
> "GLR::Controller::Payment", "The 'add_attribute' method cannot be called on
> an immutable instance at
> /usr/local/lib/perl/5.10.1/Class/MOP/Class/Immutable/Trait.pm line 32
>
>
> Can anyone steer me in the right direction to get this working?  BTW, I'm a
> long-time Perl guy, but this is my first Catalyst app.
>
> Thanks!
>
> Eric
>
>
>
>
>
>
> ___
> 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/
>

People seem to move towards HTML::FormHandler these days.
http://search.cpan.org/~gshank/HTML-FormHandler-0.32005/

___
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] error handling (Chain where ajax and non-ajax actions chain off)

2010-11-09 Thread David Schmidt
On Tue, Nov 9, 2010 at 11:38 AM, Eden Cardim  wrote:
>>>>>> "David" == David Schmidt  writes:
>
>    David> Hello list Both ajax and non-ajax actions chain off the same
>    David> action (base_with_id). If an error occurs (like the resource
>    David> doesn't exist) I detach to '/error404' in my Root Controller.
>    David> I just introduced the ajax stuff and before that 'error404'
>    David> simply rendered an error template. Now I'd like to check if
>    David> it is an xmlhttp request using
>    David> 
> http://search.cpan.org/~flora/Catalyst-TraitFor-Request-XMLHttpRequest-0.01/
>    David> and then either render the error template like before OR use
>    David> the status_not_found() helper from
>    David> http://search.cpan.org/~bobtfish/Catalyst-Action-REST-0.87/
>
>    David> To use status_not_found I need to extend my Root Controller
>    David> from Catalyst::Controller::REST
>
>    David> That'd mean i have to check the type of request again in my
>    David> roots end method to avoid rendering of the template.
>
>
>    David> #Root.pm
>    David> sub render : ActionClass('RenderView') {}
>    David> sub end :Private {
>    David>     my ($self, $c) = @_;
>    David>     unless ($c->request->is_xhr) {
>    David>         $c->forward('render');
>    David>     }
>    David> }
>
>    David> Any comments on that solution are appreciated as are pointers
>    David> to alternatives.
>
> Put the ajax code into a separate controller with an XHR-specific end
> action (probably empty, for your case) and chain from there.


I tend to put related actions into a controller. E.g.: all actions
dealing with artists into the Artists.pm controller and so on.
You advise (as I understood) means having an additional controller for
every controller where I want to support XHR requests.

Is there a flaw in how I lay out my controllers?

david

___
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] error handling (Chain where ajax and non-ajax actions chain off)

2010-11-09 Thread David Schmidt
Hello list

Both ajax and non-ajax actions chain off the same action
(base_with_id). If an error occurs (like the resource doesn't exist) I
detach to '/error404' in my Root Controller.
I just introduced the ajax stuff and before that 'error404' simply
rendered an error template. Now I'd like to check if it is an xmlhttp
request using 
http://search.cpan.org/~flora/Catalyst-TraitFor-Request-XMLHttpRequest-0.01/
and then either render the error template like before OR use the
status_not_found() helper from
http://search.cpan.org/~bobtfish/Catalyst-Action-REST-0.87/

To use status_not_found I need to extend my Root Controller from
Catalyst::Controller::REST

That'd mean i have to check the type of request again in my roots end
method to avoid rendering of the template.

#Root.pm
sub render : ActionClass('RenderView') {}
sub end :Private {
my ($self, $c) = @_;
unless ($c->request->is_xhr) {
$c->forward('render');
}
}


Any comments on that solution are appreciated as are pointers to alternatives.

david


#User.pm
sub base : Chained('') PathPart('') CaptureArgs(0) {
my ($self, $c ) = @_;
$c->stash(users_rs => $c->model('DB::Users'));
}

sub base_with_id : Chained('base') PathPart('') CaptureArgs(1) {
my ($self, $c, $id ) = @_;
my $user = $c->stash->{'users_rs'}->find($id);
if ($user) {
$c->stash(user = $user);
} else {
$c->stash(error_msg => 'User not found.');
$c->detach('/error404');
}
}

___
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] myapp_test.pl - running code from the command line

2010-11-03 Thread David Schmidt
On Wed, Nov 3, 2010 at 7:40 AM, Jonathon Soong
 wrote:
> Hi
>
>> What kind of code do you actually want to run?
>> Perhaps it would be smarter to put that code into the model and then
>> run a perl script from cron that makes use of that model thus
>> bypassing the HTML authentication (which might be ok considering the
>> code is run from the system)
>
> Yes I realise now it might make more sense in the Model, but at the moment it 
> is in the Controller (it is someone else's code, so more difficult for me to 
> refactor).
>
> There are two questions I have then:
> 1. How do you call a Model's function from the command line?
> 2. Is there no way to call controller methods that require authentication?
>
> Thanks
>
>
> Jon
>
>
> ___
> 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/
>
>

1) put code in an app independent module, your model uses that module
and so can you.
2) http://search.cpan.org/~petdance/WWW-Mechanize-1.66/lib/WWW/Mechanize.pm

... oh and what Octavian said.

___
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] myapp_test.pl - running code from the command line

2010-11-02 Thread David Schmidt
On Wed, Nov 3, 2010 at 5:08 AM, Jonathon Soong
 wrote:
> Hi guys
>
> I am new to Catalyst and have a question :)
>
> I'd like the ability to run some of the code of my website from the
> command line ( a cron job ).
>
> Usually this would be achieved by a person logging into the website and
> clicking on a particular button which hits a controller.
>
> I saw that there is a myapp_test.pl that can call a particular address,
> so i tried this:
>
> This works fine:
> $>  perl script/myapp_test.pl /login
>
> I can see the HTML get printed out on my screen.
>
> But when I try to get to a deeper URL it does not work:
>  perl script/isrms_test.pl /my/other/url
>
> I think this is because there is authentication on the site?
>
> Is this the way I should be going about trying to do this? Is there a
> better way to do this?
>
> Thanks
>
> Jon
>
>
> ___
> 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/
>

Hey Jon,

What kind of code do you actually want to run?
Perhaps it would be smarter to put that code into the model and then
run a perl script from cron that makes use of that model thus
bypassing the HTML authentication (which might be ok considering the
code is run from the system)

david

___
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] Has anyone read the book "Catalyst 5.8 : The Perl MVCFramework" yet?

2010-10-26 Thread David Schmidt
On Tue, Oct 26, 2010 at 8:03 AM, Octavian Rasnita  wrote:
> IMHO the dispatching is a very important chapter for a web framework,
> especially for Catalyst that has so many things to offer in this field.
>
> And another important thing is to show how Catalyst works alone, without an
> ORM, without a templating system, without a form processor, with the warning
> that this not the right way to do it, but it is very important for the
> beginners to see which are the things that depend on Catalyst and which are
> those that depend on the ORM or templating system.
>
> And another important thing is to use a lot of warnings that "This is not
> the right way" when DBIC code is used in the controllers for beeing easier
> to understand by the beginners, but to let them know that that way of doing
> things should be avoided.
>
> And it should be very helpful to show examples of models that get data and
> save data, but models that don't use an ORM like DBIC.
>
> --Octavian
>
> - Original Message - From: "Kieren Diment" 
> To: "The elegant MVC web framework" 
> Sent: Tuesday, October 26, 2010 7:57 AM
> Subject: Re: [Catalyst] Has anyone read the book "Catalyst 5.8 : The Perl
> MVCFramework" yet?
>
>
> Wrong book.  The discussion was about the new edition of the Packt book. You
> appear to be referring to the Apress book "The Definitive Guide to Catalyst"
>
> With the Apress book, we assumed that you could read the freely available
> tutorial already, so our aim wasn't to duplicate that.
>
> Should we ever go to second edition I'd like to significantly expand the
> cookbook chapter (which I must respectfully disagree is of great usefulness
> to the beginner - I'm also strongly of the opinion that the Chained dispatch
> type chapter is also of great use to the beginner, although the point may
> not be immediately apparent until you start designing your own application's
> dispatch structure).
>
> On 25/10/2010, at 11:23 AM, John Karr wrote:
>
>> It came out just as I was trying to learn catalyst. From a beginner
>> perspective it wasn't of any value -- thankfully Kennedy Clark has been
>> doing an excellent job with the Tutorial on CPAN, because that's how I
>> figured most things out. I was severely disappointed with the book, and
>> not
>> the least concerned with LOLCats and Kitty Pidgin. The people who wrote
>> the
>> book are a very knowledgeable group and sometimes their book works as a
>> reference, but overall doesn't seem add a lot to what's already in the
>> documentation, while being of no value to beginners whatsoever.
>>
>>
>>
>> It would be nice to have a good beginner book and a more advanced book. If
>> any of the more advanced programmers on this list would like someone to
>> help
>> with writing the beginner book, don't hesitate to get in touch!
>>
>>
>>
>>
>> From: Philip Medes [mailto:pmedes_2...@yahoo.com]
>> Sent: Friday, October 01, 2010 5:33 PM
>> To: The elegant MVC web framework
>> Subject: Re: [Catalyst] Has anyone read the book "Catalyst 5.8 : The Perl
>> MVC Framework" yet?
>>
>>
>>
>> I actually read the first 2 chapters and tried the examples.   I haven't
>> had
>> time to finish the book.
>> I haven't read any other books on Catalyst, but I do like the Sitepoint
>> books better ("Build Your Own Ruby On Rails Web Applications").
>>
>>  _
>>
>> From: Kiffin Gish 
>> To: catalyst@lists.scsys.co.uk
>> Sent: Fri, October 1, 2010 3:15:47 PM
>> Subject: [Catalyst] Has anyone read the book "Catalyst 5.8 : The Perl MVC
>> Framework" yet?
>>
>> I recently received a copy of the book "Catalyst 5.8 : The Perl MVC
>> Framework" for review, have read it and tried out the examples.
>>
>> Before I make my judgments public, I'd first be curious to hear from
>> others in the Catalyst Community about what their views are on the
>> book.
>>
>> Those that have "actually read" the book, that is. I've already seen a
>> couple blog entries and they tend to be fairly negative (we sure prefer
>> to rant).
>>
>> --
>> Kiffin Gish 
>> Gouda, The Netherlands
>>
>>
>>
>> ___
>> 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/
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo

[Catalyst] Re: Error handling in Template render

2010-09-30 Thread David Schmidt
On Thu, Sep 30, 2010 at 8:27 AM, David Schmidt  wrote:
> If an exception is thrown it's usually put into the $c->error array.
> When this error happens during rendering this doesn't seem to be the
> case and I am trying to find out what Catalyst is doing.
>
>
> In my example forward('render') causes the body to be filled with an
> error array.
>
>
> This is the body after forward('render')
>
> $VAR1 = bless( [
>                 'undef',
>                 bless( {
>                          'msg' =>
> 'Physio::Schema::Result::Exercises::media(): DBI Exception:
> DBD::Pg::st execute failed: ERROR:  column me.mediatype does not exist
> LINE 1: ..., me.name, me.position, me.file, me.content_type, me.mediaty...
>                                                             ^ [for
> Statement "SELECT me.id, me.exercise_id, me.name, me.position,
> me.file, me.content_type, me.mediatype, me.created, me.updated FROM
> media me WHERE ( me.exercise_id = ? ) ORDER BY position" with
> ParamValues: 1=\'1\'] at
> /home/david/catalyst/Physio/root/templates/exercises/show.tt line 17
> '
>                        }, 'DBIx::Class::Exception' ),
>                 \'
> ...'
>               ], 'Template::Exception' );
>
>
>
>
> How do I handle this kind of error?
>
>
> sub end : Private {
>    my ($self, $c) = @_;
>
>    $c->forward('render');
>
>    # display catalyst error page
>    return if $c->debug;
>    # in production log error and display nice error page
>    if (@{$c->error}) {
>        for my $error (@{$c->error}) {
>            $c->log->error($error);
>        }
>        $c->stash(template => 'error.tt');
>        $c->clear_errors;
>    }
> }
>
> sub render : ActionClass('RenderView') {}
>



After reading the Catalyst::View::TT::render source where I found this

$c->log->debug('The Catalyst::View::TT render() method will start
dying on error in a future release. Unless you are calling the
render() method manually, you probably want the new behaviour, so set
render_die => 1 in config for ' . blessed($self) . '. If you wish to
continue to return the exception rather than throwing it, add
render_die => 0 to your config.') if $c->debug;



'MyApp::View::TT' => {
   render_view => 1,
   ...
},

in MyApp.pm I am getting close to the behaviour I want. I have to
forward to render again after setting the error template though.


sub end : Private {
   my ($self, $c) = @_;

   $c->forward('render');

   # display catalyst error page
   return if $c->debug;

   # in production log error and display nice error page
   if (@{$c->error}) {
   for my $error (@{$c->error}) {
   $c->log->error($error);
   }
   $c->stash(template => 'error.tt');
   $c->clear_errors;
   $c->forward('render'); # trigger rendering
   }
}

sub render : ActionClass('RenderView') {}

___
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] Error handling in Template render

2010-09-29 Thread David Schmidt
If an exception is thrown it's usually put into the $c->error array.
When this error happens during rendering this doesn't seem to be the
case and I am trying to find out what Catalyst is doing.


In my example forward('render') causes the body to be filled with an
error array.


This is the body after forward('render')

$VAR1 = bless( [
 'undef',
 bless( {
  'msg' =>
'Physio::Schema::Result::Exercises::media(): DBI Exception:
DBD::Pg::st execute failed: ERROR:  column me.mediatype does not exist
LINE 1: ..., me.name, me.position, me.file, me.content_type, me.mediaty...
 ^ [for
Statement "SELECT me.id, me.exercise_id, me.name, me.position,
me.file, me.content_type, me.mediatype, me.created, me.updated FROM
media me WHERE ( me.exercise_id = ? ) ORDER BY position" with
ParamValues: 1=\'1\'] at
/home/david/catalyst/Physio/root/templates/exercises/show.tt line 17
'
}, 'DBIx::Class::Exception' ),
 \'
...'
   ], 'Template::Exception' );




How do I handle this kind of error?


sub end : Private {
my ($self, $c) = @_;

$c->forward('render');

# display catalyst error page
return if $c->debug;
# in production log error and display nice error page
if (@{$c->error}) {
for my $error (@{$c->error}) {
$c->log->error($error);
}
$c->stash(template => 'error.tt');
$c->clear_errors;
}
}

sub render : ActionClass('RenderView') {}

___
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] Reuse of controllers

2010-09-19 Thread David Schmidt
On Mon, Sep 20, 2010 at 4:33 AM, John Romkey  wrote:
> On Sep 19, 2010, at 10:02 PM, Pavel A. Karoukin wrote:
>> I started to play more often with Catalyst framework and found that I often 
>> need to re-use some controllers logic. What the best DRY way to deal, for 
>> example, with Login/Register/Forgotpassword controllers?
>>
>> I mean I created one controller for one app. For another app I am doing I 
>> need to recreate everything, which ends up in plain copy/pasting and 
>> changing class names. I do not like this, this doesn't feel DRY. Is there 
>> some better way? Something plugable and unplugable with their own 
>> models/controller/view may be?
>
> One approach is to simply inherit from the controller you want to reuse. So, 
> package up the controllers you want to reuse together, then use Moose to 
> extend them in the  controller modules in each app that uses them. That 
> allows you quite a bit of flexibility; use a common convention for the start 
> of the dispatch chain (for instance, 'base') for each controller and then 
> your subclass can map its parent controller to whatever path is best for each 
> app.
>        - john romkey
>        http://www.romkey.com/
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

Another nice approach to reuse Controller Logic is to use Moose Roles.

I got the basics from t0ms blog
(http://bobtfish.livejournal.com/#post-bobtfish-264317)
An example how i use it can be found here
http://wiki.catalystframework.org/wiki/wikicookbook/controllerwithfileupload
(the interesting part is in the file Resource.pm in the attachment
http://wiki.catalystframework.org/wiki/wikicookbook/ControllerWithFileUpload.attachment/100)


*
package CatalystX::TraitFor::Controller::Resource;
use MooseX::MethodAttributes::Role;
use namespace::autoclean;

sub base : Chained('') PathPart('') CaptureArgs(0) {
my ($self, $c ) = @_;
...
};

sub index :Chained('base') :PathPart('') :Args(0) {
my ($self, $c ) = @_;
...
}
1;
*



david

___
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 management with Catalyst (with email and URLs)

2010-08-26 Thread David Schmidt
On Thu, Aug 26, 2010 at 4:34 PM, Bill Moseley  wrote:
>
>
> On Thu, Aug 26, 2010 at 4:10 AM, David Schmidt  wrote:
>>
>> 1) user enters mailaddress and hits submit
>> 2) you generate a digest
>> 3) store digest + mailaddress in model
>
> I currently collect info and store and then also save the digest.  After
> seeing how much cruft get collected, I'd be tempted now to first send out
> the "invitation" to their email which brings them back to a sign-up form.
>  The invite URL can contain their email, a timeout, and a digest so nothing
> needs to be saved server side.
>
> --
> Bill Moseley
> mose...@hank.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/
>
>

The invite URL could contain a digest of the mailaddress, in the
signup form the mailaddress is checked against the digest and could be
verified that way.
if the digest is generated with a private key it'll  be difficult to forge 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] User management with Catalyst (with email and URLs)

2010-08-26 Thread David Schmidt
On Thu, Aug 26, 2010 at 12:41 PM,   wrote:
>>> Basically you need to setup a model (a common one would be
>>> DBIx::Class) to store your users.
>>> (http://search.cpan.org/~rkitover/Catalyst-Model-DBIC-Schema-
>>> 0.43/lib/Catalyst/Model/DBIC/Schema.pm)
>
> I am not going to use a database for authentication, so DBIx::Class is not 
> useful for me in this case.
>
>
>>> CatalystX::SimpleLogin
>>> (http://search.cpan.org/~bobtfish/CatalystX-SimpleLogin-0.12/)
>>>
>>> Then you need to set up the Authentication Plugin
>>> (http://search.cpan.org/dist/Catalyst-Plugin-Authentication/)
>
> I was more interested in the email/URL-confirmation process and the above two 
> modules you pointed me at cannot help me with that.
>
>
> Will look at the MojoMojo code to see if I can find an interesting starting 
> point there. Thanks for your answers so far.
>
> Anyone got any more useful pointers for the email/URL-confirmation process?
>
> Cheers,
> Daniel.
>
>
> -Ursprüngliche Nachricht-
> Von: David Schmidt [mailto:davew...@gmx.at]
> Gesendet: Donnerstag, 26. August 2010 11:13
> An: The elegant MVC web framework
> Betreff: Re: [Catalyst] User management with Catalyst (with email and URLs)
>
> On Thu, Aug 26, 2010 at 10:46 AM,   wrote:
>> Dear list members,
>>
>> I guess what I am trying to do is a pretty common task for web developers.
>> So I am very astonished that a couple of hours spent searching the Internet
>> didn’t provide me with a good starting point for my efforts.
>>
>> Here’s what I would like to achieve:
>>
>> A user comes to a web page and enters his email address to join the fun. He
>> gets an email with a confirmation URL that leads him back to the site where
>> he entered his email address to begin with, he then gets a welcome message
>> and is presented a request to enter a password. With his email address and
>> the entered password he can from then on login to the protected area at any
>> time.
>>
>> And of course users do forget their passwords, so an automatic password
>> retrieval feature would come in handy, too.
>>
>> Anybody got any good pointers where to start looking for something I can
>> customize to my needs?
>>
>> I can’t imagine I am the first or only one wanting to achieve something like
>> the above using Catalyst. Right?
>>
>> Any hints appreciated.
>>
>> Thanks,
>>
>> Daniel.
>>
>> ___
>> 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/
>>
>>
>
> Basically you need to setup a model (a common one would be
> DBIx::Class) to store your users.
> (http://search.cpan.org/~rkitover/Catalyst-Model-DBIC-Schema-0.43/lib/Catalyst/Model/DBIC/Schema.pm)
>
> CatalystX::SimpleLogin
> (http://search.cpan.org/~bobtfish/CatalystX-SimpleLogin-0.12/)
>
> Then you need to set up the Authentication Plugin
> (http://search.cpan.org/dist/Catalyst-Plugin-Authentication/)
>
> and thats pretty much 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/
>
> ___
> 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/
>
>

For that approach you need to store

email address
digest used in your URL
password

somewhere, that's what the model is for.

Anyways, what you want can be done with Catalyst.

1) user enters mailaddress and hits submit
2) you generate a digest
3) store digest + mailaddress in model
4) send digest in URL to mailaddress
5) user klicks the link
6) validate digest and request password
7) store pw in db

catalyst makes all this very easy.

___
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 management with Catalyst (with email and URLs)

2010-08-26 Thread David Schmidt
On Thu, Aug 26, 2010 at 10:46 AM,   wrote:
> Dear list members,
>
> I guess what I am trying to do is a pretty common task for web developers.
> So I am very astonished that a couple of hours spent searching the Internet
> didn’t provide me with a good starting point for my efforts.
>
> Here’s what I would like to achieve:
>
> A user comes to a web page and enters his email address to join the fun. He
> gets an email with a confirmation URL that leads him back to the site where
> he entered his email address to begin with, he then gets a welcome message
> and is presented a request to enter a password. With his email address and
> the entered password he can from then on login to the protected area at any
> time.
>
> And of course users do forget their passwords, so an automatic password
> retrieval feature would come in handy, too.
>
> Anybody got any good pointers where to start looking for something I can
> customize to my needs?
>
> I can’t imagine I am the first or only one wanting to achieve something like
> the above using Catalyst. Right?
>
> Any hints appreciated.
>
> Thanks,
>
> Daniel.
>
> ___
> 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/
>
>

Basically you need to setup a model (a common one would be
DBIx::Class) to store your users.
(http://search.cpan.org/~rkitover/Catalyst-Model-DBIC-Schema-0.43/lib/Catalyst/Model/DBIC/Schema.pm)

CatalystX::SimpleLogin
(http://search.cpan.org/~bobtfish/CatalystX-SimpleLogin-0.12/)

Then you need to set up the Authentication Plugin
(http://search.cpan.org/dist/Catalyst-Plugin-Authentication/)

and thats pretty much 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-Plugin-Params-Nested rt 59604

2010-07-27 Thread David Schmidt
On Wed, Jul 28, 2010 at 1:40 AM, Evan Carroll  wrote:
> Is C:P:P:N still maintained? I filed a bug on CPAN, next day I heard a
> request for a patch. I provided a patch, and I haven't heard anything
> back. If any one is maintaining it? Can I get co-maint to apply my
> patch.
>
> Find more information about the issue and the patch set here:
> https://rt.cpan.org/Public/Bug/Display.html?id=59604
>
> --
> Evan Carroll - m...@evancarroll.com
> System Lord of the Internets
> web: http://www.evancarroll.com
> ph: 281.901.0011
>
> ___
> 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/
>

Tomas Doran (the maintainer according to
http://search.cpan.org/dist/Catalyst-Plugin-Params-Nested/lib/Catalyst/Plugin/Params/Nested.pm)
is very active and im convinced he will apply the patch at due time if
it is sane.

He reads the mailinglist aswell. Just give it some more time.

david

___
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] Handling expired sessions gracefully

2010-07-08 Thread David Schmidt
On Fri, Jul 9, 2010 at 4:55 AM, Toby Corkindale
 wrote:
> On 09/07/10 00:53, Steve wrote:
>>
>> I've looked in the archives and tutorials but can't seem to find
>> examples of handling expired sessions gracefully. I'm admittedly weak in
>> the area of error checking, but I'm working on it :) Here are my
>> questions:
>> In what controller (Root.pm or MyApp.pm) and action should I check for
>> an expired session? Should I check $c->user_exists or
>> $c->session_expired (not sure if I have the correct accessor)? Once
>> detected, do I forward, redirect, etc.?
>
> How about something like this?
>
> sub auto :Private { # or the head of your chain
>  my ($self, $c) = @_;
>  if (not $c->user_exists) {
>    $c->stash->{destination} = $c->request->path;
>    $c->detach('/login');
>  }
> }
>
> Then in your login method, redirect them back to {destination} if they
> successfully authenticate; make sure to validate the path though, to avoid
> exploits. (eg. Another site crafting a redirect link like
> http://yoursite.com/login?destination=/confirm_payment/to/evil/hacker)
>
> ___
> 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/
>

Checkout SimpleLogin. It does redirect after login and much more.
http://search.cpan.org/~bobtfish/CatalystX-SimpleLogin-0.12/lib/CatalystX/SimpleLogin.pm

___
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] Dealing with file uploads

2010-07-01 Thread David Schmidt
Hello list,

I updated my wiki cookbook entry today and think the outcome is pretty
neat. While it still can be improved here and there I think it's
partially advanced stuff for a newbie like me. It contains what I
learned about catalyst in the past weeks and I hope it's okay to get a
bit more publicity via the mailing list.

In the article I explain how to make your website deal with file
uploads and delivery in a proper way. I packed most code in reusable
roles that you simply apply to your controller.

But see for yourself...
http://wiki.catalystframework.org/wiki/wikicookbook/controllerwithfileupload

Feedback is very welcome.

david

___
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] Repeatedly creating sessions

2010-06-24 Thread David Schmidt
On Thu, Jun 24, 2010 at 10:14 PM, Nicholas Wehr
 wrote:
> I see - sounds really cool and I fell into using firebug before I really got
> a chance to use it to it's fullest. firebug also allows for javascript
> debugging which was pretty critical for me, since I'm kind of a debugger
> junkie ;)
>
> On Thu, Jun 24, 2010 at 12:56 PM, James Spath 
> wrote:
>>
>> On Thu, Jun 24, 2010 at 3:51 PM, Matthias Dietrich 
>> wrote:
>> > Nicholas,
>> >
>> > Am 24.06.2010 um 18:54 schrieb Nicholas Wehr:
>> >
>> >> I used charles proxy as well until I discovered how awesome the mozilla
>> >> addon firebug is. unbeatable json (xhdr) and network activity analyzer.
>> >> handles ssl too check it out!
>> >>
>> >> jim, is there a charles feature that stands out above firebug? I only
>> >> used for one project until I re-discovered firebug...
>> >
>> > I haven't bought Charles yet but used it for a longer time.  A big plus
>> > is that you can display the content depending on its type (eg. JSON and AMF
>> > as collapsable tree, but doesn't has a display mode for every type, I
>> > guess).  And it's browser independent so you can test with Safari and other
>> > clients (like native apps!), too.  You can record transferred data, stop
>> > recording, open new sessions while the old ones are still present.  If FF
>> > crashes or you navigate to a different page, Charles is still there and
>> > showing the recorded and opened sessions.
>> >
>> > Firebug is nice for single request tracking (yes, you can let the
>> > requests be "sticky", but that's not the same and a bit ugly, even 
>> > sometimes
>> > it doesn't show the content if there's some), CSS, Javascript and HTML, but
>> > if you need to debug more intensive and longer I would prefer something 
>> > like
>> > Charles.
>>
>> What Matthias said :)
>>
>> The biggest features for me are a full history beyond the current page
>> load ... and also the ability to redirect requests to different
>> servers or even to a local file on your machine.
>>
>> Don't get me wrong, I use Firebug all the time, but Charles definitely
>> has its uses.
>>
>> - Jim
>>
>> ___
>> 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/
>
>

With http://getfirebug.com/firebuglite you can debug on other browsers aswell.

david


-- 
David Schmidt   |   http://www.fm5.at

___
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] unrecognized characters

2010-06-13 Thread David Schmidt
On Sat, Jun 12, 2010 at 3:56 PM, Xiao Yafeng  wrote:
> Hi gurus,
>             I'm new to Catalyst. I've found a strange situation when I wrote
> a website in utf-8. The page will change into unrecognized characters when I
> use DBD::Oracle plus WRAPPER directive.
> but if I use single module like DBD::Oracle or WRAPPER, it will retrieve
> correct words.
> Please help! any replies are welcome! I could post the source code if
> needed.
> Besides. I use Catalyst::Plugin::Unicode for encoding, it works fine when I
> just use DBD::Oracle module only.
> ___
> 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/
>
>

Read the pod, the author suggests not to use it anymore

http://search.cpan.org/dist/Catalyst-Plugin-Unicode/lib/Catalyst/Plugin/Unicode.pm


-- 
David Schmidt   |   http://www.fm5.at

___
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::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-13 Thread David Schmidt
On Sun, Jun 13, 2010 at 11:14 AM, Christiaan Kras  wrote:
> Hi list,
>
> I'm currently looking at the available modules for implementing
> Log::Log4perl with my Catalyst app and would like to have some advice on it.
>
> I've found and tried Catalyst::Plugin::Log4perl::Simple but when using the
> module Catalyst warns about it using NEXT. So I'm wondering if it's smart to
> use it in its current state.
>
> When looking on I also found Log::Log4perl::Catalyst and
> Catalyst::Log::Log4perl. Where the former is part of the Log::Log4perl
> distribution. The latter still has some old issues open on which the author
> hasn't responded yet. So to me it seems abandoned. Other than that I don't
> really see much difference between both modules. I must note though that the
> former is very new and is only available since 2010/02/24
>
> From this I'd say using Log::Log4perl::Catalyst is the way to go: it's part
> of the Log::Log4perl distribution and has no open bugs (at least not on the
> Catalyst module).
>
> Thanks.
>
> --
>
> Christiaan Kras
>
> http://blog.htbaa.com
> http://www.brandweeruren.nl
>
>
> ___
> 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/
>

Check whichever Plugin for log4perl Jay Shirley is recommending in
this talk and go with it.

http://www.presentingperl.org/opw2010/zen-maintenance/

greetings
david


-- 
David Schmidt   |   http://www.fm5.at

___
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] A point of confusion/frustration on chained actions

2010-05-20 Thread David Schmidt
Could it be that this module provides what you are looking for?

http://search.cpan.org/~MASAKI/Catalyst-Controller-Resources-0.08/lib/Catalyst/Controller/Resources.pm#NESTED_RESOURCES

david

On Thu, May 20, 2010 at 4:42 AM, J. Shirley  wrote:
> On May 19, 2010, at 4:32 PM, Steve Kleiman wrote:
>
>> I second that. I'm another Catalyst newbie who would like to submit doc 
>> patches for review, but I don't know the process
>>
>>
>> On May 19, 2010, at 4:24 PM, Jeff Albert wrote:
>>
>>> As an unabashed Catalyst n00b, I spent a couple of hours earlier this week 
>>> bashing through this same design conundrum on my own application, and 
>>> although I did ultimately come up with the solution that Ash describes 
>>> under my own steam, the Catalyst::DispatchType::Chained documentation 
>>> didn't do much to help me with the process at all - nor did the Catalyst 
>>> tutorial.
>>>
>>> I've never contributed, so I don't know the process, but it would be nice 
>>> to see this information in the documentation. If somebody who knows what's 
>>> necessary mails me off-list with the information on how to get started, I 
>>> would be willing hack up Ash's reply into a fairly minimal doc patch in 
>>> whichever location is appropriate.
>>>
>>> Cheers,
>>> Jeff
>>>
>>>
>
>
> There is a wiki node on it: http://wiki.catalystframework.org/wiki/contrib
>
> If you just connect to irc.perl.org, join #catalyst and then say, "I want to 
> contribute a doc patch to [something]" you shouldn't have a problem finding 
> an eager mentor to also help guide you through the process.
>
> You can also easily contribute to the Catalyst wiki 
> (http://wiki.catalystframework.org/wiki/), which has a very low barrier to 
> entry and you can ask for people to proofread what you have written by simply 
> posting to the mailing list here.
>
> Thanks,
> -Jay
> ___
> 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/
>



-- 
David Schmidt   |   http://www.fm5.at

___
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] REST Controller + ajax(jquery) with file upload

2010-05-18 Thread David Schmidt
Hello everybody,

I am experimenting with Catalyst::Controller::REST and jquery. The
goal is to create a Controller that handles media resources (= upload
a file + text input).

Catalyst::Controller::Resources pretty much does what I want.

Problem: Since I cannot seem to upload a file with a XMLHttpRequest my
Controller needs to handle two kinds of requests
1) typical AJAX requests where only a part of the site is changed.
thus no full document is sent "..." but only
html fragments or JSON encoded data.
2) entire documents to respond to multipart/form-data POST/PUT requests



Here is a list of actions/paths I want to work with:

GET /media
get a list of all resources (respond with json data)

GET /media/$id
get a resource (respond with json data)

DELETE /media/$id
delete a resource (respond with a status msg, e.g. http status code)

GET /media/new
send form for creating a new resource (...)

POST /media
submit a form, unlike the other requests so far this one expects a
complete document in return. the entire page is reloaded.

GET /media/$id/edit
send form for editing a resource (...)

PUT /media/$id
submit the edit form, unlike. this one expects a complete document in
return like the POST request before



So how do I handle the two kinds of output?
One time I want to respond with html documents generated by my
C::V::TT View (POST, PUT requests) and for ajax requests I'd like to
use the serialization mechanism of C::C::REST.
I accomplished this by setting

MyApp/Controller/Media.pm:
__PACKAGE__->config(
map => {
'text/html' => [ 'View', 'MyView' ], # lib/MyApp/View/MyView.pm
}
);

Otherwise catalyst returns a 415 "Content-Type text/html is not supported" msg.
Now form POST/PUT requests are answered with completely new html pages
while ajax requests with jquery dataType "json" will get the
application/json response provided by C::C::REST


I am asking myself if my approach is practicable.
Any input welcome.

david

ps: I want my websites to be able to work with and without js. How can
I achieve this without increasing the complexity of my code too much.
(I vaguely remember this was really easy in RoR)

___
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] HTML editor plugin

2010-02-03 Thread David Schmidt
On Wed, Feb 3, 2010 at 2:32 PM, Denny <2...@denny.me> wrote:
> On Wed, 2010-02-03 at 07:02 -0600, Paul Falbe wrote:
>> I'm looking to create a little app to edit/create HTML strings to
>> store in a mysql table.  These strings are going to be displayed on
>> a web page for annoucements for a youth baseball league.  Before I
>> went about creating one I thought I'd ask if there is a plugin/example
>> out there I should use as a starting point.  Basically, I need a
>> Catalyst html editor plugin if such a thing exists.
>
> Not Catalyst specific, but I've used ckeditor* in the past - it's a
> drop-in replacement for  with a load of configuration options.
>
> Bear in mind the obvious security risks of letting people input HTML and
> then injecting it directly into your site - at a bare minimum you want
> to strip out javascript stuff, including onclick etc.

I use TinyMCE and HTMLScrubber to define the allowed html tags.
http://search.cpan.org/~cfranks/HTML-FormFu-0.06001/lib/HTML/FormFu/Filter/HTMLScrubber.pm

- type: Textarea
  name: 'description'
  filters:
- type: HTMLScrubber
  allow: [ 'a', 'p', 'br', 'strong', 'em', 'h1', 'h2', 'h3',
'img', 'ul', 'ol', 'li' ]

___
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] Enabling debug mode with fastcgi..

2010-01-18 Thread David Schmidt
I am pretty sure debug output went to apache's error log when I last checked.

On Mon, Jan 18, 2010 at 8:54 PM, Adam Mackler  wrote:
> Hi Toby:
>
> The output might be going to your web server log.  Try starting your
> fastcgi script with a -e option (with CATALYST_DEBUG set as well).
>
> Adam
>
> On Mon, Jan 18, 2010 at 05:03:23PM +1100, Toby Corkindale wrote:
>> Hi guys,
>> If you're running a Catalyst app with the fastcgi script (as found in
>> scripts/myapp_name_fastcgi.pl), then is there a way to enable the debug
>> mode. (eg. like running scripts/myapp_server.pl -d)
>>
>> I've tried setting CATALYST_DEBUG and MYAPP_DEBUG in the shell
>> environment, but that doesn't seem to work. Either that or else fastcgi
>> is discarding the output somewhere in our case. (I've messed with the
>> -keeperr option too)
>>
>> Cheers,
>> Toby
>>
>> ___
>> 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/
>



-- 
David Schmidt   |   http://www.fm5.at

___
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] Login as another user ...

2010-01-18 Thread David Schmidt
On Mon, Jan 18, 2010 at 11:34 AM, Kiffin Gish  wrote:
> As system administrator who has root access to everything, I want to be
> able to login as another user from my dashboard page.
>
> What's the best way to achieve this? I tried $c->authenticate without a
> password, but this doesn't seem to work.


The following thread might help you.

http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg08648.html

david

___
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] C::P::Authentication, force user authentication

2009-12-29 Thread David Schmidt
On Tue, Dec 29, 2009 at 9:15 AM, Ben van Staveren
 wrote:
>> On 28 Dec 2009, at 09:16, Ben van Staveren wrote:
>>>
>>> Warning: I use this myself, it seems to work, but it's a hack. YMMV.
>>> Standard disclaimer applies.
>>
>> I.e. It is very much relying on an implementation detail which I/we can
>> and _will_ feel free to change at our leisure if needed.
>
> Correct :) Like I said it's something I use in one spot, and I'm fully aware
> of the fact that it will break sooner or later, but for now it was the
> "quick" way to get the result I wanted.
>
>
>
> ___
> 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/
>


But if I had to choose between your hack and using

$c->set_authenticated( $user, $realmname )
(given that it works, never tested it)

Id go with the latter for at least its documented.


-- 
David Schmidt   |   http://www.fm5.at

___
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] C::P::Authentication, force user authentication

2009-12-28 Thread David Schmidt
On Mon, Dec 28, 2009 at 4:53 PM, J. Shirley  wrote:
> On Mon, Dec 28, 2009 at 7:13 AM, Tomas Doran  wrote:
>>
>> On 28 Dec 2009, at 09:16, Ben van Staveren wrote:
>>>
>>> Warning: I use this myself, it seems to work, but it's a hack. YMMV.
>>> Standard disclaimer applies.
>>
>> I.e. It is very much relying on an implementation detail which I/we can and
>> _will_ feel free to change at our leisure if needed.
>>
>> The solution Rafal suggested in the next reply is a much better idea,
>> however it's not as easy as it could/should be right now - someone should
>> write a Realm class specifically for making doing this easier (as it's a
>> common use-case).
>>
>> If anyone wants to volunteer I'd be happy to work with them on it :)
>>
>
>
> When I wrote the progressive realm, I also wrote this up:
> http://www.coldhardcode.com/2009/01/building-the-best-forgot-passw.html
>
> (And also an advent that makes use of OpenID:
> http://www.catalystframework.org/calendar/2008/19)
>
> Provides quite a few boiler plate examples.
>
> -J

Hello and thanks for all the input,

I solved my problem with a different approach.

If the user lost his password he can submit the emailaddress along
with a new password.
I then send a digest to the email address (only if this address is in
DB already)
The digest is stored in the DB along with the new password
If the digest is entered on the website I set the new password

I use the same approach for:
- initial mail confirmation
- password change
- email change

david

___
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] C::P::Authentication, force user authentication

2009-12-28 Thread David Schmidt
Hello

When a user lost his password I send a digest by email.
If he enters this digest I want to automatically authenticate the user
so he can edit his password.

I only found this method but it says in the docs you shouldn't use it
in your code as it is an internal function only.
$c->set_authenticated( $user, $realmname )

Any other way to force user authentication?

thanks

david

___
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: Deploying with apache/fastcgi

2009-12-19 Thread David Schmidt
On Sat, Dec 19, 2009 at 11:38 AM, David Schmidt  wrote:
> Hello list
>
> I followed the deployment instructions in the cat book to run my app
> on apache2 with fastcgi. I do get a 500 internal error msg and the
> appache error log says:
>
> [Sat Dec 19 10:25:47 2009] [error] [client 78.142.165.159] FastCGI:
> incomplete headers (0 bytes) received from server
> "/var/www/MyApp/script/myapp_fastcgi.pl"
>
> I copied the apache config from another cat app (I cant get ahold of
> the other developer but will report back here once I talked to him)
> that is running smoothly already and checked against the cat book.
>
> I installed apache2/fastcgi through the debian package system with
> aptitude install apache2 libapache2-mod-fastcgi
>
> Here is my apache2 config:
> 
>    ServerName myapp.at
>    ServerAdmin da...@myapp.at
>
>    DocumentRoot /var/www/MyApp/root/
>    
>        Options Indexes FollowSymLinks MultiViews
>        AllowOverride None
>        Order allow,deny
>        allow from all
>    
>
>   Alias /static /var/www/MyApp/root/static
>
>   FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
>   Alias / /var/www/MyApp/script/myapp_fastcgi.pl/
>
>    ErrorLog /var/log/apache2/myapp.at.error.log
>
>    # Possible values include: debug, info, notice, warn, error, crit,
>    # alert, emerg.
>    LogLevel warn
>
>    CustomLog /var/log/apache2/myapp.at.access.log combined
> 
>
>
> Any help is appreciated
>
> david
>

t0m helped me out once again:

t0m: what happens when you say sudo -u www-data
/var/www/MyApp/script/myapp_fastcgi.pl

turns out FCGI.pm wasnt installed

thanks alot

david

___
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] Deploying with apache/fastcgi

2009-12-19 Thread David Schmidt
Hello list

I followed the deployment instructions in the cat book to run my app
on apache2 with fastcgi. I do get a 500 internal error msg and the
appache error log says:

[Sat Dec 19 10:25:47 2009] [error] [client 78.142.165.159] FastCGI:
incomplete headers (0 bytes) received from server
"/var/www/MyApp/script/myapp_fastcgi.pl"

I copied the apache config from another cat app (I cant get ahold of
the other developer but will report back here once I talked to him)
that is running smoothly already and checked against the cat book.

I installed apache2/fastcgi through the debian package system with
aptitude install apache2 libapache2-mod-fastcgi

Here is my apache2 config:

ServerName myapp.at
ServerAdmin da...@myapp.at

DocumentRoot /var/www/MyApp/root/

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


   Alias /static /var/www/MyApp/root/static

   FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
   Alias / /var/www/MyApp/script/myapp_fastcgi.pl/

ErrorLog /var/log/apache2/myapp.at.error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/myapp.at.access.log combined



Any help is appreciated

david

___
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] does detach cancel forward

2009-11-07 Thread David Schmidt
>From the new Catalyst Book:

"$c->forward returns to the calling action and ompletes the request,
while $c->detach proceeds to the end action after the called actions
are completed."


On Wed, Nov 4, 2009 at 11:19 PM, Ovid  wrote:
> - Original Message 
>
>> From: Steve Rippl 
>>
>> I'm building "chains" of methods using forward and detach mostly, I
>> quote the chains because I know it's not the regular chained methods but
>> my "chains" vary according to where you are etc.  Anyway, the question I
>> have is whether forward is still valid after a detach... let me
>> illustrate...
>>
>> If A forwards to B, once B is done it comes back to A, that I use and it
>> works.  If C detaches to D to doesn't come back after D, again I use
>> that.
>>
>> Now, If from A I forward to B, then B detaches to C which detaches to D,
>> it doesn't seem to come back to A after D.  Is this my mistake
>> somewhere, is it by design?  Does the detach after a forward "cancel"
>> the forward?
>
> Think of detach as "game over", if that helps (probably doesn't).  From the 
> docs, detach() is described as:
>
>    The same as forward, but doesn't return to the previous action when 
> processing is finished.
>
> I think that description might be a bit confusing for some, as your question 
> suggests.
>
> Cheers,
> Ovid
> --
> Buy the book         - http://www.oreilly.com/catalog/perlhks/
> Tech blog            - http://use.perl.org/~Ovid/journal/
> Twitter              - http://twitter.com/OvidPerl
> Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
>
>
>
> _______
> 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/
>



-- 
David Schmidt   |   http://www.fm5.at

___
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::View::Email config error after Catalyst upgrade

2009-03-29 Thread David Schmidt
On Sun, Mar 29, 2009 at 3:00 PM, Jason Galea  wrote:
> Hi David,
>
> setting default_view in my config appears to have fixed this for me.. (I
> have other, unrelated, issues now)
>
> default_view: MyApp::View::TT
>
> hope this helps..
>
> cheers,
>
> J
>
> David Schmidt wrote:
>>
>> Hello everyone
>>
>> I've just upgraded Catalyst from 5.7015 to 5.71001.
>> If I start my project development server it loads but upon requesting
>> any page I get the error:
>>
>> Caught exception in MyApp::View::myEmail->process "Can't send email
>> without a valid email structure at
>> /usr/local/share/perl/5.10.0/Catalyst/Action.pm line 46"
>>
>> On the cpan site of C::V::Email the developer says that the config
>> options have changed slightly but I cannot figure out wether the docs
>> represent the new or old config style.
>>
>>
>> http://search.cpan.org/~jshirley/Catalyst-View-Email-0.13/lib/Catalyst/View/Email.pm
>>
>> WARNING: since version 0.10 the configuration options slightly changed!
>>
>> This is were the error comes from in /Catalyst/View/Email.pm
>>
>>    my $email  = $c->stash->{$self->{stash_key}};
>>    croak "Can't send email without a valid email structure"
>>        unless $email;
>>
>> but I have the stash_key configured in MyApp/lib/MyApp.pm
>> __PACKAGE__->config(
>>    'View::Email' => {
>>        stash_key => 'email',
>>        default => {
>>            content_type => 'text/plain',
>>            charset => 'utf-8'
>>        },
>>        sender => {
>>            mailer => 'SMTP',
>>            mailer_args => {
>>                Host     => 'test.smtp.at', # defaults to localhost
>>                username => 'blah',
>>                password => 'foo',
>>                ssl      => 1
>>            }
>>        }
>>    }
>> };
>>
>> and it also seems to be configured in MyApp/lib/MyApp/View/myEmail.pm
>> __PACKAGE__->config(
>>    stash_key => 'email'
>> );
>>
>> well, that's it for now. thanks in advance for any pointers.
>>
>> david
>>
>> ___
>> 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/
>

Ye it did so for me too.
These lines are still here though

Use of uninitialized value $text in split at
/usr/local/share/perl/5.10.0/Text/SimpleTable.pm line 239.

I really hoped the upgrade from Catalyst 5.70 to 5.71 wouldnt break my app.

Thanks for your reply :)

___
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: Catalyst::View::Email config error after Catalyst upgrade

2009-03-29 Thread David Schmidt
On Sat, Mar 28, 2009 at 12:59 PM, David Schmidt  wrote:
> Hello everyone
>
> I've just upgraded Catalyst from 5.7015 to 5.71001.
> If I start my project development server it loads but upon requesting
> any page I get the error:
>
> Caught exception in MyApp::View::myEmail->process "Can't send email
> without a valid email structure at
> /usr/local/share/perl/5.10.0/Catalyst/Action.pm line 46"
>
> On the cpan site of C::V::Email the developer says that the config
> options have changed slightly but I cannot figure out wether the docs
> represent the new or old config style.
>
> http://search.cpan.org/~jshirley/Catalyst-View-Email-0.13/lib/Catalyst/View/Email.pm
>
> WARNING: since version 0.10 the configuration options slightly changed!
>
> This is were the error comes from in /Catalyst/View/Email.pm
>
>    my $email  = $c->stash->{$self->{stash_key}};
>    croak "Can't send email without a valid email structure"
>        unless $email;
>
> but I have the stash_key configured in MyApp/lib/MyApp.pm
> __PACKAGE__->config(
>    'View::Email' => {
>        stash_key => 'email',
>        default => {
>            content_type => 'text/plain',
>            charset => 'utf-8'
>        },
>        sender => {
>            mailer => 'SMTP',
>            mailer_args => {
>                Host     => 'test.smtp.at', # defaults to localhost
>                username => 'blah',
>                password => 'foo',
>                ssl      => 1
>            }
>        }
>    }
> };
>
> and it also seems to be configured in MyApp/lib/MyApp/View/myEmail.pm
> __PACKAGE__->config(
>    stash_key => 'email'
> );
>
> well, that's it for now. thanks in advance for any pointers.
>
> david
>

This doesn't seem to be related to C:V:Email but rather to some config
not getting loaded.

When I start my app the first lines are

da...@foo:~/catalyst/MyApp$ DBIC_TRACE=1 ./script/myapp_server.pl -d -r
Subroutine initialize redefined at /usr/share/perl5/Class/C3.pm line 70.
Subroutine uninitialize redefined at /usr/share/perl5/Class/C3.pm line 88.
Subroutine reinitialize redefined at /usr/share/perl5/Class/C3.pm line 101.
Use of uninitialized value $text in split at
/usr/local/share/perl/5.10.0/Text/SimpleTable.pm line 239.
Use of uninitialized value $text in split at
/usr/local/share/perl/5.10.0/Text/SimpleTable.pm line 239.
Use of uninitialized value $text in split at
/usr/local/share/perl/5.10.0/Text/SimpleTable.pm line 239.
(...)
Use of uninitialized value $text in split at
/usr/local/share/perl/5.10.0/Text/SimpleTable.pm line 239.
Use of uninitialized value $text in split at
/usr/local/share/perl/5.10.0/Text/SimpleTable.pm line 239.
[debug] Debug messages enabled
[debug] Statistics enabled
[debug] Loaded plugins:
(...)

Caught exception in MyApp::Controller::Root->end
"Catalyst::Action::RenderView could not find a view to forward to."

I set default_view => 'myView' in lib/MyApp.pm after I have seen this
error but to no avail.


david

___
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::View::Email config error after Catalyst upgrade

2009-03-28 Thread David Schmidt
Hello everyone

I've just upgraded Catalyst from 5.7015 to 5.71001.
If I start my project development server it loads but upon requesting
any page I get the error:

Caught exception in MyApp::View::myEmail->process "Can't send email
without a valid email structure at
/usr/local/share/perl/5.10.0/Catalyst/Action.pm line 46"

On the cpan site of C::V::Email the developer says that the config
options have changed slightly but I cannot figure out wether the docs
represent the new or old config style.

http://search.cpan.org/~jshirley/Catalyst-View-Email-0.13/lib/Catalyst/View/Email.pm

WARNING: since version 0.10 the configuration options slightly changed!

This is were the error comes from in /Catalyst/View/Email.pm

my $email  = $c->stash->{$self->{stash_key}};
croak "Can't send email without a valid email structure"
unless $email;

but I have the stash_key configured in MyApp/lib/MyApp.pm
__PACKAGE__->config(
'View::Email' => {
stash_key => 'email',
default => {
content_type => 'text/plain',
charset => 'utf-8'
},
sender => {
mailer => 'SMTP',
mailer_args => {
Host => 'test.smtp.at', # defaults to localhost
username => 'blah',
password => 'foo',
ssl  => 1
}
}
}
};

and it also seems to be configured in MyApp/lib/MyApp/View/myEmail.pm
__PACKAGE__->config(
stash_key => 'email'
);

well, that's it for now. thanks in advance for any pointers.

david

___
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::Controller::DBIC::Transaction Integration

2009-03-16 Thread David Schmidt
Hello Carl and thanks

I already attempted to solve the problem with changing the order of
the parent classes. I still get the same error

Can't call method "submitted_and_valid" on an undefined value at
/home/david/temp/catalyst/nolabel2/Nolabel2/script/../lib/Nolabel2/Controller/Accounts.pm
line 41.
 at /usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954
DBIx::Class::Schema::throw_exception('Nolabel2::Schema=HASH(0x930f764)',
'Can\'t call method "submitted_and_valid" on an undefined valu...')
called at /usr/local/share/perl/5.8.8/DBIx/Class/Storage.pm line 122

DBIx::Class::Storage::throw_exception('DBIx::Class::Storage::DBI::SQLite=HASH(0x93e3208)',
'Can\'t call method "submitted_and_valid" on an undefined valu...')
called at /usr/local/share/perl/5.8.8/DBIx/Class/Storage/DBI.pm line
667

DBIx::Class::Storage::DBI::txn_do('DBIx::Class::Storage::DBI::SQLite=HASH(0x93e3208)',
'CODE(0x9ee39a8)') called at
/usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 734
DBIx::Class::Schema::txn_do('Nolabel2::Schema=HASH(0x930f764)',
'CODE(0x9ee39a8)') called at
/usr/local/share/perl/5.8.8/Catalyst/Action/DBIC/Transaction.pm line
27

Catalyst::Action::DBIC::Transaction::execute('Catalyst::Action::DBIC::Transaction=HASH(0x9d78d08)',
'Nolabel2::Controller::Accounts=HASH(0x9ce8e34)',
'Nolabel2=HASH(0x9dc3794)') called at
/usr/local/share/perl/5.8.8/Catalyst/Action.pm line 32

Catalyst::Action::__ANON__('Nolabel2::Controller::Accounts=HASH(0x9ce8e34)',
'Nolabel2=HASH(0x9dc3794)') called at
/usr/local/share/perl/5.8.8/Catalyst.pm line 1220

... and so on.

ps: I read and implemented your approach to formfu validation through
a custom validator rather then a callback yesterday, thanks for that.
:)

On Mon, Mar 16, 2009 at 11:45 AM, Carl Franks  wrote:
> 2009/3/16 David Schmidt :
>> Hello list,
>>
>> I need to put all DBIC Operations in an action into a transaction and
>> thought the use of
>>
>> http://search.cpan.org/~druoso/Catalyst-Controller-DBIC-Transaction-0.3/lib/Catalyst/Controller/DBIC/Transaction.pm
>>
>> would be a good idea, but ever since I added  C::C::DBIC::Controller
>> with "use parent" FormFu doesnt work anymore.
>>
>>  use parent qw/
>>            Catalyst::Controller::DBIC::Transaction
>>            Catalyst::Controller::HTML::FormFu
>>            /;
>>
>> sub create :Path('create') :Args(0) :FormConfig('accounts/create.yml')
>> :DBICTransaction('myDB') {
>>    my ( $self, $c ) = @_;
>>    my $form = $c->stash->{form};
>>    if ($form->submitted_and_valid) {
>>    ...
>> }
>>
>> The error message basically says:
>>
>> Can't call method "submitted_and_valid" on an undefined value at
>> /home/david/temp/catalyst/nolabel2/Nolabel2/script/../lib/Nolabel2/Controller/Accounts.pm
>> line 41.
>>  at /usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954
>
> I think now that Catalyst::Controller::HTML::FormFu isn't first in the
> inheritance list, its create_action() isn't being called.
>
> If you change it to the following, you should find it works again:
>
>  use parent qw/
>           Catalyst::Controller::HTML::FormFu
>           Catalyst::Controller::DBIC::Transaction
>           /;
>
> If any Cat dev could point me to a Cat controller that does the action
> registering correctly, so I can fix C-C-HTML-FormFu, I'd very much
> appreciate it.
>
> Carl
>
> ___
> 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/
>



-- 
David Schmidt   |   http://www.fm5.at

___
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::Controller::DBIC::Transaction Integration

2009-03-16 Thread David Schmidt
Hello list,

I need to put all DBIC Operations in an action into a transaction and
thought the use of

http://search.cpan.org/~druoso/Catalyst-Controller-DBIC-Transaction-0.3/lib/Catalyst/Controller/DBIC/Transaction.pm

would be a good idea, but ever since I added  C::C::DBIC::Controller
with "use parent" FormFu doesnt work anymore.

 use parent qw/
Catalyst::Controller::DBIC::Transaction
Catalyst::Controller::HTML::FormFu
/;

sub create :Path('create') :Args(0) :FormConfig('accounts/create.yml')
:DBICTransaction('myDB') {
my ( $self, $c ) = @_;
my $form = $c->stash->{form};
if ($form->submitted_and_valid) {
...
}

The error message basically says:

Can't call method "submitted_and_valid" on an undefined value at
/home/david/temp/catalyst/nolabel2/Nolabel2/script/../lib/Nolabel2/Controller/Accounts.pm
line 41.
 at /usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954

Any help is greatly appreciated

david


-- 
David Schmidt   |   http://www.fm5.at

___
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] command in Catalyst tute part 4 for generating schema files (static creation) using DBIx::Class::TimeStamp needs to be updated

2009-03-15 Thread David Schmidt
I ran into the sae problem today.

check if you have at least version 0.23 with the following command

perl -MCatalyst::Model::DBIC::Schema -e \
'print "$Catalyst::Model::DBIC::Schema::VERSION\n"'

if not follow these instructions
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7018/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod#Convert_to_DBIC_%22load_namespaces%22

On Tue, Mar 10, 2009 at 12:32 PM,   wrote:
> Actually scrap that.
> I am noticing that no 'Schema' subdirectory has been created hence no
> model files were even made.
>
>  I switched the command back to what's in the tute. Here is how it looks
> like:
>
>
> kakim...@moomba-water-fest:~/projects/myApp/script$ ./myApp_create.pl
> model myAppDB DBIC::Schema myApp::Schema create=static
> components=TimeStamp
> dbi:Pg:dbname=myApp:Username=test_user:Password=password11
>  exists "/home/kakimoto/projects/myApp/script/../lib/myApp/Model"
>  exists "/home/kakimoto/projects/myApp/script/../t"
>  DBIx::Class::Schema::Loader::make_schema_at(): DBI Connection failed:
> Can't connect to data source 'components=TimeStamp' because I can't work
> out what driver to use (it doesn't seem to contain a 'dbi:driver:'
> prefix and the DBI_DRIVER env var is not set) at
> /usr/local/share/perl/5.8.8/DBIx/Class/Storage/DBI.pm line 839
>
>
>
> Guys, any ideas?
>
>
>
> Thanks
>
>
>
>
>
> Quoting kakim...@tpg.com.au:
>
>> hi everyone,
>>
>>  I just followed the tute in
>>
> http://search.cpan.org/~hkclark/Catalyst-Manual-5.7018/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
>> to regenerate my schema (model) files to use DBIx::Class::TimeStamp.
>>
>> I refered to the section "Update DBIC to Automatically Handle the
>> Datetime Columns".
>>
>> I ran my command following this order,
>> "script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \
>>         create=static components=TimeStamp dbi:SQLite:myapp.db"
>>
>> and it fails. I have the latest version of catalyst and all related
>> DBIX
>> modules installed in my machine.
>>
>>
>>
>> Running the command above with 'components=TimeStamp' before
>> 'create=static'  worked fine
>> ( ie.
>>
>> "script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \
>>       components=TimeStamp  create=static  dbi:SQLite:myapp.db "
>> ).
>>
>>
>>
>> I would suggest for the command in the tutorial to be updated.
>>
>>
>> thanks
>>
>> K. akimoto
>>
>> ___
>> 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/
>



-- 
David Schmidt   |   http://www.fm5.at

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


Re: [Catalyst] Re: OT: Better TT pager?

2009-01-22 Thread David Schmidt
On Thu, Dec 25, 2008 at 12:18 AM, Aristotle Pagaltzis  wrote:
> * Jesse Sheidlower  [2008-12-23 12:45]:
>> Does someone have a model I can steal from?
>
> I have something pretty close to that. Not entirely happy insofar
> as that I want to add the ability show a few links to skip 10 and
> 20 pages as appropriate, and it's not abstracted as it should be,
> but as a starting point it should work.
>
>USE decimal = format('%d') ;
>BLOCK pagination ;
>  IF NOT page ; page = 0 ; END ;
>  last_page = decimal( ( num_trials - 1 ) / per_page );
>
>  IF last_page ;
>%][%
>%] NOT page %]>1[%
>
>linked_page = page - 4 ;
>IF linked_page < 1 ; linked_page = 1 ; END ;
>
>until_page = linked_page + 7 ;
>IF last_page <= until_page ;
>  until_page = last_page - 1 ;
>  linked_page = until_page - 7 ;
>  IF linked_page < 1 ; linked_page = 1 ; END ;
>END ;
>
>'…' IF 1 < linked_page ;
>
>WHILE ( linked_page <= until_page ) AND ( linked_page < last_page ) ;
>  %] class="current"' IF page == linked_page %]>[% linked_page + 1 %][%
>  linked_page = linked_page + 1 ;
>END ;
>
>'…' IF linked_page < last_page ;
>%] class="current"' IF page == last_page %]>[% last_page + 1 %][%
>
>%][%
>  END ;
>END ;
>
> This is also a perfect demonstration of why I say that TT sucks.
> This should by all rights be handled in the template since it's
> display logic, but writing it in that TT mini-language rather
> than Perl is fugly. And PERL and RAWPERL blocks have their own
> problems. Anyway. Someday I'll quit yapping and write some code.
>
> The CSS for styling that looks like this:
>
>div.pagination {
>margin: 1.1em 0 0.5em;
>text-align: right;
>padding: 0.2em 0;
>}
>
>div.pagination i {
>font-style: normal;
>}
>
>div.pagination a:link,
>div.pagination a:visited {
>border: 1px solid #359;
>background-color: #f0f0e6;
>padding: 0.1em 0.3em;
>margin: 0 0.2em;
>}
>
>div.pagination a.current,
>div.pagination a:focus,
>div.pagination a:hover,
>div.pagination a:active {
>background-color: #47b;
>color: #fff;
>}
>
> I'm not sure how selfcontained that is, but I can't be bothered
> to dig through the rest of my stylesheets right now.
>
> Regards,
> --
> Aristotle Pagaltzis // <http://plasmasturm.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/
>

I adapted one of the proposals and felt I should share it with you.

in my Controller:
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
my $page = $c->req->param('page') || 1;
my $rows  = $c->req->param('rows') || 3;
my $where = { };
my $attr = { page => $page, rows => $rows, order_by => "created desc" };
my $rs = $c->model('DB::Pictures')->search( $where, $attr );
my $pager = $rs->pager();
$c->stash->{pager} = $pager;
$c->stash->{pictures} = [$rs->all];
$c->stash->{template} = 'pictures/list.tt2';
}


in my template.tt2:

[% IF pager.current_page() != pager.first_page() -%]
<<
[% END -%]

[% IF pager.previous_page -%]
 <
[% END -%]

[% IF pager.next_page -%]
 >
[% END -%]

[% IF pager.current_page != pager.last_page() -%]

>>
[% END -%]


[% IF pager.total_entries() > 0 -%]
[% pager.total_entries() -%] pictures found |
Showing page [% pager.current_page() -%] of [% pager.last_page() -%]
[% END -%]


Works fine so far.

david

-- 
David Schmidt   |   http://www.fm5.at

___
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] many_to_many relationship always deletes then inserts

2009-01-02 Thread David Schmidt
Hello list

I have a M:N relationship where each project can have many pictures
and vice-versa.

(projects) ---* (picture_projects) *--- (pictures)

If I edit a project I present the user a list of all pictures with
previously selected ones beeing pre-selected.

In the formfu config file I add all entries (pictures is the
many_to_many relationship of the Project DBIx Schema)
__PACKAGE__->many_to_many( pictures => 'picture_projects', 'picture_id');


projects/create.yml
---
model_config:
  model: 'DB::Projects'

- type: Select
  name: pictures
  label: Pictures
---

When I edit a Project and save it all entries in picture_projects with
project_id of the edited project are deleted and then reinserted.
But what I want is to only delete them if i actually removed them in
the editing process.

DELETE FROM picture_projects WHERE ( project_id = ? ): '3'
INSERT INTO picture_projects (picture_id, project_id) VALUES (?, ?): '2', '3'
INSERT INTO picture_projects (picture_id, project_id) VALUES (?, ?): '3', '3'

I would be very pleased about getting help here since I just redid the
entire application and ran into the same problem again.

thanks in advance

david



-- 
David Schmidt   |   http://www.fm5.at

___
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] Beginner Question: Controller Layout

2008-12-09 Thread David Schmidt
Hello list,

I am at the point of starting a new project and have yet to choose a
controller layout.

my application is a site where:

music bands can
-   register
-   fill out (and later edit) a profile
-   upload pictures and songs
-   schedule events which will be displayed on a calendar

visitors can
-   browse all of the above information
-   register to a newsletter

admins can
-   edit all of the above stuff

Well, I suppose you get the picture. I am hoping to get some guidance
here from someone who has experience

One solution that comes to my mind would be to make a controlller for
each role (admin, band, visitor)
another one would be to make a controller for each type of media
(songs, pictures, band, ...)

Either way I am not able to tell which one is most suitable beforehand.

thanks in advance

david

___
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] edit has_many relation with FormFu

2008-10-27 Thread David Schmidt
Another mail I got from outside of the Mailinglist strengthened my
theory (composed primary keys are bad for nested_name/Repeatable
Types)

Upon adding a atomic primary key to the picture_projects table I now
receive the following error when trying to edit a project

> CREATE TABLE picture_projects (
> id  INTEGER PRIMARY KEY,
> picture_id  INTEGER,
> project_id  INTEGER,
> positionINTEGER,
> UNIQUE (project_id, picture_id),
> FOREIGN KEY (project_id) references projects(id),
> FOREIGN KEY (picture_id) references pictures(id)
> );

http://131.130.239.28:3000/projects/formfu_edit/1

DBI Exception: DBD::SQLite::db prepare_cached failed: ambiguous column
name: id(1) at dbdimp.c line 271 [for Statement "SELECT id FROM
picture_projects me  JOIN pictures picture ON ( picture.id =
me.picture_id ) WHERE ( me.id = ? )"] at
/usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954

I could simply avoid this error by not naming the primary key in table
picture_projects "id" (ambiguous with primary key "id" in table
projects) but I sense either a bug in Catalyst/FormFu interaction or
rather likely some misconfiguration on my behalf.

Is there a way to make catalyst call:

"SELECT me.id FROM picture_projects me  JOIN pictures picture ON (
picture.id = me.picture_id ) WHERE ( me.id = ? )"
rather then
"SELECT id FROM picture_projects me  JOIN pictures picture ON (
picture.id = me.picture_id ) WHERE ( me.id = ? )"

?

david

On Mon, Oct 27, 2008 at 10:23 AM, David Schmidt <[EMAIL PROTECTED]> wrote:
> Hello and thanks for your reply.
> I tried adding model_config before but it didn't change anything.
> Here is a full formfu_create.yml listing:
>
>> indicator: submit
>> elements:
>> - type: Text
>>   name: title
>>   label: Title
>>
>> - type: Textarea
>>   name: description
>>   label: Description
>>
>> - type: Select
>>   name: pictures
>>   label: Pictures
>>   multiple: 1
>>   size: 10
>>
>> - type: Select
>>   name: active
>>   label: Status
>>   options:
>> - [ '0', 'inactive' ]
>> - [ '1', 'active' ]
>>
>> - type: Repeatable
>>   nested_name: picture_projects
>>   model_config:
>> model: 'myDB::PictureProjects'
>>   elements:
>> - type: Hidden
>>   name: project_id
>> - type: Hidden
>>   name: picture_id
>> - type: Text
>>   label: Position
>>   name: position
>>
>> - type: Submit
>>   name: submit
>>   value: Submit
>>
>> constraints:
>> - Required
>
> The only thing different with your example I can see is that you
> apparently have a primary key consisting of one column while I have a
> composed primary key of the two foreign keys of the m:n relation.
>
> friendly greetings
> david
>
> On Sun, Oct 26, 2008 at 10:59 PM, Chris <[EMAIL PROTECTED]> wrote:
>> Hi David,
>>
>>> I want to edit a m:n relation between projects and pictures (a project
>>> may have many pictures). It is displayed correctly but upon submit the
>>> following error message occurs:
>>> NOTE: 7 is the project ID which seems to be interpreted as a column name
>>>
>>> DBI Exception: DBD::SQLite::db prepare_cached failed: near ".7":
>>> syntax error(1) at dbdimp.c line 271 [for Statement "SELECT
>>> me.picture_id, me.project_id, me.position FROM picture_projects me
>>> WHERE ( ( ( me.7 IS NULL ) AND ( me.project_id = ? ) ) )"] at
>>> /usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954
>>>
>>> in this line in Controller/Projects.pm:
>>>>if ($form->submitted_and_valid) {
>>>>$form->model->update($project);
>>>
>>>
>>> Any help is highly appreciated as I am stuck with this problem since a
>>> few days already.
>>>
>>> in lib/MyApp/Schema/Projects.pm:
>>>> __PACKAGE__->has_many(picture_projects => 
>>>> 'Oberhumer::Schema::PictureProjects', 'project_id');
>>>> __PACKAGE__->many_to_many(pictures => 'picture_projects', 'picture');
>>>
>>> in myapp02.sql:
>>>>CREATE TABLE pictures (
>>>>id   INTEGER PRIMARY KEY,
>>>>titleTEXT,
>>>>info TEXT,
>>>>filename TEXT,
>>>>created  

Re: [Catalyst] edit has_many relation with FormFu

2008-10-27 Thread David Schmidt
Hello and thanks for your reply.
I tried adding model_config before but it didn't change anything.
Here is a full formfu_create.yml listing:

> indicator: submit
> elements:
> - type: Text
>   name: title
>   label: Title
>
> - type: Textarea
>   name: description
>   label: Description
>
> - type: Select
>   name: pictures
>   label: Pictures
>   multiple: 1
>   size: 10
>
> - type: Select
>   name: active
>   label: Status
>   options:
> - [ '0', 'inactive' ]
> - [ '1', 'active' ]
>
> - type: Repeatable
>   nested_name: picture_projects
>   model_config:
> model: 'myDB::PictureProjects'
>   elements:
> - type: Hidden
>   name: project_id
> - type: Hidden
>   name: picture_id
> - type: Text
>   label: Position
>   name: position
>
> - type: Submit
>   name: submit
>   value: Submit
>
> constraints:
> - Required

The only thing different with your example I can see is that you
apparently have a primary key consisting of one column while I have a
composed primary key of the two foreign keys of the m:n relation.

friendly greetings
david

On Sun, Oct 26, 2008 at 10:59 PM, Chris <[EMAIL PROTECTED]> wrote:
> Hi David,
>
>> I want to edit a m:n relation between projects and pictures (a project
>> may have many pictures). It is displayed correctly but upon submit the
>> following error message occurs:
>> NOTE: 7 is the project ID which seems to be interpreted as a column name
>>
>> DBI Exception: DBD::SQLite::db prepare_cached failed: near ".7":
>> syntax error(1) at dbdimp.c line 271 [for Statement "SELECT
>> me.picture_id, me.project_id, me.position FROM picture_projects me
>> WHERE ( ( ( me.7 IS NULL ) AND ( me.project_id = ? ) ) )"] at
>> /usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954
>>
>> in this line in Controller/Projects.pm:
>>>if ($form->submitted_and_valid) {
>>>$form->model->update($project);
>>
>>
>> Any help is highly appreciated as I am stuck with this problem since a
>> few days already.
>>
>> in lib/MyApp/Schema/Projects.pm:
>>> __PACKAGE__->has_many(picture_projects => 
>>> 'Oberhumer::Schema::PictureProjects', 'project_id');
>>> __PACKAGE__->many_to_many(pictures => 'picture_projects', 'picture');
>>
>> in myapp02.sql:
>>>CREATE TABLE pictures (
>>>id   INTEGER PRIMARY KEY,
>>>titleTEXT,
>>>info TEXT,
>>>filename TEXT,
>>>created  datetime
>>>);
>>>
>>>CREATE TABLE picture_projects (
>>>picture_id  INTEGER,
>>>project_id  INTEGER,
>>>positionINTEGER,
>>>PRIMARY KEY (project_id, picture_id)
>>>);
>>
>> in root/forms/projects/formfu_create.yml:
>>>- type: Repeatable
>>>  nested_name: picture_projects
>>>  elements:
>>>- type: Hidden
>>>  name: project_id
>>>- type: Hidden
>>>  name: picture_id
>>>- type: Text
>>>  label: Position
>>>  name: position
>>
>> with friendly greetings
>> David Schmidt
>>
>
> What does the rest of formfu_create.yml contain?
>
> I've seen the same problem. I vaguely recall needing a model_config
> section in the formfu config, something like this (as a perl hash):
>
> {   type => 'Fieldset', legend=>'Plant Zones', elements => [
>{
>type=> 'Repeatable',
>nested_name =>  'plant_zones',
>
>model_config=>  {
>model  
>  =>  'DB::PlantZones',
>new_empty_row_multi => 
>  'zone_id',
>},
>
>        attributes  =>  {
>class   =>  
> 'zone-block',
>},
>
>elements=>  [
>{
>type=>  
> 'Hidden',
>name=>  'id',
>},
>
> ... etc...
>
> - Chris
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



-- 
David Schmidt   |   http://www.fm5.at

___
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] edit has_many relation with FormFu

2008-10-24 Thread David Schmidt
Hello List.

I want to edit a m:n relation between projects and pictures (a project
may have many pictures). It is displayed correctly but upon submit the
following error message occurs:
NOTE: 7 is the project ID which seems to be interpreted as a column name

DBI Exception: DBD::SQLite::db prepare_cached failed: near ".7":
syntax error(1) at dbdimp.c line 271 [for Statement "SELECT
me.picture_id, me.project_id, me.position FROM picture_projects me
WHERE ( ( ( me.7 IS NULL ) AND ( me.project_id = ? ) ) )"] at
/usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954

in this line in Controller/Projects.pm:
>if ($form->submitted_and_valid) {
>$form->model->update($project);


Any help is highly appreciated as I am stuck with this problem since a
few days already.

in lib/MyApp/Schema/Projects.pm:
> __PACKAGE__->has_many(picture_projects => 
> 'Oberhumer::Schema::PictureProjects', 'project_id');
> __PACKAGE__->many_to_many(pictures => 'picture_projects', 'picture');

in myapp02.sql:
>CREATE TABLE pictures (
>id   INTEGER PRIMARY KEY,
>titleTEXT,
>info TEXT,
>filename TEXT,
>created  datetime
>);
>
>CREATE TABLE picture_projects (
>picture_id  INTEGER,
>project_id  INTEGER,
>positionINTEGER,
>PRIMARY KEY (project_id, picture_id)
>);

in root/forms/projects/formfu_create.yml:
>- type: Repeatable
>  nested_name: picture_projects
>  elements:
>- type: Hidden
>  name: project_id
>- type: Hidden
>  name: picture_id
>- type: Text
>  label: Position
>  name: position

with friendly greetings
David Schmidt

-- 
David Schmidt   |   http://www.fm5.at

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