Michael Peters > Smolder-1.51 > Smolder::Control



Annotate this POD


New  7
Open  15
View/Report Bugs
Source   Latest Release: Smolder-1.52



Shows a FORBIDDEN message if a user tries to act on a project that is not marked as 'forbibben'




This module serves as a base class for all controller classes in smolder. As such it defines some behavior with regard to templates, form validation, etc and provides some utility methods for accessing this data.



Will be true if we are running under Apache2/mod_perl2

    if( $Smolder::Control::MP2 ) {



This method will return the Smolder::DB::Developer object that this request is associated with, if it's not a public request. This information is pulled from the $ENV{REMOTE_USER} which is set by mod_auth_tkt.


This method, will return whether the current user making the request has permissions to view the given a Smolder::DB::Project object.


This method will return the Smolder::DB::Projects that are marked as 'public'.


A simple run mode to display an error message. This should not be used to show expected messages, but rather to display un-recoverable and un-expected occurances.


This method is provided by the TT Plugin plugin. It is used to choose and process the Template Toolkit templates. If no name is provided for the template (as the first argument) then the package name and the run mode will be used to determine which template to use. For instance:

    $self->tt_process({ arg1 => 'foo', arg2 => 'bar' });

If this was done in the Smolder::Control::Foo package for the 'list' run mode then it would use the templates/Foo/list.tmpl template. If you want to use a different template then you can explicitly specify it as well:

    $self->tt_process('Foo/list.tmpl', { arg1 => 'foo', arg2 => 'bar' });

See TEMPLATE_CONFIGURATION for more details.


This is a convenience method to get access to the last Data::FormValidator messages that were created due to a form validation failure. These messages are simply flags indicating which fields were missinage, which failed their constraints and which constraints failed.

See "FORM VALIDATION" for more information.


This method takes an array ref of values to be returned to an AJAX Autocomplete field.


This method will take the URL and add the smolder version number to the front so that caching can be more aggressive. This is only done if it's not a developer install, so that developers aren't frustrated by having to fight with browser caches.


Adds an message that will be displayed to the user. Takes the following name-value pairs;


The text of the message to send. It will be HTML escaped, so it must not contain HTML.


The type of the message, either info or warning. By default info is assumed.


As mentioned above, template access/control is performed through the CGI::Application::Plugin::TT plugin. The important are the settings used:

The search path of templates is lib/Smolder/Data/templates
All templates are wrapped with the templates/wrapper.tmpl template unless the ajax CGI param is set.
Recursion is allowed for template INCLUDE and PROCESS
The following FILTERS are available to each template:

Given a percentage (usually of passing tests to the total number run) this filter will return an HTML RGB color suitable for a colorful indicator of performance.


For form validation we use CGI::Application::Plugin::ValidateRM which in turn uses Data::FormValidator. We further customize the validation by providing the untaint_all_constraints option which means that some values will become "transformed" (dates will become DateTime objects, etc).

We also customize the resulting hash of messages that is generated upon validation failure. All failed and missing constraints will become err_$field. All fields that were present but failed a constraint will become invalid_$name (where $name is the name of the field or the name of the constraint if it's named). And all missing constraints will have a missing_$field message. Also, the 'any_errors' message will be set.

syntax highlighting: