summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-03-14 06:05:12 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-03-14 06:05:12 +0000
commit43ebbcc41b5752e054eb1d7e78f1a5de5ba275af (patch)
treee78980b6d89e3a8b95845418a823683f8be94003
parent384dbc178876688925f672690e6eabb784ce6c0d (diff)
DBObject::AUTOLOAD known to be broken. Moved other modules to use named arguments. for DBObject calls
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@897 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-xLedgerSMB.pm14
-rw-r--r--LedgerSMB/DBObject.pm18
-rw-r--r--LedgerSMB/Employee.pm11
-rw-r--r--LedgerSMB/Location.pm12
-rw-r--r--LedgerSMB/Setting.pm5
5 files changed, 35 insertions, 25 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm
index 6a929b47..ab771eb1 100755
--- a/LedgerSMB.pm
+++ b/LedgerSMB.pm
@@ -41,6 +41,7 @@ package LedgerSMB;
sub new {
+ # This will probably be the last to be revised.
my $type = shift;
@@ -81,6 +82,7 @@ sub new {
sub debug {
+ # Use Data Dumper for this one.
my ($self, $file) = @_;
@@ -97,16 +99,16 @@ sub debug {
sub escape {
- my ($self, $str, $beenthere) = @_;
+ my ($self, $str) = @_;
+ my $regex = qr/([^a-zA-Z0-9_.-])/;
+ $str =~ s/$regex/sprintf("%%%02x", ord($1))/ge;
# for Apache 2 we escape strings twice
- if (($ENV{SERVER_SIGNATURE} =~ /Apache\/2\.(\d+)\.(\d+)/) && !$beenthere) {
- $str = $self->escape($str, 1) if $1 == 0 && $2 < 44;
+ if (($ENV{SERVER_SIGNATURE} =~ /Apache\/2\.(\d+)\.(\d+)/)) {
+ $str =~ s/$regex/sprintf("%%%02x", ord($1))/ge
+ if $1 == 0 && $2 < 44;
}
-
- $str =~ s/([^a-zA-Z0-9_.-])/sprintf("%%%02x", ord($1))/ge;
$str;
-
}
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm
index 5c07e15e..0a79590e 100644
--- a/LedgerSMB/DBObject.pm
+++ b/LedgerSMB/DBObject.pm
@@ -24,17 +24,20 @@ your software.
=cut
package LedgerSMB::DBObject;
-use LedgerSMB;
+use Scalar::Util;
+use base qw(LedgerSMB);
use strict;
use warnings;
-our @ISA = qw(LedgerSMB);
-
our $AUTOLOAD;
sub AUTOLOAD {
my ($self) = shift;
- $self->exec_method($AUTOLOAD, @_);
+ my $type = (Scalar::Util::reftype $self) =~ m/::(.*?)$/;
+ print "Type: $type\n";
+ $type =~ m/::(.*?)$/;
+ $type = lc $1;
+ $self->exec_method("$type" . "_" . $AUTOLOAD, @_);
}
sub new {
@@ -55,7 +58,10 @@ sub new {
sub exec_method {
my ($self) = shift @_;
- my ($funcname) = shift @_;
+ my %args = @_;
+ my $funcname = $args{funcname};
+ my @in_args = @{$args{args}};
+ my @call_args;
my $query =
"SELECT proname, proargnames FROM pg_proc WHERE proname = ?";
@@ -73,7 +79,7 @@ sub exec_method {
die;
}
my $m_name = $ref->{proname};
- my @call_args;
+
if ($args){
for my $arg (@proc_args){
diff --git a/LedgerSMB/Employee.pm b/LedgerSMB/Employee.pm
index bf22cb45..261d9578 100644
--- a/LedgerSMB/Employee.pm
+++ b/LedgerSMB/Employee.pm
@@ -41,29 +41,30 @@ sub AUTOLOAD {
my $AUTOLOAD = $LedgerSMB::Employee::AUTOLOAD;
$AUTOLOAD =~ s/^.*:://;
my $procname = "employee_$AUTOLOAD";
- $self->exec_method($procname, @_);
+ $self->exec_method(procname => "employee_$AUTOLOAD", args => \@_);
+ my @call_args;
}
sub save {
my $self = shift;
- my $hashref = shift @{$self->exec_method("employee_save")};
+ my $hashref = shift @{$self->exec_method(procname => "employee_save")};
$self->merge($hashref, 'id');
}
sub get {
my $self = shift;
- my $hashref = shift @{$self->exec_method("employee_get")};
+ my $hashref = shift @{$self->exec_method(procname => "employee_get")};
$self->merge($hashref, keys %{$hashref});
}
sub list_managers {
my $self = shift;
- $self->{manager_list} = $self->exec_method("employee_list_managers");
+ $self->{manager_list} = $self->exec_method(procname => "employee_list_managers");
}
sub search {
my $self = shift;
- $self->{search_results} = $self->exec_method("employee_search");
+ $self->{search_results} = $self->exec_method(procname => "employee_search");
}
1;
diff --git a/LedgerSMB/Location.pm b/LedgerSMB/Location.pm
index 05b38094..dc4b0123 100644
--- a/LedgerSMB/Location.pm
+++ b/LedgerSMB/Location.pm
@@ -42,23 +42,25 @@ sub AUTOLOAD {
my $AUTOLOAD = $LedgerSMB::Location::AUTOLOAD;
$AUTOLOAD =~ s/^.*:://;
my $procname = "location_$AUTOLOAD";
- $self->exec_method($procname, @_);
+ $self->exec_method(procname => "location_$AUTOLOAD", args => \@_);
}
sub save {
- $ref = shift @{$self->exec_method("location_save")};
+ $ref = shift @{$self->exec_method(procname =>"location_save")};
$self->merge($ref, 'id');
}
sub get {
- $ref = shift @{$self->exec_method('location_get')};
+ $ref = shift @{$self->exec_method(procname =>'location_get')};
$self->merge($ref, keys %{$ref});
}
sub search {
- $self->{search_results} = $self->exec_method('location_search');
+ $self->{search_results} =
+ $self->exec_method(procname => 'location_search');
}
sub list_all {
- $self->{search_results} = $self->exec_method('location_list_all');
+ $self->{search_results} =
+ $self->exec_method(procname => 'location_list_all');
}
diff --git a/LedgerSMB/Setting.pm b/LedgerSMB/Setting.pm
index bef80f60..2f439610 100644
--- a/LedgerSMB/Setting.pm
+++ b/LedgerSMB/Setting.pm
@@ -47,13 +47,12 @@ sub AUTOLOAD {
my $self = shift;
my $AUTOLOAD = $LedgerSMB::Setting::AUTOLOAD;
$AUTOLOAD =~ s/^.*:://;
- my $procname = "setting_$AUTOLOAD";
- $self->exec_method($procname, @_);
+ $self->exec_method(procname => "setting_$AUTOLOAD", args =>\@_);
}
sub get {
my $self = shift;
- my $hashref = shift @{$self->exec_method('setting_get')};
+ my $hashref = shift @{$self->exec_method(procname => 'setting_get')};
$self->merge($hashref, 'value');
}