You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2011/01/24 23:21:02 UTC
svn commit: r1063026 - in /incubator/deltacloud/trunk/server/lib:
deltacloud/helpers/application_helper.rb drivers.rb
Author: lutter
Date: Mon Jan 24 22:21:02 2011
New Revision: 1063026
URL: http://svn.apache.org/viewvc?rev=1063026&view=rev
Log:
Only make available/access drivers within a request
There is no point talking about a driver outside the context of a request
anymore, since we don't know until request time what driver the user wants.
Because of the lazy instantiation of drivers, accessing a driver outside of
a request can lead to nasty races.
* lib/drivers.rb: do not include module Deltacloud in Object
* lib/deltacloud/helpers/application_helper.rb: include module Deltacloud
Modified:
incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
incubator/deltacloud/trunk/server/lib/drivers.rb
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb?rev=1063026&r1=1063025&r2=1063026&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb Mon Jan 24 22:21:02 2011
@@ -19,6 +19,8 @@
module ApplicationHelper
+ include Deltacloud
+
def bread_crumb
s = "<ul class='breadcrumb'><li class='first'><a href='#{url_for('/')}'>δ</a></li>"
url = request.path_info.split('?') #remove extra query string parameters
Modified: incubator/deltacloud/trunk/server/lib/drivers.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/drivers.rb?rev=1063026&r1=1063025&r2=1063026&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/drivers.rb (original)
+++ incubator/deltacloud/trunk/server/lib/drivers.rb Mon Jan 24 22:21:02 2011
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+# FIXME: This should be moved into lib/ and be called Deltacloud::Drivers
+# or some such
module Deltacloud
DRIVERS = {
:ec2 => { :name => "EC2" },
@@ -48,9 +50,9 @@ module Deltacloud
DRIVERS[:"#{driver_symbol}"][:name]
end
- def driver_class_name
+ def driver_class
basename = DRIVERS[:"#{driver_symbol}"][:class] || "#{driver_name}Driver"
- "Deltacloud::Drivers::#{driver_name}::#{basename}"
+ Deltacloud::Drivers.const_get(driver_name).const_get(basename)
end
def driver_source_name
@@ -58,20 +60,13 @@ module Deltacloud
end
def driver_mock_source_name
- return File.join('deltacloud', 'drivers', "#{driver_symbol}",
+ return File.join('deltacloud', 'drivers', "#{driver_symbol}",
"#{driver_symbol}_driver.rb") if driver_name.eql? 'Mock'
end
def driver
require driver_source_name
- #require 'deltacloud/base_driver/mock_driver.rb'
- if Sinatra::Application.environment.eql? :test
- require driver_mock_source_name if driver_mock_source_name
- end
-
- @driver ||= eval( driver_class_name ).new
+ @driver ||= driver_class.new
end
end
-
-include Deltacloud