Username Password
Bookmark and Share

Mason Script Wobject

The Mason Script wobject provides the ability to run perl-based Mason components (in standalone mode) as a WebGUI wobject. This wobject brings together the power of WebGUI with the flexibility of scripted server pages.

Mason is a server side scripting environment which provides a PHP, ASP, JSP like environment in the perl language. Full documentation on Mason can be found at Please review the documentation found there, paying close attention to the sections on running Mason as a standalone script as certain functionality (e.g., $m variable) is not available in the MasonScript wobject.

A Mason script consists of HTML with embedded perl code. There are a variety of different mechanisms for doing such, but the most common are:

  • a single line of any perl code (line starts with a % to indicate that this line is perl code and not HTML)
  • perl expression/variable within <% %> block as in <% $myVar %>
  • perl block: <%perl> MULTI-LINE PERL CODE HERE </%perl>

An example of a simple MasonScript wobject utilizing these mechanisms is as follows:


print "world";
my $today = "day";

% print "is a beautiful ";
<% $today %>

<br>WobjectId = <% $session{wobject}{wobjectId} %>
<br>Username = <% $session{user}{username} %>
This would yield
hello, world
Today is a beautiful day
WobjectId = RnEvWuXFQ9LDjUaGhk-wlg
Username = Admin

Please note that the WebGUI %session variable is available to your MasonScript wobjects and has been further extended to include the following wobject specific values:

  • $session{wobject}{wobjectId}
  • $session{wobject}{namespace}
  • $session{wobject}{title}
  • $session{wobject}{ownerId}
  • $session{wobject}{groupIdView}
  • $session{wobject}{groupIdEdit}

Mason Script code has full access to the WebGUI and Perl environment (including the ability to read files and use Perl modules). Therefore, privileges to edit Mason Script wobjects is provided only to WebGUI Admins or members of a Script Editors group (groupId indicated by the optional WebGUI conf file setting of script_editors_group as in script_editors_group = 3).

The Mason Script wobject has been tested on the Windows 6.2.7 zip-and-go. A 5.5.x version is also available, but lacks templates, internationlization, and/or help files.

Comments and questions welcome, but I have limited time to pursue enhancements. However, I'm also toying with reimplementing this wobject with Text::MicroMason instead of the full blown HTML::Mason for security reasons. Apparently, MicroMason is more lightweight, can be configured to support HTML::Template like syntax, and can be configured to run in a safe mode sandbox. If you have any experience with Text::MicroMason, please let me know.

Special thanks to josh_johnson and scb for their feature/functionality suggestions. Special thanks to raidro for canEdit bugfixs and data_dir suggestion


Follow included instructions. HTML::Mason modules is included in tar file. However, if you don't seem to have all prequisites, you my try installing it from CPAN issuing: perl -MCPAN -e "install HTML::Mason"


MasonScript 1.0.2 - December 3, 2004
To upgrade, copy the file overtop the existing file
Bugfix for canEdit call in formatErrorMesssage()

MasonScript 1.0.1 - December 2, 2004
To upgrade, copy the file overtop the existing file
Bugfix for canEdit call and adds ability to specify mason data_dir in WebGUI conf file. Ability to specify mason comp_root in WebGUI conf file still available from 1.0.0

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
4raidro: "
I have played arround a little bit with the Wobject and found the following bug:

    $var{canEdit} = WebGUI::Wobject::canEdit($self->get("wobjectId"));

This line tests, if the wobjectID is editable, and WebGUI is coming up with a fatal error.

Please change it to:

 $var{canEdit} =$self->canEdit;

Moreover, you should add a mason data directory to the interpreter, so that mason can compile/cache its components.

Last, but not least: Great!!!!

4edv: "Thanks.  Although I was unable to reproduce the fatal error, I've implemented a fix in 1.0.1.  Please let me know if you still experience problems.  Also, I've added the ability for you to specify the data_dir via an optional mason_data_dir entry in your WebGUI conf file.  You may also indicate the mason_comp_root as well.

I do appreciate your feedback.  Please let me know if there are other ways to improve this wobject.

4raidro: "Found a second canEdit bug during playing around with mason components:

sub formatErrorMessage {
    my ($output, $errmsg, $wobjectId);
    $errmsg = shift || '';
    $wobjectId = shift || '';
    if ($session{var}{adminOn} && WebGUI::Wobject::canEdit($wobjectId)) {..."
2edv: "I'm not getting any errors so I'm confused as to why you are. What platform are you running on? Can you post the error messages here, including the webgui log stacktrace?

4raidro: "My sytems are running on Gentoo linux.

However this has nothing todo with the bug. I have set wobjects privileges on some root trees. If an error in the mason components occur,  the method  formatErrorMessage is called. formatErrorMessage is calling WebGUI::Wobject::canEdit with the wobjectID. This is the bug!!!

The method should be called with the wobject and not the wobjectId  (have a look on the API in

My Wobject privileges are not equal to 1. Therefore  $self->get('wobjectId') is called from WebGUI::Wobject::canEdit.

A fatal error  comes up, since Your argument, i.e. $self, was the wobjectId instead of the wobject.

Some minor advice: have a look on  the  modules, if You call methods. The API has changed dramatically in WebGUI.

4edv: "Yes, this was hastily ported from a working 5.5 wobject.  Sorry for the problems and thanks for your assistance.

Still not sure why I wasn't getting any fatals...  Do you still get them with version"
DownloadMasonScript-1.0.2.tar.gz MasonScript-1.0.2.tar.gz
LinksNo Support Offered
Statistics Downloads: 702
Views: 9330
Rating: 4
Updated: 8/12/2005
Keywords Assets utility
NavigationBack to the Bazaar
© 2022 Plain Black Corporation | All Rights Reserved