[jifty-devel] Downloading files
Henry Baragar
Henry.Baragar at instantiated.ca
Tue Dec 12 14:17:18 EST 2006
On Tuesday, December 12 2006 11:05 am, Jesse Vincent wrote:
> On Tue, Dec 12, 2006 at 09:22:14AM -0500, Henry Baragar wrote:
> > Hello all,
> >
> > What is the standard way to download a file in Jifty? I am generating
> > CSV files from a database for downloading into spreadsheets.
> >
> > The way I would do it in Mason would be to put the following in a
> > template file:
> >
> > <%init>
> > use Apache::Constants qw/OK/;
> > $m->clear_buffer;
> > $r->content_type('text/comma-separated-values');
> > $r->send_http_header();
> > $m->print(csv_data());
> > $m->abort(OK);
> > </%init>
> >
> > It occurs to me that this should all go into the Dispatcher. However, I
> > am worried that manipulating the request and Mason objects in this way
> > will interfere with what Jifty does.
>
> Well, I wouldn't generally put print statements in the dispatcher ;)
>
Makes sense.
> Usually, I dispatch to a template that looks a lot like what you wrote,
> except I've never needed the Apache::Constants, clear_buffer or
> send_http_header lines ;)
>
OK. Things definitely do not work in Jifty as I have them.
Following your advice, the following works:
$r->content_type('text/comma-separated-values');
$m->print(csv_data());
I like it. Its much shorter and much easier to remember.
(BTW, does this work in pure Mason as well?)
Regards,
Henry
> > Furthermore, there ought to be an easier way to do it!-)
> >
> > Thanks,
> > Henry
> > _______________________________________________
> > jifty-devel mailing list
> > jifty-devel at lists.jifty.org
> > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
More information about the jifty-devel
mailing list