Grokbase
Topics Posts Groups | in
x
[ help ]

Carl Franks (firea...@gmail.com)

Profile | Posts (312)Page 1 of 16: 1 2 3 > >>
1) Carl Franks [Dbix-class] Re: DBIx::Class::ResultSet::RecursiveUpdate - announcement and RFC
| +1 vote
2008/10/2 Zbigniew Lukasiak <zzbbyy@gmail.com>: I would suggest that if it's an update, you should...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/10/2 Zbigniew Lukasiak <zzbbyy@gmail.com>:
> On Thu, Oct 2, 2008 at 2:40 AM, Matt S Trout <dbix-class@trout.me.uk> wrote:
>> On Wed, Oct 01, 2008 at 09:38:07AM +0200, Zbigniew Lukasiak wrote:
>>> The example that I am mostly concerned with is:
>>>
>>> $cd_rs->recursive_update( { title => 'New Title', artist => { name =>
>>> 'New Name' } } )
>>>
>>> Now when traversing the relation from cd to the artist I get the
>>> artist resultset with the PK constrained in the ->{cond}. There is
>>> just one artist that the cd 'belongs_to' - and that artist should be
>>> updated. But there is no PK passed in the parameters - so if we just
>>> look at the parameters we would conclude that this would require a
>>> ->create call.
>>
>> Ah, because the artist is about to be changed?
>>
>> In that case you should create the artist separately and then assign it
>> I think, which again avoids the problem.
>>
>
> Perhaps I did not explain it enough - I want that call to result in an
> update not a create. An update to the only artist that 'belongs_to'
> the cd.

( /me steps into a minefield )

I would suggest that if it's an update, you should already have the
artist PK - keep ahold of it when you're initially getting the vales
from the DB.

Then, when you're doing the update, verify the PK hasn't changed (or
maybe allow it to be configured to allow rel ID changes).

I know FormFu doesn't do that, it can just follow the relationship
name, so you don't need a hidden field for the related PK - but I feel
it's more flexible to handle traversing the relationships ourselves,
rather than using a core DBIC recursive-update.

Carl
2) Carl Franks [Catalyst] Slow template processing on debian lenny
| +1 vote
2008/9/26 Terence Monteiro <terence@deeproot.co.in>: In my experience, the Template::Alloy author...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/9/26 Terence Monteiro <terence@deeproot.co.in>:

> The only thing with Template::Alloy is that
> it does'nt seem to support the list import vmethod, does someone have a
> patch, or do I modify my template to get import working?

In my experience, the Template::Alloy author has been very good about
accepting patches / suggestions - so I'd suggest emailing him.

Carl
3) Carl Franks [Catalyst] persistent perl engine
| +1 vote
I'm just posting this here in case it's useful to anyone else. `perperl` provided by the...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
I'm just posting this here in case it's useful to anyone else.

`perperl` provided by the PersistentPerl distribution seems to work
fine with myapp_cgi.pl - with one exception...
sysread() seems to always return 0 when running under perperl.

I've created a basic engine that simply overrides read_chunk(), so it
uses read() instead.

This should also work with CGI::SpeedyCGI - which as far as I'm aware,
it the same code as PersistentPerl, under a different name.

Now to start repressing my memory of how long it's taken me to fix this...

Cheers,
Carl


package Catalyst::Engine::PerPerl;

use strict;
use base 'Catalyst::Engine::CGI';

sub read_chunk {
    shift; # $self
    shift; # $c

    *STDIN->read( @_ );
}

