NAME

Para::Frame - Web application framework

DESCRIPTION

Para::Frame is a system to use for dynamic web sites. It runs as a backend daemon taking page requests from a Apache mod_perl client and returns a HTTP response.

Para::Frame::Overview
Overview and Introduction
Para::Frame::Template::Overview
The default ParaFrame TT components
Para::Frame::Template::Meta
The page META information
Para::Frame::Template::Index
Template creation and modification

QUICKSTART

In httpd.conf :

   <Perl>
      unshift @INC, '/usr/local/paraframe/lib';
   </Perl>
   PerlModule Para::Frame::Client

In .htaccess :

   <FilesMatch ".tt$|^$">
     SetHandler perl-script
   </FilesMatch>
   PerlHandler Para::Frame::Client
   ErrorDocument 404 /page_not_found.tt
   PerlSetVar port 7788

In some/public/file.tt :

   [% META title="Hello world" %]
   <p>This is a simple template</p>

startup

watchdog_startup

  Para::Frame->watchdog_startup

Starts the Para::Frame::Watchdog.

You may want to use /daemonize instead.

main_loop

switch_req

add_client

get_value

Either we know we have something to read or we are expecting an answer shortly

Only call this if you KNOW where is a value to get. The answer may not be the one you were waiting for, so you may have to call this method several times.

This will also handle incoming data coming AFTER your answer, if there is any such data to be handled.

In usmmary: It reads all there is and returns

Exceptions: If nothing was gotten before the timeout (5 secs), an exception will be thrown.

TODO: Cleanup return code...

recieve_from_clients

handle_recieved_data

fill_buffer DEPRECATED

handle_code

nonblock

cancel_and_close

  cancel_and_close( $req, $client, $reason )

$req may be undef

close_callback

REAPER

daemonize

  Para::Frame->daemonize( $run_watchdog )

Starts the paraframe daemon in the background. If $run_watchdog is true, lets Para::Frame::Watchdog start and watch over the daemon.

restart

  Para::Frame->restart()

Restarts the daemon. We asume that we will restart in the background, with a watchdog.

TODO: Will try to detect if the process is not a daemon and in that case restart in the foreground. (Must place new process in same terminal)

kill_children

  Para::Frame->kill_children()

go_down

  Para::Frame->go_down()

Assumes that we will exit one way or another after this. Thus, we will shut down the signal handling before killing the childs, and NOT turn it on afterwards.

add_background_jobs_conditional

add_background_jobs

RUNS bgjobs!

handle_request

handle_http

add_hook

  Para::Frame->add_hook( $label, \&code )

Adds code to be run on special occations. This adds the code to the hook. The actual hook is added (created) by adding the hook label to %HOOK and then run the hook using /run_hook.

Availible hooks are:

on_configure

Runs just after the main PF configure. Before DB connection. Before startup.

on_startup

Runs just before the main_loop.

on_memory

Runs then the watchdog send a MEMORY notice.

on_error_detect

Runs then the exception is catched by Para::Frame::Result/exception.

on_fork

Runs in the child just after the fork.

on_reload

Called with filepath as argument on each reload of a module. Will also be called on first load of module if loaded by compile() method.

done

Runs just before the request is done.

before_user_login

Runs before user logged in, in Para::Frame::Action::user_login

user_login

Runs after user logged in, in Para::Frame::Action::user_login

before_user_logout

Runs after user logged out, in Para::Frame::User/logout

after_db_connect

Runs after each DB connect from Para::Frame::DBIx/connect

before_db_commit

Runs before committing each DB, from Para::Frame::DBIx/commit

after_db_rollback

Runs after a rollback for each DB, from Para::Frame::DBIx/rollback

before_switch_req

Runs just before switching from one request to another. Not Switching from one request to another can be done several times before the request is done.

before_render_output

Runs before the result page starts to render.

busy_background_job

Runs often, between requests.

add_background_jobs

For adding jobs that should be done in the background, when there is nothing else to do or when it hasen't run in a while.

run_hook

Para::Frame->run_hook( $req, $label );

Runs hooks with label $label.

add_global_tt_params

  Para::Frame->add_global_tt_params( \%params )

Adds all params to the global params to be used for all templates. Replacing existing params if the name is the same.

do_hup

Will tell watchdog to restart server by forking.

write_pidfile

remove_pidfile

END

open_logfile

See also Para::Frame::Watchdog/open_logfile

configure

  Para::Frame->configure( \%cfg )

Configures paraframe before startup. The configuration is stored in $Para::Frame::CFG

These configuration params are used:

appback

This is a listref of server paths. Each path should bee a dir that holds a html dir, or a dev dir, for compiled sites. See Para::Frame::Site/appback.

Must be defined

appbase

A string that gives the base part of the package name for actions.

Must be defined

Example: If you set appbase to My::App, the action my_action will be looked for as My::App::Action::my_action.

appfmly

