Gantry

 view release on metacpan or  search on metacpan

lib/Gantry.pm  view on Meta::CPAN

            'Gantry', 'State', "${sengine}.pm" 
        );

        eval {
            require $def_sengine_file;
            import $DEFAULT_STATE_MACHINE;
        };
        if ($@) { die qq/Could not load Default state machine, "$@"/ }
        
    }   

}

#-------------------------------------------------
# $class->namespace or $site->namespace
#-------------------------------------------------
sub namespace {
    return 'Gantry';
}

#-------------------------------------------------
# $site->init( $r )
# note: this function should be redefined in the application.
# This will act as the default but it's recommended
# that only global init rules are defined here
# 
# application note: for "proper" or suggested practice,
# the application level init function should immeadiatly
# call:
#
# $site->SUPER::init( $r );
#
# After the call to SUPER, the application level init 
# should include its init intructions.
#-------------------------------------------------
sub init {
    my ( $self, $r_or_cgi ) = @_; 

    $self->uri( $self->fish_uri() );
    $self->location( $self->fish_location() );
    $self->path_info( $self->fish_path_info() );
    $self->method( $self->fish_method() );
    $self->protocol( $ENV{HTTPS} ? 'https://' : 'http://' );
    $self->status( "" ); 

    if (defined $plugin_callbacks{ $self->namespace }{ init }) {
        # Do the plugin callbacks for the 'init' phase
        foreach my $callback (sort
                @{ $plugin_callbacks{ $self->namespace }{ init } }
        ) {
            $callback->( $self );
        }
    }

    # set post_max - used for apache request object
    $self->post_max( $self->fish_config( 'post_max' ) || '20000000' );

    # set user varible
    $self->user( $self->fish_user() );
    
    # set default content-type
    $self->content_type( $self->fish_config( 'content_type' ) || 'text/html' );

    # set template variables
    $self->template( $self->fish_config( 'template' ) );
    $self->template_default( $self->fish_config( 'template_default' ) );
    $self->template_wrapper( $self->fish_config( 'template_wrapper' ) );
    $self->template_disable( $self->fish_config( 'template_disable' ) );
    
    # set application directory variables
    my $app_root = $self->fish_config( 'root' ) || '';
    
    $self->root( $app_root );
    $self->doc_root( $self->fish_config( 'doc_root' ) );
    $self->css_root( $self->fish_config( 'css_root' ) );
    $self->img_root( $self->fish_config( 'img_root' ) );
    $self->js_root( $self->fish_config( 'js_root' ) );
    $self->tmp_root( $self->fish_config( 'tmp_root' ) );
    
    # set application uri variables
    $self->doc_rootp( $self->fish_config( 'doc_rootp' ) );
    $self->web_rootp( $self->fish_config( 'web_rootp' ) );
    $self->app_rootp( $self->fish_config( 'app_rootp' ) );
    $self->img_rootp( $self->fish_config( 'img_rootp' ) );
    $self->css_rootp( $self->fish_config( 'css_rootp' ) );
    $self->js_rootp( $self->fish_config( 'js_rootp' ) );
    $self->tmp_rootp( $self->fish_config( 'tmp_rootp' ) );
    $self->editor_rootp( $self->fish_config( 'editor_rootp' ) );
    
    # set no cache
    $self->no_cache( $self->fish_config( 'no_cache' ) );
    
    # set page title
    $self->page_title( $self->fish_config( 'page_title' ) || $self->uri );
    
    # set default date format
    $self->date_fmt( $self->fish_config( 'date_fmt' ) || '%b %d, %Y' );
    
    
    # set request body paramater variables
    $self->set_req_params();

    # database and auth database variables are handled in each engine's
    # Gantry::Utils::DBConnHelper::* sublcass.
    
} # END $site->init

#-------------------------------------------------
# $self->r( value )
#-------------------------------------------------
sub r {
    my ( $self, $p ) = @_;

    $self->{__R__} = $p if ( defined $p );
    return( $self->{__R__} );
        
} # end r

#-------------------------------------------------
# $self->cgi( value )
#-------------------------------------------------

lib/Gantry.pm  view on Meta::CPAN

Not intended for direct calls.

=item response_headers

Dual use accessor.

Parameters:
    key
    value

Returns: always returns the hash of headers

Omit the key and value for pure getter behavior.

=item r - The Apache Request 

 $r = $self->r; 
 $self->r( $r );

Set/get for apache request object

=item 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.

=item uri 

 $uri = $self->uri; 
 $self->uri( uri );

Set/get for server uri

=item location

 $location = $self->location; 
 $self->location( location );

Set/get for server location

=item current_url

 $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.

=item path_info

 $path_info  = $self->path_info; $self->path_info( path_info );

Set/get for server path_info

=item content_type

 $type = $self->content_type;
 $self->content_type( 'text/html' );

Set/get for reponse content-type

=item content_length

 $type = $self->content_length;
 $self->content_length( $length );

Set/get for reponse content-length

=item 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.

=item 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.

=item 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.

=item 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.

=item status

Dual accessor for the HTTP status of the page hit.

=item 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.

=item img_root



( run in 1.279 second using v1.01-cache-2.11-cpan-524268b4103 )