NAME
Gantry - Web application framework for mod_perl, cgi, etc.
SYNOPSIS
use Gantry qw/-Engine=MP13 -TemplateEngine=Default/;
use Gantry qw/-Engine=MP13 -TemplateEngine=TT/;
use Gantry qw/-Engine=CGI -TemplateEngine=TT/;
use Gantry qw/-Engine=MP20/;
DESCRIPTION
Perl Web application framework for Apache/mod_perl. Object Oriented design for a pragmatic, modular approach to URL dispatching. Supports MVC and initiates rapid development. This project offers an orgainized coding scheme for web applications.
METHODS
- handler
-
This is the default handler that can be inherited it calls init, and cleanup. Methods to be called from this handler should be of the naming convention do_name. If this cannot be found then the autoloader is called to return declined. Methods should take $r, and any other parameters that are in the uri past the method name.
- init
-
The init is called at the begining of each request and sets values such as, app_rootp, img_rootp, and other application set vars.
- declined
-
$self->declined( 1 );
Set and unset the declined flag
- relocate
-
$self->relocate( location );
This method can be called from any controller will relocated the user to the given location
- redirect
-
$self->redirect( 1 );
Set and unset the redirect flag
- no_cache
-
$self->no_cache( 1 );
Set and unset the no cache flag. This directive informs Apache to either send the the no_cache header or not.
- template_disable
-
$self->template_disable( 1 );
Set and unset the template disable flag.
- method
-
$self->method; $self->method( $r->method );
Set/get the apache request method, either 'POST' or 'GET'
- cleanroot
-
$self->cleanroot( uri, root );
Splits the URI and returns and array of the individual path locations.
- cleanup
-
$self->cleanup
This method is called at the end of the request phase to cleanup, disconnect for a database, etc.
-
$hash_ref_of_cookies = $self->get_cookies(); $cookie_value = $self->get_cookies( 'key_of_cookie' );
If called without any parameters, this method will return a reference to a hash of all cookie data. Otherwise, by passing a key to this method then the value for the requested cookie is returned.
-
$self->set_cookie( { name => cookie name, value => cookie value, expire => cookie expires, path => cookie path, domain => cookie domain, secure => [0/1] cookie secure, } )
This method can be called repeatedly and it will create the cookie and push it into the response headers.
- r
-
$r = $self->r; $self->r( $r );
Set/get for apache request object
- cgi
-
$cgi = $self->cgi; $self->cgi( CGI::Simple->new() );
Set/get for CGI::Simple object. See CGI::Simple docs. This method is only available when using the CGI engine.
- uri
-
$uri = $self->uri; $self->uri( uri );
Set/get for server uri
- location
-
$location = $self->location; $self->location( location );
Set/get for server location
- current_url
-
my $url_for_email = $self->current_url
Get the url of the current page. This combines protocol, base_server and uri to form a valid url suitable for inclusion in an email.
- path_info
-
$path_info = $self->path_info; $self->path_info( path_info );
Set/get for server path_info
- content_type
-
$type = $self->content_type; $self->content_type( 'text/html' );
Set/get for reponse content-type
- root
-
$self->root( '/home/tkeefer/myapp/root' ); $root = $self->root;
Set/get for the root value. This value is the application root directory that stores the templates and other application specific files.
- template
-
$self->template( 'some_template.tt' );
Set/get for template name for current request
The filename is relative to the $self->root value, otherwise it needs to be the full path to template file.
- template_default
-
$self->template_default( 'some_default_template.tt' );
Set/get for a template default value. If a template has not been defined for the request, then the default template is called.
The filename is relative to the $self->root value, otherwise it needs to be the full path to template file.
- template_wrapper
-
$self->template_wrapper( 'wrappers/wrapper.tt' );
Set/get for the template toolkit wrapper file. The wrapper does exactly as it says; it wrapper the ouput from the controller before the response is sent to the client.
The filename is relative to the $self->root value, otherwise it needs to be the full path to template file.
- css_root
-
$self->css_root( '/home/tkeefer/myapp/root/css' ); $css_root = $self->css_root;
Set/get for the css_root value. This value is used to locate the css files on disk.
- img_root
-
$self->img_root( '/home/tkeefer/myapp/root/images' ); $img_root = $self->img_root;
Set/get for the img_root value. This value is used to locate the application image files on disk.
- app_rootp
-
$self->app_rootp( '/myapp' ); $app_rootp = $self->app_rootp;
Set/get for the app_rootp value. This value is used to identify the the root URI location for the web application.
- img_rootp
-
$self->img_rootp( '/myapp' ); $img_rootp = $self->img_rootp;
Set/get for the img_rootp value. This value is used to identify the the root URI location for the web application images.
- css_rootp
-
$self->css_rootp( '/myapp/style' ); $css_rootp = $self->css_rootp;
Set/get for the app_rootp value. This value is used to identify the the root URI location for the web application css files.
- tmp_rootp
-
$self->tmp_rootp( '/myapp/tmp' ); $tmp_rootp = $self->tmp_rootp;
Set/get for the tmp_rootp value. This value is used to identify the the root URI location for the web application temporary files.
- editor_rootp
-
$self->editor_rootp( '/fck' ); $editor_rootp = $self->editor_rootp;
Set/get for the editor_rootp value. This value is used to identify the the root URI location for the html editor.
- tmp_root
-
$self->tmp_rootp( '/home/httpd/html/myapp/tmp' ); $tmp_root = $self->tmp_root;
Set/get for the tmp_root value. This value is used to identify the the root directory location for the web application temporary files.
- user
-
$self->user( $apache_connection_user ); $user = $self->user;
Set/get for the user value. Return the full user name of the active user. This value only exists if the user has successfully logged in.
- user_id
-
$user_id = $self->user_id( model => '', user_name => '' ); $user_id = $self->user_id;
Returns the user_id for the given user_name or for the currently logged in user, if no user_name parameter is passed. The user_id corresponds to the user_name found in the auth_users table. The user_id is generally used for changelog entries and tracking user activity within an app.
By default, the first time you call user_id or user_row during a request, the model will be set. It will be set to the value you pass in as model or the value returned by calling
<$self-
get_auth_model_name>>, if no model parameter is passed. This module has a get_auth_model_name that always returns 'Gantry::Control::Model::auth_users'. If you use a different model, override get_auth_model_name in your app's base module. We assume that your model has these methods: id and user_name. - user_row
-
$user_row = $self->user_row( model => '', user_name '' ); $user_row = $self->user_row;
The same as user_id, but it returns the whole model object (usually a representation of a database row).
- page_title
-
$self->page_title( 'Gantry is for you' ); $page_title = $self->page_title;
Set/get for the page title value. This page title is passed to the template and used for the HTML page title. This can be set in either the Apache LOCATION block or in the contoller.
- date_fmt
-
$self->date_fmt( '%m %d, %Y' ); $fmt = $self->date_fmt;
Set/get for the date format value. Used within the application for the default date format display.
- post_max
-
$self->post_max( '4M' ); $post_max = $self->post_max;
Set/get for the apache request post_max value. See Apache::Request or Apache2::Request docs.
- ap_req
-
$self->ap_req( api_call_to_apache ); $req = $self->ap_req;
Set/get for the apache request req object. See mod_perl documentation for intructions on how to use apache requets req.
- params
-
$self->params( $self->ap_req ); $params = $self->params;
Set/get for the request parameters. Returns a reference to a hash of key value pairs.
- protocol
-
$self->protocol( $ENV{HTTPS} ? 'https://' : 'http://' ); $protocol = $self->protocol;
Set/get for the request protocol. Value is either 'http://' or 'https://'. This is used to construct the full url to a resource on the local server.
- get_conf
-
Pass this the name of the instance and (optionally) the ganty.conf file where the conf for that instance lives. Returns whatever Gantry::Conf->retrieve returns.
MODULES
- Gantry::Stash
-
Main stash object for Gantry
- Gantry::Utils::CDBI
-
Class::DBI base class for Gantry applications
- Gantry::Plugins::CRUD
-
Helper for flexible CRUD coding scheme.
- Gantry::Plugins::AutoCRUD
-
provides a more automated approach to the CRUD (Create, Retrieve, Update, Delete) support
- Gantry::Plugins::Calendar
-
These module creates a couple calendar views that can be used by other applications and are highly customizeable.
- Gantry::Engine::MP13
-
This module is the binding between the Gantry framework and the mod_perl API. This particluar module contains the mod_perl 1.0 specific bindings.
See mod_perl documentation for a more detailed description for some of these bindings.
- Gantry::Engine::MP20
-
This module is the binding between the Gantry framework and the mod_perl API. This particluar module contains the mod_perl 2.0 specific bindings.
See mod_perl documentation for a more detailed description for some of these bindings.
- Gantry::Control
-
This module is a library of useful access functions that would be used in other handlers, it also details the other modules that belong to the Control tree.
- Gantry::Utils::DB
-
These functions wrap the common DBI calls to Databases with error checking.
- Gantry::Template::TT
-
This is recommended templating system in use by by Gantry.
- Gantry::Template::Default
-
This modules is used to to bypass a tempalting system and used if you prefer to output the raw text from within the controllers.
- Gantry::Utils::HTML
-
Implements HTML tags in a browser non-specfic way conforming to 3.2 and above HTML specifications.
- Gantry::Utils::SQL
-
This module supplies easy ways to make strings sql safe as well as allowing the creation of sql commands. All of these commands should work with any database as they do not do anything database specfic, well as far as I know anyways.
- Gantry::Utils::Validate
-
This module allows the validation of many common types of input.
- Gantry::Server
-
Stand alone web server used for testing Gantry applications and for quick delopment of Gantry applications. This server is not recommended for production use.
- Gantry::Conf
-
Flexible configuration system for Gantry
SEE ALSO
perl(3), httpd(3), mod_perl(3)
LIMITATIONS
Limitations are listed in the modules they apply to.
AUTHOR
Tim Keefer <tkeefer@gmail.com> Phil Crow <philcrow2000@yahoo.com>
Gantry was branched from Krkit version 0.16 Sat Jun 11 15:27:28 CDT 2005
COPYRIGHT and LICENSE
Copyright (c) 2005-6, Tim Keefer.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1322:
You forgot a '=back' before '=head1'