On Mon, Feb 03, 2003 at 04:49:00AM -0000, Greg Zartman <[EMAIL PROTECTED]> wrote:
> 
> I have a quick question about esmith::templates::processTemplate:
> 
> The perldoc states the following:  "Finally, variables from additional
> databases are usually gotten via the esmith::DB->as_hash feature."  Does
> this mean that esmith::DB::db methods are available to code embeded in
> template fragments or that the esmith::DB->as_hash method is the regular way
> of doing things?

All values from the "configuration" DB come for free as a multi-level
hashes, with the hash name matching the configuration database key,
so you can do things like this:

{
    return "" (unless $sshd{'status'} eq 'public');
}

I.e. you do not need to open/read the main "configuration" DB - it is
given to you as a _read-only_ hash.

If you want access to other DBs, the cleanest way is an initialisation
fragment, e.g. 00setup:

{
    use esmith::DomainsDB;

    $domainsdb = esmith::DomainsDB->open_ro();
    
    %domains = defined $domainsdb ? $domainsdb->as_hash : ();
}

and you can then make use of %domains in later fragments:

10something

{
    foreach my $key (keys %domains)
    {
        if ( $domains{$key}{'Content'} eq 'Public' )
        {
            ... 
        }
    }
}

One of the many reasons why the esmith::config and esmith::db ways
of accessing the databases are deprecated.

Gordon
--
 Gordon Rowell                         [EMAIL PROTECTED]
 Director, Engineering
 Network Server Solutions Group        http://www.e-smith.com/
 Mitel Networks Corporation            http://www.mitel.com/smallbusiness/


--
Please report bugs to [EMAIL PROTECTED]
Please mail [EMAIL PROTECTED] (only) to discuss security issues
Support for registered customers and partners to [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Searchable archive at http://www.mail-archive.com/devinfo%40lists.e-smith.org

Reply via email to