1;
4) Carl Franks [Catalyst] Catalyst::Response - send a file
| +1 vote
2008/8/19 Dermot <paikkos@googlemail.com>: Ah, ok. You should have used header(). headers() returns...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/8/19 Dermot <paikkos@googlemail.com>:
> 2008/8/19 Carl Franks <fireartist@gmail.com>:
>> 2008/8/19 Dermot <paikkos@googlemail.com>:
>>> sub downloadFile {
>>>
>>>  my ($name, $filepath) = @_;
>>>
>>>  my $length = (stat($filepath))[7];
>>>  my $res = $c->response;
>>>  $res->content_length($length);
>>>
>>> $res->headers->({ 'Content-Disposition' =>
>>> "attachment;filename=$name"} ); # CODE ref error
>>>
>>> $res->sendfile($filepath,0,$length); # Ok no such method but
>>> hopefully you'll get what I mean.
>>>
>>> }
>>
>> open my $filehandle, '<', $filepath
>>    or die $!;
>>
>> $c->response->body( $filehandle );
>
>
> Sorry. I mustn't be making myself clear.
>
> I want the browser to offer the user a 'save as' dialogue box. The
> modperl equivalent would be the RequestIO::sendfile
>
> The above sends the contents of filepath to the browser

Ah, ok.
You should have used header().
headers() returns the HTTP::Headers object, which you were overwriting.

$c->response->header(
    'Content-Disposition' => "attachment;filename=$name"
);

You'll still need the body($fh) bit to send the data, too.

Carl
5) Carl Franks [Catalyst] Catalyst::Response - send a file
| +1 vote
2008/8/19 Dermot <paikkos@googlemail.com>: open my $filehandle, '<', $filepath or die $!;...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/8/19 Dermot <paikkos@googlemail.com>:
> Hi,
>
> I am looking for a method to send a file in response to a request. My
> effort is below and all this does is print the file's path on the
> page. I can't set the content-disposition or see find an obvious
> method in C::Response or C::Request.
>
> Am I looking in the wrong place? Can someone point me in the right direction.
> Tia,
> Dp.
>
>
>
> sub downloadFile {
>
>  my ($name, $filepath) = @_;
>
>  my $length = (stat($filepath))[7];
>  my $res = $c->response;
>  $res->content_length($length);
>
> $res->headers->({ 'Content-Disposition' =>
> "attachment;filename=$name"} ); # CODE ref error
>
> $res->sendfile($filepath,0,$length); # Ok no such method but
> hopefully you'll get what I mean.
>
> }

open my $filehandle, '<', $filepath
    or die $!;

$c->response->body( $filehandle );


Cheers,
Carl
6) Carl Franks [Catalyst] HTML::FormFu - how to manually control the rendering?
| +1 vote
2008/8/18 Dermot <paikkos@googlemail.com>: The FormFu list uses the same server as this catalyst...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/8/18 Dermot <paikkos@googlemail.com>:
>
> I agree it is a great tool - shame the mailing list is down.

The FormFu list uses the same server as this catalyst list - so it's
probably not down ;)

The old rawmode.org address has been killed though.
I think all the documentation has been updated, but if you got the old
address from somewhere recently, can you let me know where, and I'll
try to get it fixed.

Cheers,
Carl
7) Carl Franks [Catalyst] HTML::FormFu - how to manually control the rendering?
| +1 vote
2008/8/18 <kakimoto@tpg.com.au>: You can sign up to the HTML-FormFu mailing list here:...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/8/18 <kakimoto@tpg.com.au>:
>
> hello there
>   I love using HTML::FormFu in these two aspects:
> 1) Validation - oh ,yeah :)
> 2) configuration (via yaml in my case)
>
>
> nevertheless, is there any way we can control the rendering (in TT2)?
> From what has been done in the catalyst tute for html::FormFu, i
> noticed that it just lists down form elements line by line...
> I am sure there are websites whereby the graphics designer would place
> form elements in different styles..

