Name

CatalystX::Usul::Model - Application independent common model methods

Version

0.1.$Revision: 402 $

Synopsis

package CatalystX::Usul;
use parent qw(Catalyst::Component CatalystX::Usul::Base);

package CatalystX::Usul::Model;
use parent qw(CatalystX::Usul CatalystX::Usul::Utils);

package YourApp::Model::YourModel;
use parent qw(CatalystX::Usul::Model);

Description

Common core model methods

Subroutines/Methods

new

Defines the following accessors:

screensaver

The external command to execute to lock the display. Defaults to one that works with KDE as the window manager. Should move this to a plugin because its silly

scrubbing

Boolean used by "query_array" and "query_value" to determine if input value should be cleaned of potentially dangerous characters

scrub_chars

List of characters to scrub from input values. Defaults to '"/\;

Loads model plugins including;

CatalystX::Usul::Plugin::Model::StashHelper

ACCEPT_CONTEXT

Calls "build_per_context_instance" for each new context

build_per_context_instance

Called by "ACCEPT_CONTEXT". Takes a copy of the Catalyst object so that we don't have to pass $c into "get_action" in CatalystX::Usul, "localize" in CatalystX::Usul and "uri_for" in CatalystX::Usul

check_field

$self->check_field( $id, $val );

Expose "check_field" in Data::Validation

check_form

$self->check_form( \%fields );

Expose "check_form" in Data::Validation

form

$self->form( @rest );

Calls the form method to stuff the stash with the data for the requested form. Uses the $c->stash->{form}->{name} value to construct the method name

loc

localize

$local_text = $self->localize( $message, $args );

Localizes the message. Optionally calls markdown on the text

lock_display

Locks the display by running the external screensaver command

query_array

Returns the requested parameter in a list context. Uses the encoding attribute to generate the method call to decode the input values. The decode method is provided by CatalystX::Usul::Encoding. Will try to guess the encoding if one is not provided

query_value

Returns the requested parameter in a scalar context. Uses encoding attribute to generate the method call to decode the input value. The decode method is provided by CatalystX::Usul::Encoding. Will try to guess the encoding if one is not provided

scrub

$value = $self->scrub( $value );

Removes the $self->scrub_chars from the value

uri_for

$uri = $self->uri_for( $action_path, @args );

Provide defaults for the Catalyst uri_for method. Search for the uri with differing numbers of capture args

_get_req_array

my $array_ref = $self->_get_req_array( $field );

Takes a request object that must implement a params method which returns a hash ref. The method returns the value for $field from that hash. This method will always return a array ref. This method is wrapped by Catalystx::Usul::Encoding::mk_encoding_methods and as such is not called directly

_get_req_value

my $value = $self->_get_req_value( $field );

Takes a request object that must implement a params method which returns a hash ref. The method returns the value for $field from that hash. This method will always return a scalar. This method is wrapped by Catalystx::Usul::Encoding::mk_encoding_methods and as such is not called directly

Configuration and Environment

None

Diagnostics

None

Dependencies

CatalystX::Usul
CatalystX::Usul::Utils
Data::Validation
Scalar::Util

Incompatibilities

There are no known incompatibilities in this module.

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Copyright (c) 2008 Peter Flanigan. All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE