DBIx-DBStag

 view release on metacpan or  search on metacpan

DBIx/DBStag/Cookbook.pm  view on Meta::CPAN

data, using ubiq.cgi, which should come with your distribution. 

You may have to modify some of the directories below, depending on
your web server set up (we assume Apache here).

We want to create the CGI, and give it access to our templates:

  mkdir /usr/local/httpd/cgi-bin/cia
  cp templates/*.stg /usr/local/httpd/cgi-bin/cia
  cp `which ubiq.cgi` /usr/local/httpd/cgi-bin/cia
  chmod +x /usr/local/httpd/cgi-bin/cia/ubiq.cgi
  mkdir /usr/local/httpd/cgi-bin/cia/cache
  chmod 777 /usr/local/httpd/cgi-bin/cia/cache

Set up the environment for the CGI script. It must be able to see the
templates and the necessary perl libraries (if not installed
system-wide)

  cat > /usr/local/httpd/cgi-bin/cia/dbenv.pl
  $ENV{DBSTAG_DBIMAP_FILE} = "./resources.conf";
  $ENV{DBSTAG_TEMPLATE_DIRS} = ".:./templates:/usr/local/share/sql/templates";
  $ENV{STAGLIB} = "/users/me/lib/DBIx-DBStag:/users/me/lib/stag";

cgi-bin/ubiq.cgi  view on Meta::CPAN

	my $n = shift;
	my @matches = grep {$_->name eq $n} @$templates;
	die "looking for $n, got @matches" unless @matches == 1;
	$template = shift @matches;
	$varnames = $template->get_varnames;
	conn;
	my $cachef = "./cache/cache-$dbname-$n";
	$example_input = $template->get_example_input($dbh,
						      $cachef,
						      1);
	system("chmod 777 $cachef");
	$template_name = $n;
    };				# end of sub: settemplate

    # ++++++++++++++++++++++++++++++++++++++++++++++++++
    # resultbox
    #
    #
    # ++++++++++++++++++++++++++++++++++++++++++++++++++
    sub resultbox;		#
    *resultbox = sub {

cgi-bin/ubiq.cgi  view on Meta::CPAN

	    }
            if ($no_query_params_set) {
                $errmsg = h2("No Query Constraints Set");
            }
            else {
		# kill killer queries
		my $tag = "kill$$"."TAG";
		my $tagf = "/tmp/$tag";
		my $t=time;
		print STDERR "Launched killer $tagf at $t\n";
		system("touch $tagf && chmod 777 $tagf && sleep 15 && test -f $tagf && kill -9 $$ && rm $tagf &");
                if (is_format_flat) {
                    $rows =
                      $dbh->selectall_rows(
                                           -template=>$template,
                                           -bind=>\%exec_argh,
                                          );
                } else {
                    $stag =
                      $dbh->selectall_stag(
                                           -template=>$template,

scripts/stag-template2bin.pl  view on Meta::CPAN


# cjm@fruitfly.org

use strict;
use Carp;
use Getopt::Long;

my $bindir = $ENV{DBSTAG_TEMPLATE_BINDIR};
my $force;
my $quiet;
my $chmod = "777";
GetOptions("bindir|b=s"=>\$bindir,
	   "force"=>\$force,
	   "quiet|q"=>\$quiet,
	   "chmod=s"=>\$chmod,
	  );

if (!$bindir) {
    $bindir = "/usr/local/bin";
    unless ($force) {
	print "You did not specify -b (path to template generated binaries) on the command line\n or in \$DBSTAG_TEMPLATE_BINDIR";
	print "I will use this: $bindir\n";
	print "\nOK? [yes/no] ";
	my $ok = <STDIN>;
	if ($ok !~ /^y/i) {

scripts/stag-template2bin.pl  view on Meta::CPAN


foreach my $f (@ARGV) {
    my @parts = split(/\//, $f);
    my $name = $parts[-1];
    if ($name =~ s/\.stg$//) {
	my $bin = "$bindir/$name";
	open(F, ">$bin") || die("can't write to $bin");
	print F "#!/bin/sh\n";
	print F "selectall_xml.pl -t $name \$\@\n";
	close(F);
	system("chmod $chmod $bin");
	print "$bin\n" unless $quiet;
    }
    else {
	"$f doesn't look like a template (no .stg suffix)";
    }
}



( run in 0.854 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )