From 1676739b17b4e65414e700f5f057a576b704e4fa Mon Sep 17 00:00:00 2001 From: Brian Read Date: Wed, 27 Nov 2024 20:11:31 +0000 Subject: [PATCH] mopve opening DBs into routines so that caching is avoided --- Targets/Letsencrypt/Letsencrypt.pm | 2 +- Templates/controller.pm.tem | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Targets/Letsencrypt/Letsencrypt.pm b/Targets/Letsencrypt/Letsencrypt.pm index b96a77f..55dc60b 100644 --- a/Targets/Letsencrypt/Letsencrypt.pm +++ b/Targets/Letsencrypt/Letsencrypt.pm @@ -331,7 +331,7 @@ sub do_display { # the value of trt will tell you which panel has returned if (! $trt){ - my $trt = $c->param('trt') || 'LIST'; #Indicates where to go now + $trt = $c->param('trt') || 'LIST'; #Indicates where to go now } # Now add in the params from the selected row from the table diff --git a/Templates/controller.pm.tem b/Templates/controller.pm.tem index 1a3d19a..9a259d7 100644 --- a/Templates/controller.pm.tem +++ b/Templates/controller.pm.tem @@ -43,12 +43,6 @@ use esmith::HostsDB; use esmith::DomainsDB; -#The most common ones -our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); -our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); -our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); -our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); -our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); require '/usr/share/smanager/lib/SrvMngr/Controller/${PackageName}-Custom.pm'; #The code that is to be added by the developer @@ -67,6 +61,13 @@ sub main { my $c = shift; $c->app->log->info( $c->log_req ); + #The most common ones + $cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); + $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); + $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); + $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); + $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); + my %${prefix}_data = (); my $title = $c->l('${prefix}_${MenuDescription}'); my $modul = ''; @@ -131,6 +132,13 @@ sub do_update { $c->app->log->info($c->log_req); my $modul = ''; + #The most common ones + $cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); + $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); + $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); + $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); + $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); + my %${prefix}_data = (); my $title = $c->l('${prefix}_${MenuDescription}'); @@ -220,6 +228,13 @@ sub do_display { my ($c,$trt) = @_; $c->app->log->info($c->log_req); + + #The most common ones + $cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); + $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); + $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); + $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); + $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); my %${prefix}_data = (); my $title = $c->l('${prefix}_${MenuDescription}');