You can sign up to the HTML-FormFu mailing list here:
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Cheers,
Carl
8) Carl Franks [Catalyst] Troubleshooting FastCGI error
| +1 vote
2008/8/13 Dermot <paikkos@googlemail.com>: You're passing $form->model->update() your row object,...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/8/13 Dermot <paikkos@googlemail.com>:
> 2008/8/13 Matthias Zeichmann <matthias.zeichmann@gmail.com>:
>> On Wed, Aug 13, 2008 at 12:35, Dermot <paikkos@googlemail.com> wrote:
>>> -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
>>
>> better change permissions to something like 664 and chgrp www-data (or
>> whatever your webserver runs as) and make sure that webserver user can
>> traverse the path to db
>>
>> like i.e.
>> # su -m www-data
>> $ cd $PATH_TO_YOUR_DB
>>
>> cheers
>> m
>
> Hi Matthias,
>
> Is that for security reason? My http daemon runs as apache. Below is
> the permissions as they are now.
>
> -rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db
>
> It doesn't resolve my problem. The error:
>
> unable to open database file(14)
>
> Is still there, even after a graceful restart.
>
> I suspect this is a configuration problem with FormFU but I am not
> sure what. I have tickered with my conf file

You're passing $form->model->update() your row object, so I don't
think it can be a problem with formfu, as it'll just be working with
that.
Did you follow Matthias' advice to `su apache` and check you can
change into the directory containing the db file?

Carl
9) Carl Franks [Catalyst] Any recommendations for multiple forms incatalyst(have been using HTML::FormFu)?
| +1 vote
2008/7/6 Octavian Rasnita <orasnita@gmail.com>: Okay, when I get the time, I'll try installing on a...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/7/6 Octavian Rasnita <orasnita@gmail.com>:
>
> I have also installed it, but I needed to install DateTime and
> DateTime::Format::Strptime using ppm, because with cpan it gave some errors.

Okay, when I get the time, I'll try installing on a fresh perl
install, and see what happens.

I can remember hitting some missing prereq-dependency recently, but
can't find any relevant RT bugs on any of the DateTime* modules we use
- my bad for not following it up at the time!

Carl
10) Carl Franks [Catalyst] Any recommendations for multiple forms in catalyst(have been using HTML::FormFu)?
| +1 vote
2008/7/6 Octavian Rasnita <orasnita@gmail.com>: Yes! The reason I haven't released the MultiForm...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/7/6 Octavian Rasnita <orasnita@gmail.com>:
>
> Will HTML::FormFu work under Windows?

Yes!

The reason I haven't released the MultiForm work to cpan yet, is
because I've had trouble getting the tests to run under windows - but
that's more an issue with how I was testing, rather than the actual
code.

Other than that though, I've got HTML-FormFu and all it's dependencies
installed using VanillaPerl on WinXP.

Carl
11) Carl Franks [Catalyst] Any recommendations for multiple forms in catalyst (have been using HTML::FormFu)?
| +1 vote
2008/7/6 <kakimoto@tpg.com.au>: Hi, The multiform module hasn't been released to cpan yet - you...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/7/6 <kakimoto@tpg.com.au>:
>
> Nevertheless, I could only find
> Catalyst::Controller::FormBuilder::MultiForm.
> You mentioned there's HTML::FormFu::MultiForm. I have seen
> "Catalyst::Controller::HTML::FormFu::Action::MultiForm" but can't seem
> to read up on it cause there's no link to it in
> http://search.cpan.org/~cfranks/Catalyst-Controller-HTML-FormFu-0.03000/.

Hi,

The multiform module hasn't been released to cpan yet - you need to
check it out from the subversion repository.
You can find it, and the Cat-controller, in the 2 project folders:
http://html-formfu.googlecode.com/svn/trunk/HTML-FormFu
http://html-formfu.googlecode.com/svn/trunk/Catalyst-Controller-HTML-FormFu

The reason it hasn't been released yet, is because the file upload
handling needs a bit more work - other than that, it works fine, and
I'm using it in a live application.

