From: <chr...@us...> - 2006-05-18 22:12:18
|
Revision: 878 Author: chromatic Date: 2006-05-18 15:12:07 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/everydevel/?rev=878&view=rev Log Message: ----------- r17177@windwheel: chromatic | 2006-05-18 15:11:55 -0700 Minor documentation fixes. Removed deprecated methods. Fixed isa() calls. Modified Paths: -------------- trunk/ebase/lib/Everything/NodeBase.pm trunk/ebase/t/NodeBase.t Property Changed: ---------------- trunk/ebase/ Property changes on: trunk/ebase ___________________________________________________________________ Name: svk:merge - a6810612-c0f9-0310-9d3e-a9e4af8c5745:/ebase/offline:16742 + a6810612-c0f9-0310-9d3e-a9e4af8c5745:/ebase/offline:17177 Modified: trunk/ebase/lib/Everything/NodeBase.pm =================================================================== --- trunk/ebase/lib/Everything/NodeBase.pm 2006-05-16 20:45:15 UTC (rev 877) +++ trunk/ebase/lib/Everything/NodeBase.pm 2006-05-18 22:12:07 UTC (rev 878) @@ -1,26 +1,21 @@ - =head1 Everything::NodeBase Wrapper for the Everything database and cache. -Copyright 1999 - 2003 Everything Development Inc. +Copyright 1999 - 2006 Everything Development Inc. =cut package Everything::NodeBase; -# Format: tabs = 4 spaces - use strict; use DBI; use File::Spec; use Everything (); use Everything::NodeCache; use Everything::Node; +use Scalar::Util 'reftype'; -=cut - - =head2 C<new> Constructor for this module @@ -82,9 +77,6 @@ return $this; } -=cut - - =head2 C<joinWorkspace> create the $DB-E<gt>{workspace} object if a workspace is specified. If the @@ -118,9 +110,6 @@ 1; } -=cut - - =head2 C<getNodeWorkspace> Helper funciton for getNode's workspace functionality. Given a $WHERE hash ( @@ -185,9 +174,6 @@ \@results; } -=cut - - =head2 C<rebuildNodetypeModules> Call this to account for any new nodetypes that may have been installed. @@ -204,9 +190,6 @@ return; } -=cut - - =head2 C<buildNodetypeModules> Perl 5.6 throws errors if we test "can" on a non-existing module. This @@ -257,9 +240,6 @@ return exists $INC{$modpath}; } -=cut - - =head2 C<resetNodeCache> The node cache holds onto nodes after they have been loaded from the database. @@ -277,9 +257,6 @@ $this->{cache}->resetCache(); } -=cut - - =head2 C<getDatabaseHandle> This returns the DBI connection to the database. This can be used to do raw @@ -297,9 +274,6 @@ return $this->{dbh}; } -=cut - - =head2 C<getCache> This returns the NodeCache object that we are using to cache nodes. In @@ -357,9 +331,6 @@ or Everything::logErrors( '', "Delete failed: '$sql' [@$bound]" ); } -=cut - - =head2 C<sqlSelect> Select specific fields from a single record. If you need multiple records, use @@ -404,9 +375,6 @@ return \@result; } -=cut - - =head2 C<sqlSelectJoined> A general wrapper function for a standard SQL select command involving left @@ -462,9 +430,6 @@ return $cursor; } -=cut - - =head2 C<sqlSelectMany> A general wrapper function for a standard SQL select command. This returns the @@ -516,9 +481,6 @@ return; } -=cut - - =head2 C<sqlSelectHashref> Grab one row from a table and return it as a hash. This just grabs the first @@ -560,9 +522,6 @@ return $hash; } -=cut - - =head2 C<sqlUpdate> Wrapper for sql update command. @@ -606,9 +565,6 @@ return $this->sqlExecute( $sql, $bound ); } -=cut - - =head2 C<sqlInsert> Wrapper for the sql insert command. @@ -648,7 +604,6 @@ =cut - C<_quoteData> Private method @@ -688,9 +643,6 @@ return \@names, \@values, \@bound; } -=cut - - =head2 C<sqlExecute> Wrapper for the SQL execute command. @@ -739,9 +691,6 @@ return $this->getNode( $node_id, $selectop ); } -=cut - - =head2 C<newNode> A more programatically "graceful" way than getNode() to get a node that does @@ -775,9 +724,6 @@ return $this->getNode( $title, $type, 'create force' ); } -=cut - - =head2 C<getNode> This is the one and only function needed to get a single node. If any function @@ -830,7 +776,7 @@ return unless defined $node and $node ne ''; # it may already be a node - return $node if UNIVERSAL::isa( $node, 'Everything::Node' ); + return $node if eval { $node->isa( 'Everything::Node' ) }; my $NODE; my $cache = ""; @@ -928,7 +874,6 @@ return $NODE; } -############################################################################# sub getNodeByName { my ( $this, $node, $TYPE ) = @_; @@ -961,9 +906,6 @@ return $NODE; } -=cut - - =head2 C<getNodeZero> The node with zero as its ID is a "dummy" node that represents the root @@ -994,7 +936,6 @@ return $$this{nodezero}; } -############################################################################# sub getNodeByIdNew { my ( $this, $node_id, $selectop ) = @_; @@ -1032,9 +973,6 @@ return $NODE; } -=cut - - =head2 C<constructNode> Given a hash that contains a row of data from the 'node' table, get its type @@ -1096,9 +1034,6 @@ return 1; } -=cut - - =head2 C<getNodeWhere> Get a list of NODE hashes. This constructs a complete node. @@ -1150,7 +1085,7 @@ return unless defined $selectNodeWhere - and UNIVERSAL::isa( $selectNodeWhere, 'ARRAY' ); + and reftype( $selectNodeWhere || '' ) eq 'ARRAY'; my @nodelist; @@ -1163,12 +1098,9 @@ return \@nodelist; } -=cut - - =head2 C<selectNodeWhere> -Retrieves node id's that match the given query. +Retrieves node ids that match the given query. =over 4 @@ -1244,9 +1176,6 @@ return \@nodelist; } -=cut - - =head2 C<getNodeCursor> This returns the sql cursor for node matches. Users of this object can call @@ -1361,9 +1290,6 @@ return $cursor; } -=cut - - =head2 C<countNodeMatches> Doing a full query has some extra overhead. If you just want @@ -1402,9 +1328,6 @@ return $matches; } -=cut - - =head2 C<getType> This is just a quickie wrapper to get a nodetype by name or id. Saves extra @@ -1421,16 +1344,13 @@ return unless defined $idOrName and $idOrName ne ''; # The thing they passed in is good to go. - return $idOrName if UNIVERSAL::isa( $idOrName, 'Everything::Node' ); + return $idOrName if eval { $idOrName->isa( 'Everything::Node' ) }; return $this->getNode( $idOrName, 1 ) if $idOrName =~ /\D/; return $this->getNode($idOrName) if $idOrName > 0; return; } -=cut - - =head2 C<getAllTypes> This returns an array that contains all of the nodetypes in the system. Useful @@ -1459,9 +1379,6 @@ return @allTypes; } -=cut - - =head2 C<getFields> Get the field names of a table. @@ -1485,9 +1402,6 @@ return $this->getFieldsHash( $table, 0 ); } -=cut - - =head2 C<dropNodeTable> Drop (delete) a table from the database. Note!!! This is permanent! You will @@ -1532,9 +1446,6 @@ return $this->{dbh}->do( "drop table " . $this->genTableName($table) ); } -=cut - - =head2 C<quote> A quick access to DBI's quote function for quoting strings so that they do not @@ -1559,9 +1470,6 @@ return $this->{dbh}->quote($str); } -=cut - - =head2 C<genWhereString> This code was stripped from selectNodeWhere. This takes a WHERE hash and a @@ -1606,7 +1514,7 @@ # if your where hash includes a hash to a node, you probably really # want to compare the ID of the node, not the hash reference. - if ( UNIVERSAL::isa( $WHERE->{$key}, 'Everything::Node' ) ) + if ( eval { $WHERE->{$key}->isa( 'Everything::Node' ) } ) { $$WHERE{$key} = $this->getId( $WHERE->{$key} ); } @@ -1667,15 +1575,12 @@ return $wherestr; } -############################################################################# -# "Private" functions to this module -############################################################################# +=head1 Private methods -=cut +These methods are private. Don't call them. They won't call you. +=head2 C<getNodetypeTables> -C<getNodetypeTables> - Returns an array of all the tables that a given nodetype joins on. This will create the array, if it has not already created it. @@ -1725,13 +1630,10 @@ return \@tablelist; } -=cut +=head2 C<getRef> +This makes sure that we have an array of node hashes, not node ids. -C<getRef> - -This makes sure that we have an array of node hashes, not node id's. - Returns the node hash of the first element passed in. =cut @@ -1743,18 +1645,15 @@ for (@_) { - next if UNIVERSAL::isa( $_, 'Everything::Node' ); + next if eval { $_->isa( 'Everything::Node' ) }; $_ = $this->getNode($_) if defined $_; } return $_[0]; } -=cut +=head2 C<getId> - -C<getId> - Given a node object or a node id, return the id. Just a quick function to call to make sure that you have an id. @@ -1775,14 +1674,11 @@ my ( $this, $node ) = @_; return unless $node; - return $node->{node_id} if UNIVERSAL::isa( $node, 'Everything::Node' ); + return $node->{node_id} if eval { $node->isa( 'Everything::Node' ) }; return $node if $node =~ /^-?\d+$/; return; } -=cut - - =head2 C<hasPermission> This does dynamic permission calculations using the specified @@ -1837,40 +1733,4 @@ # if the database returns odd column names, override this to fix them sub fix_node_keys { } -############################################################################# -# DEPRECATED - use hasAccess() -sub canCreateNode -{ - my ( $this, $USER, $TYPE ) = @_; - return $this->hasAccess( $TYPE, $USER, "c" ); -} - -############################################################################# -# DEPRECATED - use hasAccess() -sub canDeleteNode -{ - my ( $this, $USER, $NODE ) = @_; - return $this->hasAccess( $NODE, $USER, "d" ); -} - -############################################################################# -# DEPRECATED - use hasAccess() -sub canUpdateNode -{ - my ( $this, $USER, $NODE ) = @_; - return $this->hasAccess( $NODE, $USER, "w" ); -} - -############################################################################# -# DEPRECATED - use hasAccess() -sub canReadNode -{ - my ( $this, $USER, $NODE ) = @_; - return $this->hasAccess( $NODE, $USER, "r" ); -} - -############################################################################# -# End of Package -############################################################################# - 1; Modified: trunk/ebase/t/NodeBase.t =================================================================== --- trunk/ebase/t/NodeBase.t 2006-05-16 20:45:15 UTC (rev 877) +++ trunk/ebase/t/NodeBase.t 2006-05-18 22:12:07 UTC (rev 878) @@ -1,13 +1,8 @@ -#!/usr/bin/perl -w +#! perl use strict; +use warnings; -BEGIN -{ - chdir 't' if -d 't'; - unshift @INC, '../blib/lib', 'lib/', '..'; -} - use strict; use vars qw( $AUTOLOAD ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |