Instead of overriding the table() method for each persistent class, the table
name should be included in classSettings().
This commit is contained in:
parent
96bfe07ec9
commit
2786df46ce
4 changed files with 35 additions and 21 deletions
|
|
@ -48,7 +48,8 @@ sub classSettings {
|
||||||
parentId => { defaultValue => 0 },
|
parentId => { defaultValue => 0 },
|
||||||
collateralFolderId => { key => 1 },
|
collateralFolderId => { key => 1 },
|
||||||
description => { quote => 1 }
|
description => { quote => 1 }
|
||||||
}
|
},
|
||||||
|
table => 'collateralFolder'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,6 +74,4 @@ sub recursiveDelete {
|
||||||
WebGUI::Collateral->multiDelete(@collateralIds);
|
WebGUI::Collateral->multiDelete(@collateralIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub table { 'collateralFolder' }
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ sub classSettings {
|
||||||
groupIdEdit => { defaultValue => 3 },
|
groupIdEdit => { defaultValue => 3 },
|
||||||
hideFromNavigation => { defaultValue => 0 },
|
hideFromNavigation => { defaultValue => 0 },
|
||||||
},
|
},
|
||||||
useDummyRoot => 1
|
useDummyRoot => 1,
|
||||||
|
table => 'page'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,9 +237,5 @@ sub makeUnique {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
sub table { 'page' }
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,17 +43,15 @@ database.
|
||||||
use WebGUI::Persistent;
|
use WebGUI::Persistent;
|
||||||
our @ISA = qw(WebGUI::Persistent);
|
our @ISA = qw(WebGUI::Persistent);
|
||||||
|
|
||||||
sub table { 'myTable' }
|
|
||||||
|
|
||||||
|
|
||||||
sub classSettings {
|
sub classSettings {
|
||||||
{
|
{
|
||||||
properties => {
|
properties => {
|
||||||
A => { key => 1 },
|
A => { key => 1 },
|
||||||
B => { defaultValue => 5},
|
B => { defaultValue => 5},
|
||||||
C => { quote => 1 , defaultValue => "hello world"},
|
C => { quote => 1 , defaultValue => "hello world"},
|
||||||
D => { }
|
D => { },
|
||||||
}
|
},
|
||||||
|
table => 'myTable'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +112,18 @@ sub classData {
|
||||||
This class method must be overridden to return a hash reference with one or
|
This class method must be overridden to return a hash reference with one or
|
||||||
more of the following keys.
|
more of the following keys.
|
||||||
|
|
||||||
|
sub classSettings {
|
||||||
|
{
|
||||||
|
properties => {
|
||||||
|
A => { key => 1 },
|
||||||
|
B => { defaultValue => 5},
|
||||||
|
C => { quote => 1 , defaultValue => "hello world"},
|
||||||
|
D => { },
|
||||||
|
},
|
||||||
|
table => 'myTable'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
=over
|
=over
|
||||||
|
|
||||||
=item properties
|
=item properties
|
||||||
|
|
@ -139,6 +149,10 @@ Should be true for fields that need to be quoted in database queries.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
=head2 table
|
||||||
|
|
||||||
|
This must be set to the name of the table that this class represents.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
@ -457,13 +471,19 @@ sub set {
|
||||||
|
|
||||||
=head2 table
|
=head2 table
|
||||||
|
|
||||||
This method must be overriden to return the name of the table modeled by this
|
Returns the table name set in classSettings().
|
||||||
class.
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub table {
|
sub table {
|
||||||
WebGUI::ErrorHandler::fatalError("table() must be overridden");
|
my ($class) = @_;
|
||||||
|
unless ($class->classData->{table}) {
|
||||||
|
unless ($class->classSettings->{table}) {
|
||||||
|
WebGUI::ErrorHandler::fatalError("table() must be overridden");
|
||||||
|
}
|
||||||
|
$class->classData->{table} = $class->classSettings->{table};
|
||||||
|
}
|
||||||
|
return $class->classData->{table}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,6 @@ methods), and from Tree::DAG_Node (to provide tree manipulation methods).
|
||||||
use WebGUI::Persistent::Tree;
|
use WebGUI::Persistent::Tree;
|
||||||
our @ISA = qw(WebGUI::Persistent::Tree);
|
our @ISA = qw(WebGUI::Persistent::Tree);
|
||||||
|
|
||||||
sub table { 'myTreeTable' }
|
|
||||||
|
|
||||||
|
|
||||||
sub classSettings {
|
sub classSettings {
|
||||||
{
|
{
|
||||||
properties => {
|
properties => {
|
||||||
|
|
@ -55,7 +52,8 @@ methods), and from Tree::DAG_Node (to provide tree manipulation methods).
|
||||||
C => { quote => 1 , defaultValue => "hello world"},
|
C => { quote => 1 , defaultValue => "hello world"},
|
||||||
parentId => { defaultValue => 0 },
|
parentId => { defaultValue => 0 },
|
||||||
sequenceNumber => { defaultValue => 1 }
|
sequenceNumber => { defaultValue => 1 }
|
||||||
}
|
},
|
||||||
|
table => 'myTreeTable'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue