From e9e4b1a73bb1e2fa439042fc15207a82c4ba03c3 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 21 Apr 2010 10:44:59 -0700 Subject: [PATCH 01/32] add root_dir directive to WebGUI.conf.orig so wgd reset --config does the right thing. --- etc/WebGUI.conf.original | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 6ecbcd40b..c28d2116a 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -110,7 +110,8 @@ # "cache" : { "driver" : "FastMmap", - "expires_variance" : "0.10" + "expires_variance" : "0.10", + "root_dir" : "/tmp/WebGUICache" }, # Sessions that are "hot", those that are not only not expired, From 4cf3c9878f7a0bec6fd96a849de358c405c23803 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Wed, 21 Apr 2010 16:52:47 -0500 Subject: [PATCH 02/32] tree: crumbtrail and back/forward work --- lib/WebGUI/Admin.pm | 8 +++++++- www/extras/admin/admin.js | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Admin.pm b/lib/WebGUI/Admin.pm index 1484da1fd..9ccf89b25 100644 --- a/lib/WebGUI/Admin.pm +++ b/lib/WebGUI/Admin.pm @@ -226,7 +226,13 @@ sub www_getTreeData { $assetInfo->{ totalAssets } = $p->getRowCount; $assetInfo->{ sort } = $session->form->get( 'orderByColumn' ); $assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' ); - $assetInfo->{ currentAsset } = { title => $asset->getTitle, helpers => $asset->getHelpers }; + $assetInfo->{ currentAsset } = { + assetId => $asset->getId, + url => $asset->getUrl, + title => $asset->getTitle, + icon => $asset->getIcon("small"), + helpers => $asset->getHelpers, + }; $assetInfo->{ crumbtrail } = []; for my $asset ( @{ $asset->getLineage( ['ancestors'], { returnObjects => 1 } ) } ) { diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index 71928eef7..f472eae71 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -96,7 +96,7 @@ WebGUI.Admin.prototype.gotoAsset } else if ( this.currentTab == "tree" ) { // Make tree request - this.tree.goto( this.currentAssetDef.url ); + this.tree.goto( url ); this.viewDirty = 1; } }; @@ -453,7 +453,9 @@ WebGUI.Admin.Tree { key: 'childCount' } ], metaFields: { - totalRecords: "totalAssets" // Access to value in the server response + totalRecords: "totalAssets", // Access to value in the server response + crumbtrail : "crumbtrail", + currentAsset : "currentAsset" } }; @@ -731,6 +733,7 @@ WebGUI.Admin.Tree.prototype.formatTitle WebGUI.Admin.Tree.prototype.goto = function ( assetUrl ) { + // TODO: Show loading screen var callback = { success : this.onDataReturnInitializeTable, failure : this.onDataReturnInitializeTable, @@ -756,6 +759,32 @@ WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable = function ( sRequest, oResponse, oPayload ) { this.dataTable.onDataReturnInitializeTable.call( this.dataTable, sRequest, oResponse, oPayload ); + // Rebuild the crumbtrail + var crumb = oResponse.meta.crumbtrail; + var elCrumb = document.getElementById( "treeCrumbtrail" ); + elCrumb.innerHTML = ''; + for ( var i = 0; i < crumb.length; i++ ) { + var item = crumb[i]; + var elItem = document.createElement( "span" ); + elItem.className = "clickable"; + YAHOO.util.Event.addListener( elItem, "click", function(){ this.goto( item.url ) }, this, true ); + elItem.appendChild( document.createTextNode( item.title ) ); + + elCrumb.appendChild( elItem ); + elCrumb.appendChild( document.createTextNode( " > " ) ); + } + + // Final crumb item has a menu + var elItem = document.createElement( "span" ); + elItem.className = "clickable"; + YAHOO.util.Event.addListener( elItem, "click", function(){ alert( "TOADO" ) }, this, true ); + elItem.appendChild( document.createTextNode( oResponse.meta.currentAsset.title ) ); + elCrumb.appendChild( elItem ); + + // TODO: Update current asset + window.admin.navigate( oResponse.meta.currentAsset ); + + // TODO Hide loading screen }; /** From 794c85c65a660ea7ebb71b6d0fa63104e820f3e9 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Fri, 23 Apr 2010 11:01:17 -0500 Subject: [PATCH 03/32] tree view works. fixed dirty frame handling --- www/extras/admin/admin.css | 5 +++++ www/extras/admin/admin.js | 38 +++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/www/extras/admin/admin.css b/www/extras/admin/admin.css index c7f96b8b8..d4a77ee06 100644 --- a/www/extras/admin/admin.css +++ b/www/extras/admin/admin.css @@ -92,6 +92,11 @@ margin: 0; padding: 0; } +.clickable { + cursor: pointer; + color: blue; +} + img.icon { vertical-align: baseline; } diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index f472eae71..5c8f9dda5 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -103,7 +103,7 @@ WebGUI.Admin.prototype.gotoAsset /** * navigate( assetDef ) - * We've navigated to a new asset. Called by one of the iframes when a new + * We've navigated to a new asset. Called by the view iframe when a new * page is reached */ WebGUI.Admin.prototype.navigate @@ -122,7 +122,10 @@ WebGUI.Admin.prototype.navigate // Update the location bar this.locationBar.navigate( assetDef ); - this.currentAssetDef = assetDef; + if ( !this.currentAssetDef || this.currentAssetDef.assetId != assetDef.assetId ) { + this.currentAssetDef = assetDef; + this.treeDirty = 1; + } }; /**************************************************************************** @@ -676,11 +679,11 @@ WebGUI.Admin.Tree.prototype.formatLockedBy elCell.innerHTML = oRecord.getData( 'lockedBy' ) ? '' - + '' + window.admin.i18n.get('WebGUI', 'locked by') + ' ' + oRecord.getData( 'lockedBy' ) + '' + '' : '' - + '' + window.admin.i18n.get('Asset', 'unlocked') + '' + '' ; @@ -723,14 +726,27 @@ WebGUI.Admin.Tree.prototype.formatRevisionDate */ WebGUI.Admin.Tree.prototype.formatTitle = function ( elCell, oRecord, oColumn, orderNumber ) { - elCell.innerHTML = '' - + ( oRecord.getData( 'childCount' ) > 0 ? "+" : " " ) - + ' ' - + oRecord.getData( 'title' ) - + '' - ; + var hasChildren = document.createElement("span"); + hasChildren.className = "hasChildren"; + if ( oRecord.getData('childCount') > 0 ) { + hasChildren.appendChild( document.createTextNode( "+" ) ); + } + else { + hasChildren.appendChild( document.createTextNode( " " ) ); + } + elCell.appendChild( hasChildren ); + + var title = document.createElement("span"); + title.className = "clickable"; + title.appendChild( document.createTextNode( oRecord.getData('title') ) ); + YAHOO.util.Event.addListener( title, "click", function(){ window.admin.gotoAsset(oRecord.getData('url')) }, this, true ); + elCell.appendChild( title ); }; +/** + * Update the tree with a new asset + * Do not call this directly, use Admin.gotoAsset(url) + */ WebGUI.Admin.Tree.prototype.goto = function ( assetUrl ) { // TODO: Show loading screen @@ -767,7 +783,7 @@ WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable var item = crumb[i]; var elItem = document.createElement( "span" ); elItem.className = "clickable"; - YAHOO.util.Event.addListener( elItem, "click", function(){ this.goto( item.url ) }, this, true ); + YAHOO.util.Event.addListener( elItem, "click", function(){ window.admin.gotoAsset( item.url ) }, this, true ); elItem.appendChild( document.createTextNode( item.title ) ); elCrumb.appendChild( elItem ); From cbb5c7a11a4c836774a3a900d2bf094666c87800 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Fri, 23 Apr 2010 13:42:57 -0500 Subject: [PATCH 04/32] begin edit form --- lib/WebGUI/Admin.pm | 2 +- www/extras/admin/admin.js | 101 +++++++++++++++++++++++++------------- 2 files changed, 69 insertions(+), 34 deletions(-) diff --git a/lib/WebGUI/Admin.pm b/lib/WebGUI/Admin.pm index 9ccf89b25..d4da2391f 100644 --- a/lib/WebGUI/Admin.pm +++ b/lib/WebGUI/Admin.pm @@ -209,7 +209,7 @@ sub www_getTreeData { childCount => $asset->getChildCount, assetSize => $asset->assetSize, lockedBy => ($asset->isLockedBy ? $asset->lockedBy->username : ''), - actions => $asset->canEdit && $asset->canEditIfLocked, + canEdit => $asset->canEdit && $asset->canEditIfLocked, helpers => $asset->getHelpers, ); diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index 5c8f9dda5..0f59d5e0c 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -79,10 +79,37 @@ WebGUI.Admin.prototype.afterShowViewTab }; /** - * go( url ) - * Open the view tab and go to the given URL. - * Should not be used for assets, use gotoAsset() instead + * appendToUrl( url, params ) + * Add URL components to a URL; */ +appendToUrl += function ( url, params ) { + var components = [ url ]; + if (url.match(/\?/)) { + components.push(";"); + } + else { + components.push("?"); + } + components.push(params); + return components.join(''); +}; + +/** + * editAsset( url ) + * Show the edit form for the asset at the given URL + */ +WebGUI.Admin.prototype.editAsset += function ( url ) { + // Open the edit form + window.frames["view"].location.href = appendToUrl( url, "func=edit" ); + + // Mark undirty, as we'll clean it ourselves + this.viewDirty = 0; + + // Show the view tab + this.tabBar.selectTab( 0 ); +}; /** * gotoAsset( url ) @@ -101,6 +128,30 @@ WebGUI.Admin.prototype.gotoAsset } }; +/** + * makeEditAsset( url ) + * Create a callback to edit an asset. Use when attaching to event listeners + */ +WebGUI.Admin.prototype.makeEditAsset += function (url) { + var self = this; + return function() { + self.editAsset( url ); + }; +}; + +/** + * makeGotoAsset( url ) + * Create a callback to view an asset. Use when attaching to event listeners + */ +WebGUI.Admin.prototype.makeGotoAsset += function ( url ) { + var self = this; + return function() { + self.gotoAsset( url ); + }; +}; + /** * navigate( assetDef ) * We've navigated to a new asset. Called by the view iframe when a new @@ -445,7 +496,7 @@ WebGUI.Admin.Tree fields: [ { key: 'assetId' }, { key: 'lineage' }, - { key: 'actions' }, + { key: 'canEdit' }, { key: 'title' }, { key: 'className' }, { key: 'revisionDate' }, @@ -498,23 +549,6 @@ WebGUI.Admin.Tree }; -/** - * appendToUrl( url, params ) - * Add URL components to a URL; - */ -appendToUrl -= function ( url, params ) { - var components = [ url ]; - if (url.match(/\?/)) { - components.push(";"); - } - else { - components.push("?"); - } - components.push(params); - return components.join(''); -}; - /** * addHighlightToRow ( child ) * Highlight the row containing this element by adding to it the "highlight" @@ -610,16 +644,17 @@ WebGUI.Admin.Tree.prototype.findRow */ WebGUI.Admin.Tree.prototype.formatActions = function ( elCell, oRecord, oColumn, orderNumber ) { - if ( oRecord.getData( 'actions' ) ) { - elCell.innerHTML - = '' - + window.admin.i18n.get('Asset', 'edit') + '' - + ' | ' - ; - } - else { - elCell.innerHTML = ""; + if ( oRecord.getData( 'canEdit' ) ) { + var edit = document.createElement("span"); + edit.className = "clickable"; + YAHOO.util.Event.addListener( edit, "click", function(){ + window.admin.editAsset( oRecord.getData('url') ); + }, window.admin, true ); + edit.appendChild( document.createTextNode( window.admin.i18n.get('Asset', 'edit') ) ); + elCell.appendChild( edit ); + elCell.appendChild( document.createTextNode( " | " ) ); } + return; // TODO var more = document.createElement( 'a' ); elCell.appendChild( more ); @@ -632,7 +667,7 @@ WebGUI.Admin.Tree.prototype.formatActions oldMenu.parentNode.removeChild( oldMenu ); } - var options = this.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'actions' )); + var options = this.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'canEdit' )); var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options ); YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ); } ); @@ -783,7 +818,7 @@ WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable var item = crumb[i]; var elItem = document.createElement( "span" ); elItem.className = "clickable"; - YAHOO.util.Event.addListener( elItem, "click", function(){ window.admin.gotoAsset( item.url ) }, this, true ); + YAHOO.util.Event.addListener( elItem, "click", window.admin.makeGotoAsset(item.url) ); elItem.appendChild( document.createTextNode( item.title ) ); elCrumb.appendChild( elItem ); @@ -879,7 +914,7 @@ WebGUI.Admin.Tree.prototype.toggleHighlightForRow */ WebGUI.Admin.Tree.prototype.toggleRow = function ( child ) { var row = this.findRow( child ); - + // Find the checkbox var inputs = row.getElementsByTagName( "input" ); for ( var i = 0; i < inputs.length; i++ ) { From d758bceea26821147869089947dd0e8e3bdfa442 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 5 May 2010 10:33:53 -0700 Subject: [PATCH 05/32] Remove unneeded module from testEnvironment.pl --- sbin/testEnvironment.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 332d458e9..ad7a1edd7 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -137,7 +137,6 @@ checkModule('Digest::SHA', '5.47' ); checkModule("CSS::Minifier::XS", "0.03" ); checkModule("JavaScript::Minifier::XS", "0.05" ); checkModule("Readonly", "1.03" ); -checkModule("Memcached::libmemcached", "0.3102" ); checkModule("Moose", "0.93" ); checkModule("MooseX::Storage", "0.23" ); checkModule("namespace::autoclean", "0.09" ); From 3e168b1c875e7875f0872cf8f13ad1f81efe7d67 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 5 May 2010 11:50:31 -0700 Subject: [PATCH 06/32] Trap calls to newById inside getParent. StoryArchive should use cloneFromDb. --- lib/WebGUI/Asset/Wobject/StoryArchive.pm | 2 +- lib/WebGUI/AssetLineage.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index 8b381d3ca..c33fa526f 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -306,7 +306,7 @@ sub getFolder { $oldVersionTag->setWorking() if $oldVersionTag; ##Get a new version of the asset from the db with the correct state - $folder = WebGUI::Asset->newByUrl($session, $folderUrl); + $folder = $folder->cloneFromDb(); return $folder; } diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index 960ff71b1..2fb1d0b16 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -733,7 +733,7 @@ sub getParent { return $self if ($self->getId eq "PBasset000000000000001"); unless ( $self->{_parent} ) { - $self->{_parent} = WebGUI::Asset->newById($self->session,$self->parentId); + $self->{_parent} = eval { WebGUI::Asset->newById($self->session, $self->parentId); }; } return $self->{_parent}; From c1cc94f2805ad9b7f282ce31ec5d243c801caf07 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 12:01:32 -0700 Subject: [PATCH 07/32] Do not run the test suite on the support class. --- t/tests/My/Test/Class.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/tests/My/Test/Class.pm b/t/tests/My/Test/Class.pm index 163d41ad5..506bf6bfb 100644 --- a/t/tests/My/Test/Class.pm +++ b/t/tests/My/Test/Class.pm @@ -32,7 +32,8 @@ sub _00_init : Test(startup => 1) { my $session = WebGUI::Test->session; $test->session($session); my $class = ref $test; - $class =~ s/Test:://; + $class =~ s/^Test:://; + return ('Not a WebGUI class') unless $class =~ /^WebGUI/; $test->class($class); lives_ok { WebGUI::Asset->loadModule($class); } "loaded module class $class"; } From 28f4605b254057be423ec235f6b9f501276bc88f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 12:19:25 -0700 Subject: [PATCH 08/32] Update test due to the removal of the headBlock. --- t/Session/Style.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/Session/Style.t b/t/Session/Style.t index 51a134372..96e96c222 100644 --- a/t/Session/Style.t +++ b/t/Session/Style.t @@ -370,6 +370,7 @@ $expectedMetas = [ }, ]; cmp_bag(\@metas, $expectedMetas, 'process, headBlock:no duped headBlock from style template'); + #################################################### # # process @@ -485,7 +486,7 @@ sub setup_assets { url => 'headblock_style', namespace => 'Style', template => 'HEADBLOCK STYLE TEMPLATE\n\nBODY=\n\nHEAD=', - headBlock => q||, + extraHeadTags => q||, id => 'testTemplate_headblock', # '1234567890123456789012' }; From d46dcaa3786b7bedbe81d3651793c02447f1bc70 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 12:21:06 -0700 Subject: [PATCH 09/32] More headBlock => extraHeadTags cleanup --- t/Session/Style.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/Session/Style.t b/t/Session/Style.t index 96e96c222..19d8c00ff 100644 --- a/t/Session/Style.t +++ b/t/Session/Style.t @@ -328,14 +328,14 @@ TODO: { #################################################### # # process -# no duped headBlockContent +# no duped extraHeadTagsContent # #################################################### $style->useEmptyStyle(1); $style->sent(0); -$session->scratch->set('personalStyleId', $templates->{headBlock}->getId); +$session->scratch->set('personalStyleId', $templates->{extraHeadTags}->getId); $styled = $style->process('body.content', 'notATemplateId'); @@ -369,7 +369,7 @@ $expectedMetas = [ 'content' => 'must-revalidate' }, ]; -cmp_bag(\@metas, $expectedMetas, 'process, headBlock:no duped headBlock from style template'); +cmp_bag(\@metas, $expectedMetas, 'process, extraHeadTags:no duped extraHeadTags from style template'); #################################################### # @@ -481,7 +481,7 @@ sub setup_assets { }; $templates->{personal} = $importNode->addChild($properties, $properties->{id}); $properties = { - title => 'personal style test template with headBlock', + title => 'personal style test template with extraHeadTags', className => 'WebGUI::Asset::Template', url => 'headblock_style', namespace => 'Style', @@ -490,7 +490,7 @@ sub setup_assets { id => 'testTemplate_headblock', # '1234567890123456789012' }; - $templates->{headBlock} = $importNode->addChild($properties, $properties->{id}); + $templates->{extraHeadTags} = $importNode->addChild($properties, $properties->{id}); $properties = { title => 'personal style test template for printing', className => 'WebGUI::Asset::Template', From b7b91a3143f2d98b06d256c0245442ef99e63826 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 12:24:38 -0700 Subject: [PATCH 10/32] Update test for property manipulation. --- t/Session/Url.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/Session/Url.t b/t/Session/Url.t index 5d44ea159..d44eb9a0d 100644 --- a/t/Session/Url.t +++ b/t/Session/Url.t @@ -417,21 +417,21 @@ my $statefulAsset = WebGUI::Asset->getRoot($session)->addChild({ className => 'W $versionTag->commit; $session->asset( $statefulAsset ); -$statefulAsset->{_properties}{state} = 'published'; +$statefulAsset->state('published'); is( $session->url->getBackToSiteURL, WebGUI::Asset->getRoot($session)->getUrl, q!getBackToSiteURL: When asset state is published, it returns you to the Assets container! ); -$statefulAsset->{_properties}{state} = 'trash'; +$statefulAsset->state( 'trash'); is( $session->url->getBackToSiteURL, $defaultAssetUrl, q!getBackToSiteURL: When asset state is trash, it returns you to the default Asset! ); -$statefulAsset->{_properties}{state} = 'clipboard'; +$statefulAsset->state('clipboard'); is( $session->url->getBackToSiteURL, $defaultAssetUrl, From 5bf7f427988b1e9b42c29c3129d3d4115324595a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 12:34:56 -0700 Subject: [PATCH 11/32] Update the test for the new caching scheme. --- t/Session/Var.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/Session/Var.t b/t/Session/Var.t index 68345c504..0798af97f 100644 --- a/t/Session/Var.t +++ b/t/Session/Var.t @@ -138,13 +138,13 @@ $session->db->write("update userSession set expires=? where sessionId=?", my %copyOfVar2 = %{$var2->{_var}}; $copyOfVar2{expires} = $var2->get('lastPageView')-1; $copyOfVar2{userId} = 3; -$session->cache->set(['session',$var2->getId], \%copyOfVar2); +$session->cache->set($var2->getId, \%copyOfVar2); my $var3 = WebGUI::Session::Var->new($session, $var2->getId); -is($var3->getId, $var2->getId, 'new Var object has correct id'); -isnt($var3->isAdminOn, $var2->isAdminOn, 'new adminOn not equal to old adminOn'); -is($var3->isAdminOn, 0, 'new Var object has default adminOn'); -isnt($var3->get('userId'), 3, 'new userId not equal to old userId'); +is $var3->getId, $var2->getId, 'new Var object has correct id'; +isnt $var3->isAdminOn, $var2->isAdminOn, 'new adminOn not equal to old adminOn'; +is $var3->isAdminOn, 0, 'new Var object has default adminOn'; +isnt $var3->get('userId'), 3, 'new userId not equal to old userId'; $var2->end; $var3->end; From 1aeb75bce901ac5babf1a988ecbf18ec94a991d4 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 12:38:00 -0700 Subject: [PATCH 12/32] Fix POD whitespace problems. --- lib/WebGUI/Asset/Wobject/GalleryAlbum.pm | 1 + lib/WebGUI/Role/Asset/Comments.pm | 2 +- t/lib/WebGUI/Form_Checking.pm | 2 +- t/lib/WebGUI/TestException.pm | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index 132d92206..9251d2efe 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -63,6 +63,7 @@ use Archive::Any; =head1 DIAGNOSTICS =head1 METHODS + =cut #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/Role/Asset/Comments.pm b/lib/WebGUI/Role/Asset/Comments.pm index 0d1493589..43b2a81a8 100644 --- a/lib/WebGUI/Role/Asset/Comments.pm +++ b/lib/WebGUI/Role/Asset/Comments.pm @@ -48,7 +48,7 @@ This is an aspect which makes adding comments to existing assets trivial. =head1 SYNOPSIS with 'WebGUI::Role::Asset::Comments'; - + =head1 METHODS These methods are available from this class: diff --git a/t/lib/WebGUI/Form_Checking.pm b/t/lib/WebGUI/Form_Checking.pm index e490ce390..b8e8b8535 100644 --- a/t/lib/WebGUI/Form_Checking.pm +++ b/t/lib/WebGUI/Form_Checking.pm @@ -74,7 +74,7 @@ Usage: # Reset the session back $session->{_request} = $old_session; - + =cut sub get_request diff --git a/t/lib/WebGUI/TestException.pm b/t/lib/WebGUI/TestException.pm index affc8a99e..03ef43247 100644 --- a/t/lib/WebGUI/TestException.pm +++ b/t/lib/WebGUI/TestException.pm @@ -26,6 +26,7 @@ functions _quiet_caller and _try_as_caller are directly copied from Test::Except hocuspocus is being in that module however, since doing 'eval { uplevel 1, $codeRef }' seems to work too. On my platform at least =). For the time being, I leave those subs in here so that they may be used. They are commented out by default, though. + =cut #---------------------------------------------------------------------------- From 1c4ea8eacd294d212e9957b81ddac07b41467b74 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 14:51:05 -0700 Subject: [PATCH 13/32] more ProfileField tests --- t/ProfileField.t | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/t/ProfileField.t b/t/ProfileField.t index 76fcfc84e..2faeaa580 100644 --- a/t/ProfileField.t +++ b/t/ProfileField.t @@ -33,7 +33,7 @@ WebGUI::Test->usersToDelete($newUser); #---------------------------------------------------------------------------- # Tests -plan tests => 48; # Increment this number for each test you create +plan tests => 50; # Increment this number for each test you create #---------------------------------------------------------------------------- # Test the creation of ProfileField @@ -91,6 +91,8 @@ my $newProfileField = WebGUI::ProfileField->create($session, 'testField', { }); is($newProfileField->get('fieldType'), 'Float', 'create: makes field with correct type'); +is $newProfileField->get('fieldName'), 'testField', '...correct fieldName'; +is $newProfileField->getId, 'testField', '...correct id'; is($newProfileField->get('label'), 'Test Field', 'correct label'); is($newProfileField->getLabel, 'Test Field', 'getLabel works, too'); From 7032e86cf120938e24f7aadce95ea959fae13205 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 15:50:43 -0700 Subject: [PATCH 14/32] Change cache strategy for User.t. Fix setRow in SQL.pm to accept overrides in row identifiers. --- lib/WebGUI/SQL.pm | 5 ++--- t/SQL.t | 4 +++- t/User.t | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index b13d5a165..dadc180a4 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -962,9 +962,8 @@ Use this ID to create a new row. Same as setting the key value to "new" except t sub setRow { my ($self, $table, $keyColumn, $data, $id) = @_; - $data->{$keyColumn} ||= $id; - if ($data->{$keyColumn} eq "new") { - $data->{$keyColumn} = $self->session->id->generate(); + if ($data->{$keyColumn} eq "new" || $id) { + $data->{$keyColumn} = $id || $self->session->id->generate(); } my $dbh = $self->dbh; my @fields = (); diff --git a/t/SQL.t b/t/SQL.t index 483ea065e..8bef9a44e 100644 --- a/t/SQL.t +++ b/t/SQL.t @@ -17,7 +17,7 @@ use WebGUI::Session; use Data::Dumper; use Test::Deep; -use Test::More tests => 56; # increment this value for each test you create +use Test::More tests => 57; # increment this value for each test you create my $session = WebGUI::Test->session; @@ -145,6 +145,8 @@ my $setRowId = $session->db->setRow("incrementer","incrementerId",{incrementerId ok($setRowId ne "", "setRow() - return ID"); my ($setRowResult) = $session->db->quickArray("select nextValue from incrementer where incrementerId=".$session->db->quote($setRowId)); is($setRowResult, 47, "setRow() - set data"); +is $session->db->setRow("incrementer", "incrementerId",{incrementerId=>'new', nextValue => 48}, 'oogeyBoogeyBoo'), + 'oogeyBoogeyBoo', 'overriding default id with a custom one'; # getRow my $getRow = $session->db->getRow("incrementer","incrementerId",$setRowId); diff --git a/t/User.t b/t/User.t index 272d2d196..47d438616 100644 --- a/t/User.t +++ b/t/User.t @@ -15,7 +15,6 @@ use lib "$FindBin::Bin/lib"; use WebGUI::Test; use WebGUI::Session; use WebGUI::Utility; -use WebGUI::Cache; #use Exception::Class; use WebGUI::User; @@ -28,8 +27,9 @@ use Data::Dumper; my $session = WebGUI::Test->session; -my $testCache = WebGUI::Cache->new($session, 'myTestKey'); -$testCache->flush; +#my $testCache = WebGUI::Cache->new($session, 'myTestKey'); +#$testCache->flush; +$session->cache->remove('myTestKey'); my $user; my $lastUpdate; @@ -1063,6 +1063,6 @@ END { $newProfileField->delete() if $newProfileField; - $testCache->flush; + $session->cache->delete('myTestKey'); } From e830e922c8b44debc8da85023d7913c3b16ffde7 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 20:08:21 -0700 Subject: [PATCH 15/32] Update test for new cache system. --- t/User.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/User.t b/t/User.t index 47d438616..d85fcae56 100644 --- a/t/User.t +++ b/t/User.t @@ -1063,6 +1063,6 @@ END { $newProfileField->delete() if $newProfileField; - $session->cache->delete('myTestKey'); + $session->cache->remove('myTestKey'); } From ad88c37581b39c4e291853a0fac13bfed6fc8df4 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 20:48:39 -0700 Subject: [PATCH 16/32] Revert back to the old setRow that handles sparse updates, like the one used by Group. --- lib/WebGUI/SQL.pm | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index dadc180a4..6f1f6fd00 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -961,24 +961,28 @@ Use this ID to create a new row. Same as setting the key value to "new" except t =cut sub setRow { - my ($self, $table, $keyColumn, $data, $id) = @_; - if ($data->{$keyColumn} eq "new" || $id) { - $data->{$keyColumn} = $id || $self->session->id->generate(); - } - my $dbh = $self->dbh; - my @fields = (); - my @data = (); - my @placeholders = (); - foreach my $key (keys %{$data}) { - push(@fields, $dbh->quote_identifier($key)); - push(@placeholders, '?'); - push(@data,$data->{$key}); - } - $self->write("replace into $table (" . join(",",@fields) . ") values (".join(",",@placeholders).")",\@data); - return $data->{$keyColumn}; + my ($self, $table, $keyColumn, $data, $id) = @_; + if ($data->{$keyColumn} eq "new" || $id) { + $data->{$keyColumn} = $id || $self->session->id->generate(); + $self->write("replace into ".$self->dbh->quote_identifier($table) + ." (" . $self->dbh->quote_identifier($keyColumn) . ") values (?)",[$data->{$keyColumn}]); + } + my @fields = (); + my @data = (); + foreach my $key (keys %{$data}) { + unless ($key eq $keyColumn) { + push(@fields, $self->dbh->quote_identifier($key).'=?'); + push(@data,$data->{$key}); + } + } + if ($fields[0] ne "") { + push(@data,$data->{$keyColumn}); + $self->write("update ".$self->dbh->quote_identifier($table)." set " . join(", ", @fields) + . " where " . $self->dbh->quote_identifier($keyColumn) . "=?", \@data); + } + return $data->{$keyColumn}; } - #------------------------------------------------------------------- =head2 unconditionalRead ( sql [, placeholders ] ) From ae43a10d7c63433e5a1ca62f7b993f40f474c24c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 May 2010 20:58:57 -0700 Subject: [PATCH 17/32] Update this test for the new caching system. --- t/User.t | 2 -- 1 file changed, 2 deletions(-) diff --git a/t/User.t b/t/User.t index d85fcae56..1ce052a45 100644 --- a/t/User.t +++ b/t/User.t @@ -27,8 +27,6 @@ use Data::Dumper; my $session = WebGUI::Test->session; -#my $testCache = WebGUI::Cache->new($session, 'myTestKey'); -#$testCache->flush; $session->cache->remove('myTestKey'); my $user; From d0b17aced80fff913d865412487f931c65e2f5f3 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 13:43:04 -0700 Subject: [PATCH 18/32] Update EMSSubmission to Moose. --- lib/WebGUI/Asset/EMSSubmission.pm | 403 ++++++++++-------------------- 1 file changed, 138 insertions(+), 265 deletions(-) diff --git a/lib/WebGUI/Asset/EMSSubmission.pm b/lib/WebGUI/Asset/EMSSubmission.pm index 8d4af8b19..48e265839 100644 --- a/lib/WebGUI/Asset/EMSSubmission.pm +++ b/lib/WebGUI/Asset/EMSSubmission.pm @@ -14,10 +14,134 @@ package WebGUI::Asset::EMSSubmission; =cut -use Class::C3; use strict; +use Moose; +use WebGUI::Definition::Asset; +use WebGUI::Asset; +use WebGUI::International; +extends 'WebGUI::Asset'; +define tableName => 'EMSSubmission'; +define assetNae => ['assetName', 'Asset_EMSSubmission']; +define icon => 'EMSSubmission.gif'; + +property submissionId => ( + noFormPost => 1, + fieldType => "hidden", + default => undef, +); +property submissionStatus => ( + fieldType => "selectList", + default => 'pending', + customDrawMethod => 'drawStatusField', + label => [ "submission status", 'Asset_EMSSubmission' ], + hoverHelp => [ "submission status help", 'Asset_EMSSubmission' ] +); +property description => ( + tab => "properties", + fieldType => "HTMLArea", + default => undef, + label => [ "description", 'Asset_Sku' ], + hoverHelp => [ "description help", 'Asset_Sku' ] +); +property sku => ( + tab => "shop", + fieldType => "text", + builder => '_builder_sku', + lazy => 1, + label => [ "sku", 'Asset_Sku' ], + hoverHelp => [ "sku help", 'Asset_Sku' ] +); +sub _builder_sku { + my $self = shift; + return $self->session->id->generate; +} +property displayTitle => ( + tab => "display", + fieldType => "yesNo", + default => 1, + label => [ "display title", 'Asset_Sku' ], + hoverHelp => [ "display title help", 'Asset_Sku' ] +); +property vendorId => ( + tab => "shop", + fieldType => "vendor", + default => 'defaultvendor000000000', + label => [ "vendor", 'Asset_Sku' ], + hoverHelp => [ "vendor help", 'Asset_Sku' ] +); +property shipsSeparately => ( + tab => 'shop', + fieldType => 'yesNo', + default => 0, + label => [ 'shipsSeparately', 'Asset_Sku' ], + hoverHelp => [ 'shipsSeparately help', 'Asset_Sku' ], +); + +property price => ( + tab => "shop", + fieldType => "float", + default => 0.00, + label => [ "price", 'Asset_EMSSubmission' ], + hoverHelp => [ "price help", 'Asset_EMSSubmission' ], +); +property seatsAvailable => ( + tab => "shop", + fieldType => "integer", + default => 25, + label => [ "seats available", 'Asset_EMSSubmission' ], + hoverHelp => [ "seats available help", 'Asset_EMSSubmission' ], +); +property startDate => ( + noFormPost => 1, + fieldType => "dateTime", + default => '', + label => [ "add/edit event start date", 'Asset_EMSSubmission' ], + hoverHelp => [ "add/edit event start date help", 'Asset_EMSSubmission' ], + autoGenerate => 0, +); +property duration => ( + tab => "properties", + fieldType => "float", + default => 1.0, + subtext => [ 'hours', 'Asset_EMSSubmission' ], + label => [ "duration", 'Asset_EMSSubmission' ], + hoverHelp => [ "duration help", 'Asset_EMSSubmission' ], +); +property location => ( + fieldType => "combo", + tab => "properties", + customDrawMethod => 'drawLocationField', + label => [ "location", 'Asset_EMSSubmission' ], + hoverHelp => [ "location help", 'Asset_EMSSubmission' ], +); +property relatedBadgeGroups => ( + tab => "properties", + fieldType => "checkList", + customDrawMethod => 'drawRelatedBadgeGroupsField', + label => [ "related badge groups", 'Asset_EMSSubmission' ], + hoverHelp => [ "related badge groups ticket help", 'Asset_EMSSubmission' ], +); +property relatedRibbons => ( + tab => "properties", + fieldType => "checkList", + customDrawMethod => 'drawRelatedRibbonsField', + label => [ "related ribbons", 'Asset_EMSSubmission' ], + hoverHelp => [ "related ribbons help", 'Asset_EMSSubmission' ], +); +property eventMetaData => ( + noFormPost => 1, + fieldType => "hidden", + default => '{}', +); +property ticketId => ( + noFormPost => 1, + fieldType => "hidden", + default => '', +); + +with 'WebGUI::Role::Asset::Comments'; + use Tie::IxHash; -use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset); use WebGUI::Utility; use WebGUI::Inbox; @@ -58,173 +182,15 @@ send email when a comment is added =cut -sub addComment { +around addComment => sub { + my $orig = shift; my $self = shift; $self->update({lastReplyBy => $self->session->user->userId}); - $self->next::method(@_); + $self->$orig(@_); $self->sendEmailUpdate; -} +}; -#------------------------------------------------------------------- - -=head2 addRevision - -This method exists for demonstration purposes only. The superclass -handles revisions to NewAsset Assets. - -=cut - -#sub addRevision { -# my $self = shift; -# my $newSelf = $self->next::method(@_); -# return $newSelf; -#} - -#------------------------------------------------------------------- - -=head2 definition ( session, definition ) - -defines asset properties for New Asset instances. You absolutely need -this method in your new Assets. - -=head3 session - -=head3 definition - -A hash reference passed in from a subclass definition. - -=cut - -sub definition { - my $class = shift; - my $session = shift; - my $definition = shift; - my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" ); - my $EMS_i18n = WebGUI::International->new($session, "Asset_EventManagementSystem"); - my $SKU_i18n = WebGUI::International->new($session, "Asset_Sku"); - tie my %properties, 'Tie::IxHash', ( - submissionId => { - noFormPost => 1, - fieldType => "hidden", - defaultValue => undef, - }, - submissionStatus => { - fieldType =>"selectList", - defaultValue => 'pending', - customDrawMethod=> 'drawStatusField', - label => $i18n->get("submission status"), - hoverHelp => $i18n->get("submission status help") - }, - description => { - tab => "properties", - fieldType => "HTMLArea", - defaultValue => undef, - label => $SKU_i18n->get("description"), - hoverHelp => $SKU_i18n->get("description help") - }, - sku => { - tab => "shop", - fieldType => "text", - defaultValue => $session->id->generate, - label => $SKU_i18n->get("sku"), - hoverHelp => $SKU_i18n->get("sku help") - }, - displayTitle => { - tab => "display", - fieldType => "yesNo", - defaultValue => 1, - label => $SKU_i18n->get("display title"), - hoverHelp => $SKU_i18n->get("display title help") - }, - vendorId => { - tab => "shop", - fieldType => "vendor", - defaultValue => 'defaultvendor000000000', - label => $SKU_i18n->get("vendor"), - hoverHelp => $SKU_i18n->get("vendor help") - }, - shipsSeparately => { - tab => 'shop', - fieldType => 'yesNo', - defaultValue => 0, - label => $SKU_i18n->get('shipsSeparately'), - hoverHelp => $SKU_i18n->get('shipsSeparately help'), - }, - - price => { - tab => "shop", - fieldType => "float", - defaultValue => 0.00, - label => $EMS_i18n->get("price"), - hoverHelp => $EMS_i18n->get("price help"), - }, - seatsAvailable => { - tab => "shop", - fieldType => "integer", - defaultValue => 25, - label => $EMS_i18n->get("seats available"), - hoverHelp => $EMS_i18n->get("seats available help"), - }, - startDate => { - noFormPost => 1, - fieldType => "dateTime", - defaultValue => '', - label => $EMS_i18n->get("add/edit event start date"), - hoverHelp => $EMS_i18n->get("add/edit event start date help"), - autoGenerate => 0, - }, - duration => { - tab => "properties", - fieldType => "float", - defaultValue => 1.0, - subtext => $EMS_i18n->get('hours'), - label => $EMS_i18n->get("duration"), - hoverHelp => $EMS_i18n->get("duration help"), - }, - location => { - fieldType => "combo", - tab => "properties", - customDrawMethod=> 'drawLocationField', - label => $EMS_i18n->get("location"), - hoverHelp => $EMS_i18n->get("location help"), - }, - relatedBadgeGroups => { - tab => "properties", - fieldType => "checkList", - customDrawMethod=> 'drawRelatedBadgeGroupsField', - label => $EMS_i18n->get("related badge groups"), - hoverHelp => $EMS_i18n->get("related badge groups ticket help"), - }, - relatedRibbons => { - tab => "properties", - fieldType => "checkList", - customDrawMethod=> 'drawRelatedRibbonsField', - label => $EMS_i18n->get("related ribbons"), - hoverHelp => $EMS_i18n->get("related ribbons help"), - }, - eventMetaData => { - noFormPost => 1, - fieldType => "hidden", - defaultValue => '{}', - }, - ticketId => { - noFormPost => 1, - fieldType => "hidden", - defaultValue => '', - }, - ); - push @{$definition}, { - assetName => $i18n->get('assetName'), - icon => 'EMSSubmission.gif', - autoGenerateForms => 1, - tableName => 'EMSSubmission', - className => 'WebGUI::Asset::EMSSubmission', - properties => \%properties, - }; - return $class->next::method( $session, $definition ); -} ## end sub definition - #------------------------------------------------------------------- =head2 drawLocationField () @@ -313,22 +279,6 @@ sub drawStatusField { } -#------------------------------------------------------------------- - -=head2 duplicate - -This method exists for demonstration purposes only. The superclass -handles duplicating NewAsset Assets. This method will be called -whenever a copy action is executed - -=cut - -#sub duplicate { -# my $self = shift; -# my $newAsset = $self->next::method(@_); -# return $newAsset; -#} - #------------------------------------------------------------------- =head2 ems @@ -527,31 +477,6 @@ sub www_view { $_[0]->ems->www_viewSubmissionQueue } #------------------------------------------------------------------- -=head2 getEditForm ( ) - -Extends the base class to add Tax information for the Sku, in a new tab. - -=cut - -sub getEditForm { - my $self = shift; - my $session = $self->session; - - my $tabform = $self->SUPER::getEditForm; - - # TODO once comments can be submitted using AJAX this will work... - # be sure to uncomment the tab in the next function also... - #my $comments = $tabform->getTab( 'comments' ); - -# $comments->div({name => 'comments', -# contentCallback => sub { $self->getFormattedComments }, -# }); - - return $tabform; -} - -#------------------------------------------------------------------- - =head2 getEditTabs ( ) defines 2 new tabs. @@ -561,15 +486,11 @@ in the future when the sku asset is created from this data. =cut -sub getEditTabs { - my $self = shift; - my $i18n = WebGUI::International->new($self->session,"Asset_EMSSubmission"); - my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku"); - return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9], - # The comment tab is not available because comments are not AJAX yet... - # ['comments', $i18n->get('comments'), 9] - ); -} +override getEditTabs => sub { + my $self = shift; + my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku"); + return (super(), ['shop', $sku_i18n->get('shop'), 9],); +}; #------------------------------------------------------------------- @@ -592,11 +513,11 @@ Making private. See WebGUI::Asset::indexContent() for additonal details. =cut -sub indexContent { +override indexContent => sub { my $self = shift; - my $indexer = $self->next::method; + my $indexer = super(); $indexer->setIsPublic(0); -} +}; #------------------------------------------------------------------- @@ -609,10 +530,6 @@ See WebGUI::Asset::prepareView() for details. sub prepareView { my $self = shift; $self->ems->prepareView; - #$self->next::method(); - #my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") ); - #$template->prepare($self->getMetaDataAsTemplateVariables); - #$self->{_viewTemplate} = $template; } #---------------------------------------------------------------- @@ -659,50 +576,6 @@ sub processForm { return $params; } -#------------------------------------------------------------------- - -=head2 processPropertiesFromFormPost ( ) - -Used to process properties from the form posted. Do custom things with -noFormPost fields here, or do whatever you want. This method is called -when /yourAssetUrl?func=editSave is requested/posted. - -=cut - -sub processPropertiesFromFormPost { - my $self = shift; - $self->next::method; -} - -#------------------------------------------------------------------- - -=head2 purge ( ) - -This method is called when data is purged by the system. -removes collateral data associated with a NewAsset when the system -purges it's data. This method is unnecessary, but if you have -auxiliary, ancillary, or "collateral" data or files related to your -asset instances, you will need to purge them here. - -=cut - -#sub purge { -# my $self = shift; -# return $self->next::method; -#} - -#------------------------------------------------------------------- - -=head2 purgeRevision ( ) - -This method is called when data is purged by the system. - -=cut - -#sub purgeRevision { -# my $self = shift; -# return $self->next::method; -#} #------------------------------------------------------------------- From 5992a1dc4a52beef9da78e095615ce1d0ee368f8 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 13:43:15 -0700 Subject: [PATCH 19/32] Update changeIobStatus for WebGUI::Paths --- sbin/changeIobStatus.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/changeIobStatus.pl b/sbin/changeIobStatus.pl index 2f5b97209..2b68578b8 100755 --- a/sbin/changeIobStatus.pl +++ b/sbin/changeIobStatus.pl @@ -45,7 +45,7 @@ pod2usage( verbose => 2 ) if $help; pod2usage() unless $configFile; print "Starting up...\n" unless ($quiet); -my $session = WebGUI::Session->open($webguiRoot,$configFile); +my $session = WebGUI::Session->open($configFile); if ($userMessageFile) { print "Opening message file.." unless ($quiet); From 22f9a209bd9dfcf95cf80649027fade44607ea97 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 15:02:45 -0700 Subject: [PATCH 20/32] Update this test for new code in Operation/Help --- t/i18n/help.t | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/i18n/help.t b/t/i18n/help.t index 0d2e6b57a..bab4ac100 100644 --- a/t/i18n/help.t +++ b/t/i18n/help.t @@ -16,7 +16,7 @@ use lib "$FindBin::Bin/../lib"; ##t/lib use WebGUI::Test; use WebGUI::Operation::Help; use WebGUI::International; -use WebGUI::Session; +use WebGUI::Pluggable; use Data::Dumper; #The goal of this test is to verify all the i18n labels in @@ -28,14 +28,14 @@ my $numTests = 0; my $session = WebGUI::Test->session; -my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session); +my @helpFileSet = WebGUI::Pluggable::findAndLoad('WebGUI::Help'); my %helpTable; -foreach my $helpSet (@helpFileSet) { - my $helpName = $helpSet->[1]; - my $help = WebGUI::Operation::Help::_load($session, $helpName); - $helpTable{ $helpName } = $help; +foreach my $helpFile (@helpFileSet) { + my ($namespace) = $helpFile =~ m{WebGUI::Help::(.+$)}; + my $help = WebGUI::Operation::Help::_load($session, $namespace); + $helpTable{ $namespace } = $help; } ##Scan #1, find all labels in the help system. body, title, @fields From ea17973b30801c22c81298195e6b75ba4ead1d70 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 15:03:32 -0700 Subject: [PATCH 21/32] There aren't any cache modules any longer. --- t/Cache.t | 145 -------------------------------------------- t/Cache/Database.t | 79 ------------------------ t/Cache/FileCache.t | 115 ----------------------------------- 3 files changed, 339 deletions(-) delete mode 100644 t/Cache.t delete mode 100644 t/Cache/Database.t delete mode 100644 t/Cache/FileCache.t diff --git a/t/Cache.t b/t/Cache.t deleted file mode 100644 index 45289b163..000000000 --- a/t/Cache.t +++ /dev/null @@ -1,145 +0,0 @@ -# vim:syntax=perl -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------ -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------ - -# Write a little about what this script tests. -# -# - -use FindBin; -use strict; -use lib "$FindBin::Bin/lib"; -use Test::More; -use WebGUI::Test; # Must use this before any other WebGUI modules -use WebGUI::Session; -use WebGUI::Cache; - -#---------------------------------------------------------------------------- -# Init -my $session = WebGUI::Test->session; - - -#---------------------------------------------------------------------------- -# Tests - -plan tests => 11; # Increment this number for each test you create - -#---------------------------------------------------------------------------- - -my $cache = WebGUI::Cache->new($session, 1); -isa_ok($cache, 'WebGUI::Cache'); -is($cache->parseKey("andy"), $session->config->getFilename.":andy", "parseKey single key"); -is($cache->parseKey(["andy","red"]), $session->config->getFilename.":andy:red", "parseKey composite key"); -$cache->set("Shawshank","Prison"); -is($cache->get("Shawshank"), "Prison", "set/get"); -$cache->set(["andy", "dufresne"], "Prisoner"); -is($cache->get(["andy", "dufresne"]), "Prisoner", "set/get composite"); -my ($a, $b) = @{$cache->mget(["Shawshank",["andy", "dufresne"]])}; -is($a, "Prison", "mget first value"); -is($b, "Prisoner", "mget second value"); -$cache->delete("Shawshank"); -is(eval{$cache->get("Shawshank")}, undef, 'delete'); -$cache->flush; -is(eval{$cache->get(["andy", "dufresne"])}, undef, 'flush'); -$cache->setByHttp("http://www.google.com/"); -cmp_ok($cache->get("http://www.google.com/"), 'ne', '', 'setByHttp'); -my $longValue ='abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*( - '; -$cache->set("really-long-value",$longValue); -is($cache->get("really-long-value"), $longValue, "set/get really long value"); - - -#---------------------------------------------------------------------------- -# Cleanup -END { - -} -#vim:ft=perl diff --git a/t/Cache/Database.t b/t/Cache/Database.t deleted file mode 100644 index 0d0fe1dfb..000000000 --- a/t/Cache/Database.t +++ /dev/null @@ -1,79 +0,0 @@ -# vim:syntax=perl -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------ -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------ - -# Write a little about what this script tests. -# -# - -use FindBin; -use strict; -use lib "$FindBin::Bin/../lib"; -use Storable qw(freeze thaw); -use Test::More; -use Time::HiRes; -use WebGUI::Test; # Must use this before any other WebGUI modules -use WebGUI::Session; -use WebGUI::Cache::Database; - -#---------------------------------------------------------------------------- -# Init -my $session = WebGUI::Test->session; - -# presupposes that there are cached items to test -my $cacheEntries = $session->db->buildArrayRefOfHashRefs("select expires,cachekey,namespace,content from cache order by rand() limit 100"); - -#---------------------------------------------------------------------------- -# Tests - -plan tests => 2 + scalar(@{$cacheEntries}); # Increment this number for each test you create - -#---------------------------------------------------------------------------- -# put your tests here - -my $cache = WebGUI::Cache::Database->new($session, "this", "that"); -my $testValue = "a rock that has no earthly business in that field"; - -$cache->set($testValue); -is($cache->get, $testValue, "set/get works"); -$cache->delete; -is($cache->get, undef, "delete works"); - - - -# performance tests -my $numTests = 0; -my $totalTime = 0; -foreach my $entry (@{$cacheEntries}) { - my $start = [Time::HiRes::gettimeofday]; - my $cache = WebGUI::Cache::Database->new($session, $entry->{cachekey}, $entry->{namespace}); - $cache->{_key} = $entry->{cachekey}; # evil: don't do this at home kids - my $value = $cache->get; - if ($entry->{expires} > time()) { - my $entryValue = $entry->{content}; - eval { $entryValue = thaw($entryValue); }; - $entryValue = ($entryValue && ref $entryValue) ? $$entryValue : undef; - is_deeply($value, $entryValue, "cache entry is valid"); - } - else { - is($value, undef, "cache entry has timed out"); - } - $numTests++; - $totalTime += Time::HiRes::tv_interval($start); -} -print "\nTime to run $numTests cache tests is $totalTime seconds. Average time per test is ".($totalTime/$numTests)." seconds.\n" if ($numTests > 0); -# end performance tests - - -#---------------------------------------------------------------------------- -# Cleanup -END { - -} diff --git a/t/Cache/FileCache.t b/t/Cache/FileCache.t deleted file mode 100644 index 2ac4add4f..000000000 --- a/t/Cache/FileCache.t +++ /dev/null @@ -1,115 +0,0 @@ -# vim:syntax=perl -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------ -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------ - -# Write a little about what this script tests. -# -# - -use FindBin; -use strict; -use lib "$FindBin::Bin/../lib"; -use Test::More; -use Test::Deep; -use Path::Class; -use File::Path; -use File::Basename qw(basename); - -use WebGUI::Test; # Must use this before any other WebGUI modules -use WebGUI::Session; -use WebGUI::Cache; - -#---------------------------------------------------------------------------- -# Init -my $session = WebGUI::Test->session; - - -#---------------------------------------------------------------------------- -# Tests - -my $tests = 14; -plan tests => 1 + $tests; - -#---------------------------------------------------------------------------- -# put your tests here - -my $origCacheType = $session->config->get('cacheType'); -$session->config->set('cacheType', 'WebGUI::Cache::FileCache'); - -my $origCacheRoot = $session->config->get('fileCacheRoot'); -$session->config->delete('fileCacheRoot'); - -my $loaded = use_ok('WebGUI::Cache::FileCache'); - -SKIP: { - - skip 'Unable to load module WebGUI::Cache::FileCache', $tests unless $loaded; - - my $cacher = WebGUI::Cache->new($session, 'ReservedForTests'); - - isa_ok($cacher, 'WebGUI::Cache::FileCache', 'WebGUI::Cache creates the correct object type'); - isa_ok($cacher->session, 'WebGUI::Session', 'session method returns a session object'); - - cmp_deeply( - $cacher, - noclass({ - _session => ignore(), - _namespace => basename(WebGUI::Test->file), - _key => re('[a-zA-Z0-9+\-]{22}'), - }), - 'New FileCache object has correct defaults', - ); - - $cacher = WebGUI::Cache->new($session, 'ReservedForTests', 'ReservedForTests'); - - cmp_deeply( - $cacher, - noclass({ - _session => ignore(), - _namespace => 'ReservedForTests', - _key => re('[a-zA-Z0-9+\-]{22}'), - }), - 'Second fileCache object was recreated with custom namespace', - ); - - my $root = '/tmp'; ##Default for Unix testing. Need to extend this for Windows someday... - my $namespace = Path::Class::Dir->new($root, qw/WebGUICache ReservedForTests/); - is($cacher->getNamespaceRoot, $namespace->stringify, 'getNamespaceRoot returns the correct path'); - - ok(! -e $cacher->getNamespaceRoot, 'The namespace does not exist in the filesystem'); - - my $folder = $namespace->subdir($cacher->{_key}); - is($cacher->getFolder, $folder->stringify, 'getFolder returns the correct path, which is the namespace with a key subdirectory'); - ok(! -e $cacher->getFolder, 'The folder does not exist in the filesystem'); - - $cacher->set('Some value'); - ok( -e $namespace->stringify, 'setting data into the cache creates the namespace dir'); - ok( -e $folder->stringify, 'setting data into the cache creates the folder dir'); - ok( -e $folder->file('expires')->stringify, 'expiry file was created'); - ok( -e $folder->file('cache')->stringify, 'cache file was created'); - - $cacher->delete(); - ok(! -e $cacher->getFolder, 'delete removes the cache folder'); - - $cacher->flush(); - ok(! -e $cacher->getNamespaceRoot, 'purge removes the namespace folder'); - - undef $cacher; - -} - -#---------------------------------------------------------------------------- -# Cleanup -END { - $session->config->set('cacheType', $origCacheType); - if ($origCacheRoot) { - $session->config->get('fileCacheRoot', $origCacheRoot); - } -} From a29c6aed04bae791e5f6b6dfdda8d1d4b1224634 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 15:09:14 -0700 Subject: [PATCH 22/32] Update mandatory_template_vars test for new Asset code. --- t/mandatory_template_vars.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/mandatory_template_vars.t b/t/mandatory_template_vars.t index cd85dbe59..c42819532 100644 --- a/t/mandatory_template_vars.t +++ b/t/mandatory_template_vars.t @@ -165,7 +165,7 @@ plan tests => $numTests; foreach my $tmpl ( @tmplVarTable ) { my $tmplId = $tmpl->{id}; - my $tmplAsset = WebGUI::Asset->newByDynamicClass($session, $tmplId); + my $tmplAsset = eval { WebGUI::Asset->newById($session, $tmplId); }; my $tmplExists = is(ref($tmplAsset), 'WebGUI::Asset::Template', "$tmplId exists"); SKIP: { skip("$tmplId could not be found", $tmpl->{numTests} ) unless $tmplExists; From 45e1c01fc954d0fbc48c61140d50d4c16691862a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 15:12:06 -0700 Subject: [PATCH 23/32] Update Help/compiled for new operational code. --- t/Help/compiled.t | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/t/Help/compiled.t b/t/Help/compiled.t index f98e8cb0e..f68455ca9 100644 --- a/t/Help/compiled.t +++ b/t/Help/compiled.t @@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; +use WebGUI::Pluggable; use WebGUI::Operation::Help; #The goal of this test is to verify that all entries in the lib/WebGUI/Help @@ -26,14 +27,14 @@ my $numTests = 0; my $session = WebGUI::Test->session; -my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session); +my @helpFileSet = WebGUI::Pluggable::findAndLoad('WebGUI::Help'); $numTests = scalar @helpFileSet; #One for each help compile plan tests => $numTests; -foreach my $helpSet (@helpFileSet) { - my $helpName = $helpSet->[1]; - my $help = WebGUI::Operation::Help::_load($session, $helpName); - ok(keys %{ $help }, "$helpName compiled"); +foreach my $helpFile (@helpFileSet) { + my ($namespace) = $helpFile =~ m{WebGUI::Help::(.+$)}; + my $help = WebGUI::Operation::Help::_load($session, $namespace); + ok(keys %{ $help }, "$namespace compiled"); } From c8075d98cdbb5e5b32192597d660fcc8986d5e16 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 15:21:06 -0700 Subject: [PATCH 24/32] Add a missing module use line. --- lib/WebGUI/Form/Email.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/WebGUI/Form/Email.pm b/lib/WebGUI/Form/Email.pm index 976cf5318..a16ab6925 100644 --- a/lib/WebGUI/Form/Email.pm +++ b/lib/WebGUI/Form/Email.pm @@ -17,6 +17,7 @@ package WebGUI::Form::Email; use strict; use base 'WebGUI::Form::Text'; use WebGUI::International; +use WebGUI::Utility; =head1 NAME From 9162bd68c9bfad947dec981fb25477dd3c7a6c14 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 17:53:17 -0700 Subject: [PATCH 25/32] Return the correct path for the WebGUI lib directory in WebGUI::Test. Should probably just use WebGUI::Path instead. --- t/lib/WebGUI/Test.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index e97f8e9b7..3ed762aa5 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -444,7 +444,7 @@ Returns the full path to the WebGUI lib directory, usually /data/WebGUI/lib. =cut -our $WEBGUI_LIB = File::Spec->catdir( $WEBGUI_TEST_ROOT, File::Spec->updir ); +our $WEBGUI_LIB = File::Spec->catdir( $WEBGUI_TEST_ROOT, File::Spec->updir, 'lib' ); sub lib { return our $WEBGUI_LIB; From 6154044719ef183fa663acad212b251e58141285 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 17:56:30 -0700 Subject: [PATCH 26/32] when using goto on objects, must restore $self into @_... --- lib/WebGUI/Definition/Meta/Class.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebGUI/Definition/Meta/Class.pm b/lib/WebGUI/Definition/Meta/Class.pm index 1b2bab583..112b7be2c 100644 --- a/lib/WebGUI/Definition/Meta/Class.pm +++ b/lib/WebGUI/Definition/Meta/Class.pm @@ -76,7 +76,7 @@ Returns an array of all attribute names across all meta classes. =cut sub get_all_attributes_list { - my $self = shift; + my ($self) = @_; if ($self->is_immutable) { return @{ $self->{__immutable}{get_all_attributes_list} ||= [ $self->_get_all_attributes_list ] }; } From 855b59f61d4420923febbda576101a9aa32ed4c6 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 17:58:00 -0700 Subject: [PATCH 27/32] Similar changes as to Definition::Meta::Class in --::Asset --- lib/WebGUI/Definition/Meta/Asset.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebGUI/Definition/Meta/Asset.pm b/lib/WebGUI/Definition/Meta/Asset.pm index 1627b958c..2ec6375d0 100644 --- a/lib/WebGUI/Definition/Meta/Asset.pm +++ b/lib/WebGUI/Definition/Meta/Asset.pm @@ -76,7 +76,7 @@ Returns an array of the names of all tables in every class used by this class. =cut sub get_tables { - my $self = shift; + my ($self) = @_; if ($self->is_immutable) { return @{ $self->{__immutable}{get_tables_methods} ||= [ $self->_get_tables ] }; } From 2fad20dcd0fee65ae46f7aeb7cc08ea606b6a038 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 18:02:17 -0700 Subject: [PATCH 28/32] Exception handling when trying to get assets for their content. --- lib/WebGUI/FilePump/Bundle.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/FilePump/Bundle.pm b/lib/WebGUI/FilePump/Bundle.pm index 8df18aff9..65f5afaf0 100644 --- a/lib/WebGUI/FilePump/Bundle.pm +++ b/lib/WebGUI/FilePump/Bundle.pm @@ -3,6 +3,7 @@ package WebGUI::FilePump::Bundle; use base qw/WebGUI::Crud WebGUI::JSONCollateral/; use strict; use WebGUI::International; +use WebGUI::Exception; use WebGUI::Utility; use URI; use Path::Class; @@ -508,8 +509,8 @@ sub fetchAsset { my $url = $uri->opaque; $url =~ s{^/+}{}; - my $asset = WebGUI::Asset->newByUrl($self->session, $url); - return {} unless $asset; + my $asset = eval {WebGUI::Asset->newByUrl($self->session, $url);}; + return {} if Exception::Class->caught(); ##Check for a snippet, or snippet subclass? my $guts = { lastModified => $asset->get('lastModified'), From 361299e2936a4326204ca9252453516449850ac9 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 18:13:31 -0700 Subject: [PATCH 29/32] Use the right location for the WebGUI.pm fake file in Storage testing. --- t/Storage.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/Storage.t b/t/Storage.t index 37c726f9a..60efc6453 100644 --- a/t/Storage.t +++ b/t/Storage.t @@ -289,7 +289,7 @@ ok (!(-e $storage1->getPath("testfile-hash.file")), "rename file original file i #################################################### $storage1->addFileFromFilesystem( - WebGUI::Test->getTestCollateralPath('WebGUI.pm'), + WebGUI::Test->getTestCollateralPath('International/lib/WebGUI/i18n/PigLatin/WebGUI.pm'), ); ok( @@ -473,7 +473,7 @@ is($formStore->addFileFromFormPost('files'), undef, 'addFileFromFormPost returns $session->request->uploadFiles( 'oneFile', - [ WebGUI::Test->getTestCollateralPath('WebGUI.pm') ], + [ WebGUI::Test->getTestCollateralPath('International/lib/WebGUI/i18n/PigLatin/WebGUI.pm') ], ); is($formStore->addFileFromFormPost('oneFile'), 'WebGUI.pm', '... returns the name of the uploaded file'); cmp_bag($formStore->getFiles, [ qw/WebGUI.pm/ ], '... adds the file to the storage location'); From 3d34cf332365ad7ec906501b2dbc4289cd99b4ef Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 18:18:11 -0700 Subject: [PATCH 30/32] Fix typos in VersionTag.t --- t/VersionTag.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/VersionTag.t b/t/VersionTag.t index 389d5f620..34e3e659f 100644 --- a/t/VersionTag.t +++ b/t/VersionTag.t @@ -236,7 +236,7 @@ is($siteWideTag->getId(), $siteWideTagId, 'versionTagMode siteWide: reclaim site ## Through in a new session as different user -my $admin_session = WebGUI::Session->open($WebGUI::Test->file); +my $admin_session = WebGUI::Session->open(WebGUI::Test->file); $admin_session->user({'userId' => 3}); WebGUI::Test->sessionsToDelete($admin_session); @@ -301,7 +301,7 @@ $adminUserTag->rollback(); is($tag->getAssetCount, 1, qq{$test_prefix [singlePerUser] tag with 1 asset}); # create admin session - my $admin_session = WebGUI::Session->open($WebGUI::Test->file); + my $admin_session = WebGUI::Session->open(WebGUI::Test->file); addToCleanup($session); $admin_session->user({'userId' => 3}); From 1450d1361d774e0ee53522a132c3631b1cbef0ac Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 May 2010 18:27:39 -0700 Subject: [PATCH 31/32] Fix POD problems --- lib/WebGUI/Asset/Wobject/Survey.pm | 2 +- t/lib/WebGUI/Test/Activity.pm | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index 551eb0aae..3255ac8ee 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -1975,7 +1975,7 @@ sub prepareShowSurveyTemplate { Serializes the SurveyJSON instance and persists it to the database. Calling this method is only required if you have directly accessed and modified -the L<"surveyJSON"> object. +the L object. =cut diff --git a/t/lib/WebGUI/Test/Activity.pm b/t/lib/WebGUI/Test/Activity.pm index 5bbe11422..4525e180a 100644 --- a/t/lib/WebGUI/Test/Activity.pm +++ b/t/lib/WebGUI/Test/Activity.pm @@ -3,16 +3,16 @@ package WebGUI::Test::Activity; use WebGUI::Workflow; use WebGUI::Test; -=head Name +=head1 Name package WebGUI::Test::Activity; -=head Description +=head1 Description This package encapsulates the code required to run an activity. -=head Usage +=head1 Usage use WebGUI::Test::Activity; @@ -27,17 +27,21 @@ is( $instance->run, 'complete', 'activity complete' ); is( $instance->run, 'done', 'activity done' ); $instance->delete; -=head methods +=head1 methods =head2 create -=params +=head3 session -session -- the session variable +the session variable -class -- the class for the activity to run +=head3 class -params -- params to set in the workflow +the class for the activity to run + +=head3 params + +params to set in the workflow =cut From 7c87a34bf55df8cce46e9d4f344ac33b46d3ba98 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sat, 8 May 2010 16:35:54 -0500 Subject: [PATCH 32/32] clean up some parts of WebGUI::Test --- t/lib/WebGUI/Test.pm | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index 3ed762aa5..c87a15904 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -57,8 +57,6 @@ our @EXPORT_OK = qw(session config collateral); my $CLASS = __PACKAGE__; -my @guarded; - sub import { our $CONFIG_FILE = $ENV{ WEBGUI_CONFIG }; @@ -80,7 +78,7 @@ sub _initSession { my $session = our $SESSION = $CLASS->newSession(1); my $originalSetting = clone $session->setting->get; - push @guarded, Scope::Guard->new(sub { + $CLASS->addToCleanup(sub { while (my ($param, $value) = each %{ $originalSetting }) { $session->setting->set($param, $value); } @@ -110,7 +108,7 @@ sub _initSession { my ($label, $table) = @checkCount[$i, $i+1]; $initCounts{$table} = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table); } - push @guarded, Scope::Guard->new(sub { + $CLASS->addToCleanup(sub { for ( my $i = 0; $i < @checkCount; $i += 2) { my ($label, $table) = @checkCount[$i, $i+1]; my $quant = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table); @@ -127,19 +125,6 @@ END { $CLASS->cleanup; } -sub cleanup { - # remove guards in reverse order they were added, triggering all of the - # requested cleanup operations - pop @guarded - while @guarded; - - if ( our $SESSION ) { - $SESSION->var->end; - $SESSION->close; - undef $SESSION; - } -} - #---------------------------------------------------------------------------- =head2 newSession ( $noCleanup ) @@ -159,7 +144,7 @@ sub newSession { my $session = WebGUI::Session->open( $CLASS->config ); $session->{_request} = $pseudoRequest; if ( ! $noCleanup ) { - $CLASS->sessionsToDelete($session); + $CLASS->addToCleanup($session); } return $session; } @@ -543,7 +528,7 @@ sub prepareMailServer { # Let it start up yo sleep 2; - push @guarded, Scope::Guard->new(sub { + $CLASS->addToCleanup(sub { # Close SMTPD if ($smtpdPid) { kill INT => $smtpdPid; @@ -576,7 +561,7 @@ sub originalConfig { } # add cleanup handler if this is the first time we were run if (! keys %originalConfig) { - push @guarded, Scope::Guard->new(sub { + $class->addToCleanup(sub { while (my ($key, $value) = each %originalConfig) { if (defined $value) { $CLASS->session->config->set($key, $value); @@ -592,7 +577,7 @@ sub originalConfig { #---------------------------------------------------------------------------- -=head2 getMail ( ) +=head2 getMail ( ) Read a sent mail from the prepared mail server (L) @@ -600,7 +585,7 @@ Read a sent mail from the prepared mail server (L) sub getMail { my $json; - + if ( !$smtpdSelect ) { return from_json ' { "error": "mail server not prepared" }'; } @@ -611,11 +596,11 @@ sub getMail { else { $json = ' { "error": "mail not sent" } '; } - + if (!$json) { $json = ' { "error": "error in getting mail" } '; } - + return from_json( $json ); } @@ -635,7 +620,7 @@ sub getMailFromQueue { if ( !$smtpdSelect ) { $class->prepareMailServer; } - + my $messageId = $CLASS->session->db->quickScalar( "SELECT messageId FROM mailQueue" ); warn $messageId; return unless $messageId; @@ -646,6 +631,7 @@ sub getMailFromQueue { return $class->getMail; } + #---------------------------------------------------------------------------- =head2 sessionsToDelete ( $session, [$session, ...] ) @@ -660,7 +646,7 @@ This is a class method. sub sessionsToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -677,7 +663,7 @@ This is a class method. sub assetsToPurge { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -693,7 +679,7 @@ This is a class method. sub groupsToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } @@ -710,7 +696,7 @@ This is a class method. sub storagesToDelete { my $class = shift; - push @guarded, cleanupGuard(map { + $class->addToCleanup(map { ref $_ ? $_ : ('WebGUI::Storage' => $_) } @_); } @@ -727,7 +713,7 @@ This is a class method. sub tagsToRollback { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -743,7 +729,7 @@ This is a class method. sub usersToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -759,7 +745,7 @@ This is a class method. sub workflowsToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } @@ -973,12 +959,26 @@ This is a class method. =cut +my @guarded; sub addToCleanup { shift if eval { $_[0]->isa($CLASS) }; push @guarded, cleanupGuard(@_); } +sub cleanup { + # remove guards in reverse order they were added, triggering all of the + # requested cleanup operations + pop @guarded + while @guarded; + + if ( our $SESSION ) { + $SESSION->var->end; + $SESSION->close; + undef $SESSION; + } +} + #---------------------------------------------------------------------------- =head1 BUGS