Grokbase
Topics Posts Groups | in
x
[ help ]

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

Profile | Posts (312)

User Information

Display Name:Carl Franks
Partial Email Address:firea...@gmail.com
Posts:
312 total
10 in Catalyst Framework Development
116 in Catalyst Framework
40 in DBIx::Class
1 in dbix-class@lists.scsys.co.uk
11 in Dojo Tookit
38 in HTML::FormFu
77 in HTML::FormFu
12 in HTML::Widget
5 in Moose
2 in Perl 5 Porters

5 Most Recent

All Posts
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

spacer
Profile | Posts (312)
Home > People > Carl Franks