Carl
12) Carl Franks [Catalyst] Any recommendations for multiple forms in catalyst (have been using HTML::FormFu)?
| +1 vote
2008/7/4 <kakimoto@tpg.com.au>: I'll provide brief answers - if you want, repost to the formfu...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/7/4 <kakimoto@tpg.com.au>:
> Hello Carl,
> Thanks for that. Sounds good but a few questions to ask.
>
> 1) I have read through the Actions section in
> http://search.cpan.org/~zarquon/Catalyst-Manual-5.7012/lib/Catalyst/Manual/Intro.pod#Actions
> and yet I couldn't really find anything that describes what the third
> argument in
> "sub form2 : Path : FormMethod('_build_form2')" means. In that, I meant,
> "FormMethod('_build_form2')".

I'll provide brief answers - if you want, repost to the formfu mailing
list [1] so we don't waste the good Catalyst folk's time.

When you referred to `$form->stash->{form}` I perhaps wrongly guessed
you were using Catalyst-Controller-HTML-FormFu and the FormConfig
action.

FormMethod is documented in Catalyst-Controller-HTML-FormFu [2]

In a nutshell, FormMethod('_build_form') does this:

    my $form = HTML::FormFu->new;
    $form->populate(
        $controller->_build_form($c)
    );
    $form->process( $c->request );
    $c->stash->{form} = $form;

> 2) From sub build_form_2, you mentioned that
>> # return hash-ref based on $c->req->params->{loan_type}
>> # automatically gets passed to $form->populate
>
> Is it possible for me to:
> a) load_config_file() of a certain file which I define (for example,
> "home_loans.yml")
> b) and return the form object that has just runned load_config_file
> (as per the step above)?

Something like this would work:

sub _build_form {
    my ( $self, $c ) = @_;

    my $value = $c->req->param->{loan_type}
        or die "loan_type required";

    my $file;

    if ( $value eq 'foo' ) {
        $file = 'foo.yml';
    }
    elsif ( $value eq 'bar' ) {
        $file = 'bar.yml';
    }
    else {
        die "invalid loan_type";
    }

    $file = $c->path_to('root', 'forms', $file);

    return {
        load_config_file => "$file",
    };
}


[1] http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
[2] http://search.cpan.org/~cfranks/Catalyst-Controller-HTML-FormFu-0.03000/lib/Catalyst/Controller/HTML/FormFu.pm#SYNOPSIS
13) Carl Franks [Catalyst] Any recommendations for multiple forms in catalyst (have been using HTML::FormFu)?
| +1 vote
2008/7/4 Tomas Doran <bobtfish@bobtfish.net>: I think there's been either a lacking in my...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2008/7/4 Tomas Doran <bobtfish@bobtfish.net>:
>
> On 3 Jul 2008, at 09:05, Carl Franks wrote:
>>
>> I'm guessing that in step 3, your $c->stash->{form} is the one created
>> by the FormConfig action - in which case it's the same form used for
>> step 1.
>> It won't validate the submitted parameters, because it doesn't know
>> about any of the fields you generated in step 2.
>> What you need to do is again generate the same form as step 2, and use
>> that to validate the submitted parameters.
>>
>
> I'd disagree. At each step, you want to validate where you got so far, and
> if that validation goes well, move on - otherwise, move back...

I think there's been either a lacking in my explanation, or a lacking
in your interpretation - if you follow my posted code, it does exactly
what you describe.

Display form 1
-> if valid goto form 2
-> if not valid redisplay form 1
Display form 2
-> if valid, use the data
-> if not valid, redisplay form 2

This is exactly what HTML::FormFu::MultiForm does, but makes it more
simple, as you can do it all within a single Catalyst action - it also
encrypts previous form's data within a hidden field, so you don't need
to revalidate earlier data.

The bit I suspect the OP was getting wrong, was trying to validate
form 2's submission, using form 1.

However, rather than suggest a new module - to get the job done I
suggested what I hoped would only be a minor code change (based on
typical formfu usage, as the OP didn't give any code).

Cheers,
Carl
14) Carl Franks [Catalyst] Any recommendations for multiple forms in catalyst (have been using HTML::FormFu)?
| +1 vote
2008/7/3 <kakimoto@tpg.com.au>: I'm guessing that in step 3, your $c->stash->{form} is the one...