[ic] Catalog self-test
Mike Heins
mike at perusion.com
Wed Sep 24 15:08:23 EDT 2003
Quoting Kevin Walsh (kevin at cursor.biz):
> Mike Heins [mike at perusion.com] wrote:
> > Quoting Marc Brevoort (marc.brevoort at armazemdedados.com):
> > > Some of the catalogs that I developed would benefit from running a self
> > > test.
> > >
> > > For example, checking for the presence of a certain stored procedure in
> > > the database and creating it when not present.
> > >
> > > Such a test would only need to be performed on catalog startup. Is this
> > > possible (we use 4.8.6)? It would be nice if this check would already
> > > have interchange functionality available.
> > >
> > You can do this type of thing in a Global UserTag, but it would have
> > no way of divining things from catalog configuration.
> >
> > Sounds like something Stefan could add to Jobs -- an on_catalog_init job.
> >
> It could be added as a new site configuration directive, as follows:
>
> interchange.cfg:
>
> GlobalSub <<EOS
> sub wrap_cataloginit {
> package Vend::Config;
>
> sub parse_cataloginit {
> my ($directive,$value) = @_;
> return undef unless $value =~ /yes/i;
>
> #
> # the following is an example of how to get access
> # to the site's configuration
> #
> ::logGlobal("vendroot=$C->{VendRoot}");
> 1;
> }
> }
> EOS
>
> AddDirective CatalogInit cataloginit
>
> catalog.cfg (at the end, when all other config is complete):
>
> CatalogInit Yes
Yes, that would work. I always seem to forget about AddDirective...when
I wrote it I thought it would be used more often than it seems to be.
>
> I have no idea whether database access would be possible with this
> sort of setup - it would have to be tried and experimented with.
I think you would have to just use DBI; without calling open_database()
none of the IC stuff will work.
> The parse_cataloginit() could simply call an external script to do
> some of the work.
>
> A solution as part of the Jobs system would be cleaner, of course.
>
This is pretty clean, I think.
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.513.523.7621 <mike at perusion.com>
"Even if you're on the right track, you'll get run over if you just
sit there." -- Will Rogers
More information about the interchange-users
mailing list