perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Grimm <edgr...@dsblade00.wat.us.ray.com>
Subject Re: Dynamically generating file for download
Date Tue, 31 Jul 2007 19:03:32 GMT
On Sat, 28 Jul 2007, Lelton wrote:

> On 7/28/07, Ed Grimm <edgrimm@dsblade00.wat.us.ray.com> wrote:
>
> > The way you word this seems to me ambiguous.  Are you needing assistance
> > in how to do the two options I mentioned?
>
> I'm not sure how I can articulate it clearer. I have a working embperl
> based website with lots of included epl files that build page
> templates, etc. Every subsequent html file contains text/code which
> sits inside each page template which is automatically generated and
> then served.
>
> What I want to do for ONE particular page is have it generate a file
> that can be downloaded. Now, the user visits the particular html page
> (which is rendered with all the templates), fills in some details,
> clicks submit (which is a FORM action back to the same page) and then
> the HTTP response is the file to download.

You may have gathered this from the other people who have responded to
this, but there is no easy way to do this in EmbPerlObject.  A single
file will always either load the template or not, depending on its
applicable <Location>, <Directory>, and <FilesMatch> settings, and the
template file associated with its directory location.

You *could* make the base.epo file be smart enough that it recognized
when a particular page is loaded *and* has form data, to not show any
template.  I think that would be unwise, but it could be done.

What could be a bit simpler and more clever, while not straying too far
from your 'pure' state, would be to have a link to the file with the
same name except for the extension - something like

% ls index.*
-rw-r--r--   1 eg       other       5503 Jul 31  2007 index.html
lrw-r--r--   1 eg       other          9 Jul 31  2007 index.txt -> index.html
%

Now, have the action link to the other extension name.


That having been said - I used to do web pages that had the same script
generate the form and process the form.  I had enough problems with
doing that in various template environments that I decided, for testing
purposes, I'd stop fighting it temporarily and have a different file to
process the action from the one to generate the form - and it was so
much easier to work with it that way that the temporary became
permanent; I would now resist any effort to make me go back to that.

It's a coding style that has been given in examples by many books and
HOWTO documents, but it does not seem to me to be actually good for
everyday use.  Since I stopped using that design, I had the opportunity
to talk to one book author who had used it - who apologized for having
lead me astray; he admitted that it wasn't normally good coding design,
he had only used it in the book because it let him fit the text in page
boundaries better.  I cannot say that the other authors were using it
for that reason, but the experience reminded me that I should always
think before adopting someone's practices, and try to determine if there
is any reason why their practice might not be appropriate for me.

Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message