CGI::Application::Bouquet::Rose - Generate a set of CGI::Application-based classes


Security Warning

The generated code allows SQL to be entered via a CGI form. This means you absolutely must restrict usage of the generated code to trusted persons.

Sample Code

        Step 1: Run the steps from the synopsis for Rose::DBx::Bouquet.
        Remember, the current dir /must/ still be Local-Wines-1.29/.

        Step 2: Edit:
        o lib/Rose/DBx/Bouquet/.htcgi.bouquet.conf
        o lib/Local/Wine/.htwine.conf

        Step 3: Run the third code generator (see scripts/rosy):
        shell> scripts/ > scripts/

        Step 4: This is the log from
        doc_root:         /var/www
        exclude:         ^(?:information_schema|pg_|sql_)
        module:          Local::Wines
        output_dir:      ./lib
        prefix:          Local::Wines::CGI
        remove:          0
        tmpl_path:       ../CGI-Application-Bouquet-Rose/templates
        verbose:         1
        Working dir:     lib/Local/Wine/CGI
        Rose::DB module: Local::Wines::Base::DB
        Processing tables:
        Table: grape. Module: Grape
        Table: vineyard. Module: Vineyard
        Table: wine. Module: Wine
        Table: wine_maker. Module: WineMaker
        Processing templates:
        Path to run-time templates: /var/www/assets/templates/local/wine
        Creating htdocs/assets/templates/local/wine
        Copying htdocs/assets/templates/local/wine/content.tmpl
        Copying htdocs/assets/templates/local/wine/
        Copying htdocs/assets/templates/local/wine/search.form.tmpl
        Copying htdocs/assets/templates/local/wine/
        Creating htdocs/search
        Creating htdocs/search/wine.fcgi
        Creating lib/Local/Wine/CGI
        Creating lib/Local/Wine/CGI/
        Creating lib/Local/Wine/CGI/
        Creating lib/Local/Wine/CGI/
        Creating lib/Local/Wine/CGI/CGIApp

        Step 5: Run the fourth code generator:
        shell> perl -Ilib scripts/

        Step 6: This is the log from
        Processing CGI::Application-based modules:
        Updating htdocs/assets/templates/local/wine/
        Generated lib/Local/Wine/CGI/CGIApp/
        Generated lib/Local/Wine/CGI/CGIApp/
        Generated lib/Local/Wine/CGI/CGIApp/
        Generated lib/Local/Wine/CGI/CGIApp/

        Step 7: Install the templates:
        shell> scripts/

        Step 8: Install Local::Wines
        shell> perl Build.PL
        shell> perl Build
        shell> sudo perl Build install

        Step 9: Install the FastCGId script:
        shell> sudo cp -r htdocs/search /var/www
        shell> sudo chmod a+x /var/www/search/wine.fcgi

        Step 10: Patch httpd.conf (see httpd/httpd.conf.patch):
        LoadModule fcgid_module modules/
        <Location /search>
            SetHandler fcgid-script
            Options ExecCGI
                Order deny,allow
            Deny from all
            Allow from

        Step 11: Restart Apache:
        shell> sudo /etc/init.d/apache2 restart

        Step 12: Use a web client to hit
        Start searching!


CGI::Application::Bouquet::Rose is a pure Perl module.

It uses a database schema, and code generated by Rose::DBx::Bouquet, to generate CGI::Application-based source code.

The result is an CGI script which implements a search engine customised to the given database.

At run-time, a menu of database tables is displayed in the web client, and when one is chosen, a CGI form is displayed which allows the user to enter any value for any column. These values are the search keys, and may include SQL tokens such as '%' and '_'.

The N rows returned by the search are displayed as a HTML table, and you can page back and forth around this data set.

This documentation uses Local::Wines as the basis for all discussions. See the FAQ for the availability of the Local::Wines distro.


This module is available as a Unix-style distro (*.tgz).

See for details.

See for help on unpacking and installing.

Constructor and initialization

new(...) returns an object of type CGI::Application::Bouquet::Rose.

This is the class contructor.

Usage: CGI::Application::Bouquet::Rose -> new().

This method takes a hashref of options.

Call new() as new({option_1 => value_1, option_2 => value_2, ...}).

Available options:


This takes a directory name, which is the name of your web server document root.

