On Wed, Oct 09, 2002 at 10:47:23PM -0700, Wim Kerkhoff wrote:
> Last week I tried a couple of ways of doing this under EmbperlObject.
> That is, from somepage.html try to ignore the output of base.html and
> set the headers and content manually, while still having access to
> things bound to the request object $req.
> 
> Is that even possible? I ended up configuring a /cgi-bin and creating a
> CGI.pm script to dump out my binary data.

(This more or less assumes 1.3.4 as I haven't played with 2.0 yet)

You need a base.html that doesn't output anything itself. Three main
cases here (I'm sure others can contribute alternatives):

1. Simple case of embperl object and you not needing anything from
   init.html:

  - create a subdir with a very simple base.html that contains only
    [- Execute('*') -]
  - your somepage.html then does its own output and all is good

2. Your case of needing things from init.html (I'm assuming that
   init.html is a "global" file and does once-only setup):

   - create a $webbase/common directory and put init.html in there
   - set EMBPERL_OBJECT_ADDPATH to $webbase/common
   - create a normal subdir with an almost as simple base.html
     [- Execute('init.html'); Execute('*'); -]
   - your somepage.html then does its own output and all is good

3. If init.html needs to be different in different parts of the site
then things start getting more complex and you'll have to either
   - copy init.html into the new subdir
   - move things into your own module and use it from somepage.html
   - use EMBPERL_OBJECT_HANDLER_CLASS and have the functions in $req
     already
   - ...

> init.html:
> 
> [- $req = shift; $req->{dbh} = DBI ...; -]
> 
> 
> base.html:
> 
> <html>
> [- Execute ('*') -]
> </html>

Your image data will be surrounded in <html> tags here.

> somepage.html:
> 
> [-
> $req = shift;
> $dbh = $req->{dbh};

$escmode=0;

> $http_headers_out{'Content-Type'} = "image/gif";
> print OUT $dbh->selectrow_array("select imageblob from images where
> id=234");     
> -]

-- 
 Andrew O'Brien
 Senior Engineer                       email: [EMAIL PROTECTED]
 Switch Online Group Pty Limited       phone: +61 2 9299 1133
 ABN 89 092 286 327                    fax:   +61 2 9299 1134

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to