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

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



Revision: 871
          http://svn.sourceforge.net/ledger-smb/?rev=871&view=rev
Author:   einhverfr
Date:     2007-03-09 15:15:56 -0800 (Fri, 09 Mar 2007)

Log Message:
-----------
Fixing numerous issues with new orm code

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

Added Paths:
-----------
    trunk/employee.pl
    trunk/location.pl

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2007-03-09 23:15:17 UTC (rev 870)
+++ trunk/LedgerSMB/DBObject.pm	2007-03-09 23:15:56 UTC (rev 871)
@@ -29,14 +29,17 @@
 no strict 'refs';
 use warnings;
 
..hidden.. = (LedgerSMB);
+our @ISA = qw(LedgerSMB);
 
 sub new {
 	my $lsmb = shift @_;
-	if (! $lsmb->isa(LedgerSMB)){
+	my $self = {};
+	if (! $lsmb->isa('LedgerSMB')){
 		$self->error("Constructor called without LedgerSMB object arg");
-	my $self = {};
-	for $attr (keys $lsmb){
+	}
+
+	my $attr;
+	for $attr (keys %{$lsmb}){
 		$self->{$attr} = $lsmb->{$attr};
 	}
 	bless $self;
@@ -49,34 +52,36 @@
 
 	my $query = 
 		"SELECT proname, proargnames FROM pg_proc WHERE proname = ?";
-	my $sth = $self->{__dbh}->prepare($query);
+	my $sth = $self->{dbh}->prepare($query);
 	$sth->execute($funcname);
 	my $ref;
 
-	$ref = $sth->fetchrow_hashref(NAME_lc);
+	$ref = $sth->fetchrow_hashref('NAME_lc');
+	my $args = $ref->{proargnames};
+	$args =~ s/\{(.*)\}/$1/;
+	my @proc_args = split /,/, $args;
+	print "Ref: $ref\n";
+	print "Args: $ref->{proargnames}\n";
 
 	if (!$ref){ # no such function
-		$self->error($locale->text("No such function: ") .$funcname;
+		$self->error("No such function: ", $funcname);
 		die;
 	}
 	my $m_name = $ref->{proname};
-	my $args = $ref->{proargnames};
-	my @proc_args;
 
-	if ($m_name ~= s/$name\_//){
-		push @{$self->{__methods}}, $m_name;
-		if ($args){
-			for $arg (@$args){
-				if ($arg =~ s/^in_//){
-					push @proc_args, $ref->{$arg};
-				}
+	if ($args){
+		for my $arg (@proc_args){
+			if ($arg =~ s/^in_//){
+				print "Arg: $arg\n";
+				push @proc_args, $self->{$arg};
 			}
 		}
-		else {
-			@proc_args = @_;
-		}
 	}
+	else {
+		@proc_args = @_;
+	}
+	print "Arg2s: @_ \n";
 	$self->callproc($funcname, @proc_args);
 }
 
-
+1;

Modified: trunk/LedgerSMB/Employee.pm
===================================================================
--- trunk/LedgerSMB/Employee.pm	2007-03-09 23:15:17 UTC (rev 870)
+++ trunk/LedgerSMB/Employee.pm	2007-03-09 23:15:56 UTC (rev 871)
@@ -33,33 +33,34 @@
 use LedgerSMB::DBObject;
 our $VERSION = '1.0.0';
 
..hidden.. = (LedgerSMB::DBObject);
+our @ISA = qw(LedgerSMB::DBObject);
 
 
 sub AUTOLOAD {
+	my $self = shift;
 	my $procname = "employee_$LedgerSMB::Employee::Autoload";
-	$self->exec_method($procname);
+	$self->exec_method($procname, @_);
 }
 
 sub save {
-	my $hashref = shift ($self->exec_method("employee_save"));
+	my $self = shift;
+	my $hashref = shift @{$self->exec_method("employee_save")};
 	$self->merge($hashref, 'id');
 }
 
 sub get {
-	my $hashref = shift ($self->exec_method("employee_get"));
-	$self->merge($hashref, keys $hashref);
+	my $self = shift;
+	my $hashref = shift @{$self->exec_method("employee_get")};
+	$self->merge($hashref, keys %{$hashref});
 }
 
-sub delete {
-	$self->exec_method("employee_delete");
-}
-
 sub list_managers {
+	my $self = shift;
 	$self->{manager_list} = $self->exec_method("employee_list_managers");
 }
 
 sub search {
+	my $self = shift;
 	$self->{search_results} = $self->exec_method("employee_search");
 }
 

Modified: trunk/LedgerSMB/Location.pm
===================================================================
--- trunk/LedgerSMB/Location.pm	2007-03-09 23:15:17 UTC (rev 870)
+++ trunk/LedgerSMB/Location.pm	2007-03-09 23:15:56 UTC (rev 871)
@@ -34,7 +34,7 @@
 use LedgerSMB::DBObject;
 our $VERSION = '1.0.0';
 
..hidden.. = (LedgerSMB::DBObject);
+our @ISA = qw(LedgerSMB::DBObject);
 
 sub AUTOLOAD {
 	my $procname = "location_$LedgerSMB::Location::Autoload";
@@ -48,7 +48,7 @@
 
 sub get {
 	$ref = shift @{$self->exec_method('location_get')};
-	$self->merge($ref, keys $ref);
+	$self->merge($ref, keys %{$ref});
 }
 
 sub search {

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-03-09 23:15:17 UTC (rev 870)
+++ trunk/LedgerSMB.pm	2007-03-09 23:15:56 UTC (rev 871)
@@ -525,16 +525,18 @@
 }
 
 sub callproc {
+	my $self = shift @_;
 	my $procname = shift @_;
 	my $argstr = "";
 	my @results;
-	for (1 .. $#_){
+	for (1 .. scalar @_){
 		$argstr .= "?, ";
 	}
 	$argstr =~ s/\, $//;
-	$query = "SELECT * FROM $procname";
-	$query =~ s/\(\)/$argstr/;
+	$query = "SELECT * FROM $procname()";
+	$query =~ s/\(\)/($argstr)/;
 	my $sth = $self->{dbh}->prepare($query);
+	$sth->execute(@_);
 	while (my $ref = $sth->fetchrow_hashref(NAME_lc)){
 		push @results, $ref;
 	}

Added: trunk/employee.pl
===================================================================
--- trunk/employee.pl	                        (rev 0)
+++ trunk/employee.pl	2007-03-09 23:15:56 UTC (rev 871)
@@ -0,0 +1,2 @@
+#!/usr/bin/perl
+require "menu.pl";


Property changes on: trunk/employee.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/location.pl
===================================================================
--- trunk/location.pl	                        (rev 0)
+++ trunk/location.pl	2007-03-09 23:15:56 UTC (rev 871)
@@ -0,0 +1,2 @@
+#!/usr/bin/perl
+require "menu.pl";


Property changes on: trunk/location.pl
___________________________________________________________________
Name: svn:executable
   + *


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