If not specified, the value defaults to the value in lib/Rose/DBx/Bouquet/.htcgi.bouquet.conf.

The default value is /var/www, which suits me.


This takes a regexp (without the //) of table names to exclude.

Code is generated for each table which is not excluded.

If not specified, the value defaults to the value in lib/CGI/Application/Bouquet/Rose/.htcgi.bouquet.conf.

The default value is ^(?:information_schema|pg_|sql_), which suits users of Postgres.


This takes the path where the output modules are to be written.

If not specified, the value defaults to the value in lib/CGI/Application/Bouquet/Rose/.htcgi.bouquet.conf.

The default value is ./lib.


This is the path to the CGI::Application::Bouquet::Rose template directory.

These templates are input to the code generation process.

If not specified, the value defaults to the value in lib/CGI/Application/Bouquet/Rose/.htcgi.bouquet.conf.

The default value is ../CGI-Application-Bouquet-Rose/templates.

Note: The point of the '../' is because I assume you have done 'cd Local-Wines-1.29' or the equivalent for whatever module you are working with.


This takes either a 0 or a 1.

Write more or less progress messages to STDERR, during code generation.

The default value is 0.


Availability of Local::Wines

Download Local::Wines from

The schema is at:

CGI::Application::Bouquet::Rose ships with in the bin/ directory, whereas Local::Wines ships with various programs in the scripts/ directory.

Files in the /bin directory get installed via 'make install'. Files in the scripts/ directory are not intended to be installed; they are only used during the code-generation process.

Note also that 'make install' installs lib/CGI/Application/Bouquet/Rose/.htcgi.bouquet.conf, and - depending on your OS - you may need to change its permissions in order to edit it.

Minimum modules required when replacing Local::Wines with your own code

Short answer:


You can implement this module any way you want. It just has to provide the same methods.


This module will use the default type and domain, where 'type' and 'domain' are Rose concepts.


Long answer:

See the docs for Local::Wines.

Why is Local::Wines not on CPAN?

To avoid the problem of people assuming it can be downloaded and used just like any other module.

How does this module interact with Rose?

See the FAQ for <Rose::DBx::Bouquet>.

What is the syntax used for search terms at run-time?

SQL. So, to find the name of a grape starting with S, you type S%.

And yes, I know there is the potential for sabotage with such a system. This means you absolutely must restrict usage of the generated code to trusted persons.

Can I search in Primary Keys?

Yes. They are text fields like any other column.

What happens when I enter several seach terms on the CGI form?

The values are combined with 'and'. There is no provision for using 'or'.

Do you ever write to the database?


My intention is to provide CRUD features one day.

How do you handle sessions?

Sessions are not implemented, simply because they are not needed.

The only data which needs to be passed from CGI form to form is the database paging state, and that is done with a hidden form field.

How are HTML entities handled?

Output from the database is encoded using HTML::Entities::Interpolate.

A note on option management

You will see a list of option names and default values near the top of this file, in the hash %_attr_data.

Some default values are undef, and some are scalars.

My policy is this:

If the default is undef...

Then the real default comes from a config file, and is obtained via the *::Config module.

If the default is a scalar...

Then that scalar is the default, and cannot be over-ridden by a value from a conf file.

But why have such a method of handling options?

Because I believe it makes sense for the end user (you, dear reader), to have the power to change configuration values without patching the source code. Hence the conf file.

However, for some values, I do not think it makes sense to do that. So, for those options, the default value is a scalar in the source code of this module.

Is this option arrangement permanent?


Options whose defaults are already in the config file will never be deleted from that file.

However, options not currently in the config file may be made available via the config file, depending on feedback.

Also, the config file is an easy way of preparing for more user-editable options.

Method: log($message)

If new() was called as new({verbose => 1}), write the message to STDERR.

If new() was called as new({verbose => 0}) (the default), do nothing.

Method: run()

Do everything.

See bin/ for an example of how to call run().

Machine-Readable Change Log

The file Changes was converted into Changelog.ini by Module::Metadata::Changes.

Version Numbers

Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.



Email the author, or log a bug on RT:


CGI::Application::Bouquet::Rose was written by Ron Savage <> in 2008.



Australian copyright (c) 2008, Ron Savage.

        All Programs of mine are 'OSI Certified Open Source Software';
        you can redistribute them and/or modify them under the terms of
        The Perl License, a copy of which is available at: