NAME

Para::Frame::Page - Represents the response page for a req

DESCRIPTION

Represents a page on a site with a specific URL.

Inherits from Para::Frame::File

This is the superclass of <Para::Frame::Site::Page>.

During lookup or generation of the page, the URL of the page can change. We differ between the original requested URL, the resulting URL and an URL for the template used.

A Para::Frame::Request will create a Para::Frame::Page object representing the response page.

A request can also create other Page objects for representing other pages for getting information about them or for generating pages for later use, maby not specificly copupled to the current request or session.

The distinction between Para::Frame::Request and Para::Frame::Page are still a litle bit vauge. We should separate more clearly between the requested URL and the URL used for the response and the template used for the response.

Methods for generating the response page and accessing info about that page has been collected here.

A Site can answer under many hosts. The host of a Page vary with the request. The language given by the request is used also for actions and not just for the response page.

Each Request has one response Page object. It may first be a normal template and then change to generate an error page if action or template throw an exception. But it is still the same object.

I may change that so that a new Page object is created if there was a redirection to a new page.

Constructors

new

  Para::Frame::Page->new( \%args )

Creates a Page object.

Accessors

See Para::Frame::File/Accessors

is_index

True if this is a /index.tt

template

  $p->template()

Returns the (current) Template::Document object for this page, as returned by /find_template given /url_path_tmpl.

The document object can be used for getting variables set in the META part of the template, via Template::Document/AUTOLOAD.

Example:

If the template contains [% META section="games" %] you can get that value by saying:

  my $section = $p->template->section;

section has no special meaning in paraframe. ... You can also get the specially used variables like next_action, et al.

Returns: The Template::Document object

title

  $p->title()

Returns the /template otitle or title or in the last case just the Para::Frame::File/name.

is_page

  $p->is_page()

Returns: true

renderer

  $p->renderer

Returns: the renderer to be used, if not the standard renderer

Public methods

add_params

  $p->add_params( \%params )
  $p->add_params( \%params, $keep_old_flag )

Adds template params. This can be variabls, objects, functions.

If $keep_old_flag is true, we will not replace existing params with the same name.

precompile

  $page->precompile( \%args )

Send same args as for /new for creating the new page from thre source $page. Also takes:

  arg type defaults to html_pre
  arg language defaults to undef

Returns: The new compiled page

paths

  $p->paths( $burner )

Automaticly called by Template::Provider to get the include paths for building pages from templates.

Returns: /incpath

set_renderer

  $p->set_renderer( \&renderer )

Sets the code to run for rendering the page, if not the standard renderer.

Example renderer:

  my $render_hello = sub
  {
      my( $req ) = @_;
      my $p = $req->page;
      $p->ctype("text/html");
      my $out = "<h1>Hello world!</h1>";
      $p->set_content(\$out);
      return 1;
  };
  $p->set_renderer($render_hello);

Returns: /renderer

set_content

  $p->set_content( \$content )

Sets the page to be returned to the client.

If you want an action to returns a special type of page, it should use /set_renderer since that renderer is called after all actions been sorted out.

But you could set the response page directly in the action by calling this method.

Returns: The reference to the content, stored in the page object.

set_tt_params

The standard functions availible in templates. This is called before the page is rendered. You should not call it by yourself.

browser
The HTTP::BrowserDetect object. Not in StandAlone mode.
dir
The directory part of the filename, including the last '/'. Symlinks resolved.
u
$req->{'user'} : The Para::Frame::User object.
ENV
$req->env: The Environment hash (http://hoohoo.ncsa.uiuc.edu/cgi/env.html). Only in client mode.
filename
Holds the Para::Frame::Request/filename.
home
$req->site->home : Para::Frame::Site/home
lang
The Para::Frame::Request/preffered_language value.
me
Holds the Para::Frame::File/url_path_slash for the page, except if an /error_page_selected in which case we set it to /orig_url_path. (For making it easier to link back to the intended page)
q
The CGI object. You will probably mostly use [% q.param() %] method. Only in client mode.
req
The req object.
reqnum
The paraframe server request number
result
$req->{'result'} : The Para::Frame::Result object
site
The <Para;;Frame::Site> object.

Private methods

burner

  $p->burner

Returns: the Para::Frame::Burner selected for this page

set_burner_by_type

  $p->set_burner_by_type( $type )

Calls Para::Frame::Burner/get_by_type and store it in the page object.

Returns: the burner

set_burner_by_ext

  $p->set_burner_by_ext( $ext )

Calls Para::Frame::Burner/get_by_ext and store it in the page object.

Returns: the burner

burn

  $p->burn( $in, $out );

Calls Para::Frame::Burner/burn with ($in, $params, $out) there $params are set by /set_tt_params.

Returns: the burner

find_template

  returns ($doc, $ext) where $doc is a L<Template::Document> objetct
that can be parsed to a L<Para::Frame::Burner> object.

get_static

  $p->get_static( $in, $pageref )

$pageref must be a scalar ref.

$in must be a IO::File or a filename to be sent to IO::File/new.

Places the content of the file in $pageref.

Returns: $pageref

render_output

  $p->render_output()

Burns the page and stores the result.

If the rendering failes, may change the template and URL. The new URL can be used for another call to this method.

This method is called by Para::Frame::Request/after_jobs.

Returns: True on success and 0 on failure

set_dirsteps

  $p->set_dirsteps()
  $p->set_dirsteps( $path_full )

path_full defaults to the current template dir. It must end with a /. It is a filesystem path. Not the URL path

Returns: /dirsteps

dirsteps

  $p->dirsteps

Returns: the current dirsteps as a ref to a list of strings.

set_incpath

  $p->set_incpath( \@incpath )

Internally used by /incpath.

The param should be a ref to an array of absolute paths (from the system root) to dirs with template include files.

Places the Para::Frame::Burner should look for templates to include.

Returns: /incpath

incpath

  $p->incpath()

Internally used by /paths, that sets up the incpath. Use /paths instead of this method.

Returns: A ref to an array of absolute paths (from the system root) to dirs with template include files.

Removed methods

url_dir

use .dir.url_path instead

url_dir_path

use .dir.url_path_slash instead

url_parent

use .parent.url_path instead

url_parent_path

use .parent.url_path_slash instead

sys_dir

use .dir.sys_path instead

SEE ALSO

Para::Frame