[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [897] trunk



Revision: 897
          http://svn.sourceforge.net/ledger-smb/?rev=897&view=rev
Author:   einhverfr
Date:     2007-03-13 23:05:12 -0700 (Tue, 13 Mar 2007)

Log Message:
-----------
DBObject::AUTOLOAD known to be broken.  Moved other modules to use named arguments. for DBObject calls

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject.pm
    trunk/LedgerSMB/Employee.pm
    trunk/LedgerSMB/Location.pm
    trunk/LedgerSMB/Setting.pm
    trunk/LedgerSMB.pm

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2007-03-14 03:53:06 UTC (rev 896)
+++ trunk/LedgerSMB/DBObject.pm	2007-03-14 06:05:12 UTC (rev 897)
@@ -24,17 +24,20 @@
 =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 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,8 +79,8 @@
 		die;
 	}
 	my $m_name = $ref->{proname};
-	my @call_args;
 
+
 	if ($args){
 		for my $arg (@proc_args){
 			if ($arg =~ s/^in_//){

Modified: trunk/LedgerSMB/Employee.pm
===================================================================
--- trunk/LedgerSMB/Employee.pm	2007-03-14 03:53:06 UTC (rev 896)
+++ trunk/LedgerSMB/Employee.pm	2007-03-14 06:05:12 UTC (rev 897)
@@ -41,29 +41,30 @@
 	my $AUTOLOAD = $LedgerSMB::Employee::AUTOLOAD;
 	$AUTOLOAD =~ s/^.*:://;
 	my $procname = "employee_$AUTOLOAD";
-	$self->exec_method($procname, @_);
+	$self->exec_method(procname => "employee_$AUTOLOAD", args => ..hidden..);
+	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;

Modified: trunk/LedgerSMB/Location.pm
===================================================================
--- trunk/LedgerSMB/Location.pm	2007-03-14 03:53:06 UTC (rev 896)
+++ trunk/LedgerSMB/Location.pm	2007-03-14 06:05:12 UTC (rev 897)
@@ -42,23 +42,25 @@
 	my $AUTOLOAD = $LedgerSMB::Location::AUTOLOAD;
 	$AUTOLOAD =~ s/^.*:://;
 	my $procname = "location_$AUTOLOAD";
-	$self->exec_method($procname, @_);
+	$self->exec_method(procname => "location_$AUTOLOAD", args => ..hidden..);
 }
 
 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');
 }

Modified: trunk/LedgerSMB/Setting.pm
===================================================================
--- trunk/LedgerSMB/Setting.pm	2007-03-14 03:53:06 UTC (rev 896)
+++ trunk/LedgerSMB/Setting.pm	2007-03-14 06:05:12 UTC (rev 897)
@@ -47,13 +47,12 @@
 	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 =>..hidden..);
 }
 
 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');
 }
 

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-03-14 03:53:06 UTC (rev 896)
+++ trunk/LedgerSMB.pm	2007-03-14 06:05:12 UTC (rev 897)
@@ -41,6 +41,7 @@
 
 
 sub new {
+	# This will probably be the last to be revised.
 
 	my $type = shift;
 
@@ -81,6 +82,7 @@
 
 
 sub debug {
+	# Use Data Dumper for this one.
 
 	my ($self, $file) = @_;
 
@@ -97,16 +99,16 @@
 
 
 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;
-
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.