This should be a listref of elements, each to be treated as fallbacks for Para::Frame::Site/appbase. If no actions are found under Para::Frame::Site/appbase one after one of the elements in appfmly are tried. See Para::Frame::Site/appfmly.

Defaults to none.

approot

The path to application. This is the dir that holds the lib and possibly the var dirs. See Para::Frame::Site/approot.

Must be defined

bg_user_code

A coderef that generates a user object to be used for background jobs.

Defaults to code that get guest from /user_class.

debug

Sets global $Para::Frame::DEBUG value that will be used as default debug value for all sessions.

Default is 0.

dir_log

The dir to store the paraframe log.

Default is $dir_var/log

dir_run

The dir to store the process pid.

Default is $dir_var/run

dir_var

The base for /dir_log and /dir_run and /ttcdir.

Default is /var

l10n_class

The class to use for localizations. Should be a subclass to Para::Frame::L10N.

Defaults to Para::Frame::L10N

languages

A ref to an array of scalar two letter strings of the language codes the sites supports. This config will be the default if no list is given to the specific site. See Para::Frame::Site/languages.

locale

Specifies what to set LC_ALL to, except LC_NUMERIC that is set to C. The default is sv_SE.

logfile

The file to use for logging.

Defaults to /dir_log followed by /parframe_$port.log

paraframe

The dir that holds paraframe.

Default is /usr/local/paraframe

paraframe_group

The file group to set files to that are created.

Default is staff

pidfile

The file to use for storing the paraframe pid.

Defaults to /dir_run followed by /parframe_$port.pid

port

The port top listen on for incoming requests.

Defaults to 7788.

session_class

The class to use for sessions. Should be a subclass to Para::Frame::Session.

Defaults to Para::Frame::Session

site_auto

If true, accepts hosts in request even if no matching site has been created. See Para::Frame::Site/get_by_req. site_auto can also be the name of a site to use for the template site.

site_autodetect

... document this

site_class

The class to use for representing sites. Should be a subclass to Para::Frame::Site.

Defaults to Para::Frame::Site

th

th is a ref to a hash of Para::Frame::Burner objects. You should use the default configuration.

There are three standard burners.

  html     = The burner used for all tt pages

  plain    = The burner used for emails and other plain text things

  html_pre = The burner for precompiling of tt pages

Example for adding a filter to the html burner:

  Para::Frame::Burner->get_by_type('html')->add_filters({
      'upper_case' => sub{ return uc($_[0]) },
  });

See also Para::Frame::Burner

time_zone

Sets the time zone for Para::Frame::Time.

Defaults to local

time_format

Sets the default presentation of times using Para::Frame::Time/format_datetime

Defaults to %Y-%m-%d %H.%M

time_stringify

Calls Para::Frame::Time/set_stringify with the param.

tt_plugins

Adds a list of Template::Plugin bases. Always adds Para::Frame::Template::Plugin.

Defaults to the empty list.

tt_plugin_loaders

Adds a list of TT plugin loaders. Always adds Template::Plugins and gives it tt_plugins

ttcdir

The directory that holds the compiled templates.

Defaults to /dir_var/ttc or /appback/var/ttc or /approot/var/ttc followed by /var/ttc.

umask

The default umask for created files.

Defaults 0007

user_class

The class to use for user identification. Should be a subclass to Para::Frame::User.

Defaults to Para::Frame::User

worker_startup

The number of workers to spawn during startup. The sooner a worker is spawned, the less memory will it use. The workers lives on til the next server HUP. More workes will spawn on demand.

Defaults to 0

Session

  Para::Frame->Session

Returns the /session_class string.

User

  Para::Frame->User

Returns the /user_class string.

dir

Returns the /paraframe dir.

report

Returns a report in plain text of server status

flag_restart

  Para::Frame->flag_restart()

set_global_tt_params

The standard functions availible in templates.

Most of them exists in both from client and not client.

cfg
$app->conf : Para::Frame/configure
debug
Emit a debug message in the error log. See Para::Frame::Utils/debug
dump
The Para::Frame::Utils/datadump function. To be used for debugging. Either dump the data structure inside the page (in <pre></pre>) or combine with debug to send the dump to the error log. For example: [% debug(dump(myvar)) %]
emergency_mode
True if paraframe recovered from an abnormal error.
file
Calls Para::Frame::File/new with the given params
loc
Calls Para::Frame::L10N/loc with the given params
locescape
Calls Para::Frame::L10N/locescape with the given params
rand
Produce a random integer number, at least 0 and at most one less than the number given as param.
timediff
See Para::Frame::Utils/timediff
uri
See Para::Frame::Utils/uri
uri_path
See Para::Frame::Utils/uri_path
warn
Emit a warning in the error log, excluding the linenumber (perlfunc/warn). You should use debug() instead.

See also Para::Frame::Widget and Para::Frame::Renderer::TT/set_tt_params

AUTHOR

Jonas Liljegren <jonas@paranormal.se>

SEE ALSO

Template