[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [898] trunk
- Subject: SF.net SVN: ledger-smb: [898] trunk
- From: ..hidden..
- Date: Wed, 14 Mar 2007 11:09:59 -0700
Revision: 898
http://svn.sourceforge.net/ledger-smb/?rev=898&view=rev
Author: einhverfr
Date: 2007-03-14 11:09:59 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
More documentation to DBObject, changed constructor format to use named params, and consolidated conditionals in LedgerSMB::escape
Modified Paths:
--------------
trunk/LedgerSMB/DBObject.pm
trunk/LedgerSMB/Employee.pm
trunk/LedgerSMB.pm
Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm 2007-03-14 06:05:12 UTC (rev 897)
+++ trunk/LedgerSMB/DBObject.pm 2007-03-14 18:09:59 UTC (rev 898)
@@ -8,8 +8,17 @@
=head1 METHODS
-=item find_method ($hashref, $function_name, @args)
+=item new ($class, base => $LedgerSMB::hash)
+This is the base constructor for all child classes. It must be used with base
+argument because this is necessary for database connectivity and the like.
+
+Of course the base object can be any object that inherits LedgerSMB, so you can
+use any subclass of that. The per-session dbh is passed between the objects
+this way as is any information that is needed.
+
+=item exec_method ($self, procname => $function_name, args => ..hidden..)
+
=item merge ($hashref, @attrs)
copies @attrs from $hashref to $self.
@@ -33,26 +42,25 @@
sub AUTOLOAD {
my ($self) = shift;
- my $type = (Scalar::Util::reftype $self) =~ m/::(.*?)$/;
+ my $type = Scalar::Util::blessed $self;
+ $type =~ m/::(.*?)$/;
+ $type = lc $1;
print "Type: $type\n";
- $type =~ m/::(.*?)$/;
- $type = lc $1;
- $self->exec_method("$type" . "_" . $AUTOLOAD, @_);
+ $self->exec_method(procname => "$type" . "_" . $AUTOLOAD, args => ..hidden..);
}
sub new {
- my $self = shift @_;
- my $lsmb = shift @_;
- if (! $lsmb->isa('LedgerSMB')){
+ my $class = shift @_;
+ my %args = @_;
+ my $base = $args{base};
+ my $self = bless {}, $class;
+ if (! $base->isa('LedgerSMB')){
$self->error("Constructor called without LedgerSMB object arg");
}
- $self = {};
my $attr;
- for $attr (keys %{$lsmb}){
- $self->{$attr} = $lsmb->{$attr};
- }
- bless $self;
+ $self->merge($base);
+ $self;
}
Modified: trunk/LedgerSMB/Employee.pm
===================================================================
--- trunk/LedgerSMB/Employee.pm 2007-03-14 06:05:12 UTC (rev 897)
+++ trunk/LedgerSMB/Employee.pm 2007-03-14 18:09:59 UTC (rev 898)
@@ -29,22 +29,10 @@
=cut
package LedgerSMB::Employee;
-use LedgerSMB;
-use LedgerSMB::DBObject;
+use base qw(LedgerSMB::DBObject);
use strict;
our $VERSION = '1.0.0';
-our @ISA = qw(LedgerSMB::DBObject);
-
-sub AUTOLOAD {
- my $self = shift;
- my $AUTOLOAD = $LedgerSMB::Employee::AUTOLOAD;
- $AUTOLOAD =~ s/^.*:://;
- my $procname = "employee_$AUTOLOAD";
- $self->exec_method(procname => "employee_$AUTOLOAD", args => ..hidden..);
- my @call_args;
-}
-
sub save {
my $self = shift;
my $hashref = shift @{$self->exec_method(procname => "employee_save")};
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2007-03-14 06:05:12 UTC (rev 897)
+++ trunk/LedgerSMB.pm 2007-03-14 18:09:59 UTC (rev 898)
@@ -103,10 +103,9 @@
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+)/)) {
- $str =~ s/$regex/sprintf("%%%02x", ord($1))/ge
- if $1 == 0 && $2 < 44;
+ # for Apache 2.0.x prior to 2.0.44 we escape strings twic;
+ if ($ENV{SERVER_SIGNATURE} =~ /Apache\/2\.0\.(\d+)/ && $1 < 44) {
+ $str =~ s/$regex/sprintf("%%%02x", ord($1))/ge;
}
$str;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.