incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962248 - in /incubator/deltacloud/trunk/server: lib/deltacloud/helpers/driver_helper.rb server.rb
Date Thu, 08 Jul 2010 23:40:49 GMT
Author: lutter
Date: Thu Jul  8 23:40:48 2010
New Revision: 962248

URL: http://svn.apache.org/viewvc?rev=962248&view=rev
Log:
Error handling: remove safely and catch_auth from DriverHelper

  * catch_auth was only used in the Rails controllers, but nowhere in the
    Sinatra version
  * safely was producing output when it shouldn't; error handling should be
    left to the toplevel server control

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers/driver_helper.rb
    incubator/deltacloud/trunk/server/server.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/driver_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/driver_helper.rb?rev=962248&r1=962247&r2=962248&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/driver_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/driver_helper.rb Thu Jul  8 23:40:48
2010
@@ -26,23 +26,4 @@ module DriverHelper
       Converters::XMLConverter.new( self, type ).convert(obj)
     end
   end
-
-  def catch_auth
-    begin
-      yield
-    rescue Deltacloud::AuthException => e
-      authenticate_or_request_with_http_basic() do |n,p|
-      end
-    end
-  end
-
-  def safely(&block)
-    begin
-      block.call
-    rescue Deltacloud::AuthException => e
-      @response.status=403
-      "<error>#{e.message}</error>"
-    end
-  end
-
 end

Modified: incubator/deltacloud/trunk/server/server.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/server.rb?rev=962248&r1=962247&r2=962248&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/server.rb (original)
+++ incubator/deltacloud/trunk/server/server.rb Thu Jul  8 23:40:48 2010
@@ -42,25 +42,21 @@ def filter_all(model)
     filter.merge!(:owner_id => params[:owner_id]) if params[:owner_id]
     filter.merge!(:state => params[:state]) if params[:state]
     filter = nil if filter.keys.size.eql?(0)
-    safely do
-      singular = model.to_s.singularize.to_sym
-      @elements = driver.send(model.to_sym, credentials, filter)
-      instance_variable_set(:"@#{model}", @elements)
-      respond_to do |format|
-        format.xml  { return convert_to_xml(singular, @elements) }
-        format.html { haml :"#{model}/index" }
-      end
+    singular = model.to_s.singularize.to_sym
+    @elements = driver.send(model.to_sym, credentials, filter)
+    instance_variable_set(:"@#{model}", @elements)
+    respond_to do |format|
+      format.xml  { return convert_to_xml(singular, @elements) }
+      format.html { haml :"#{model}/index" }
     end
 end
 
 def show(model)
-  safely do
-    @element = driver.send(model, credentials, { :id => params[:id]} )
-    instance_variable_set("@#{model}", @element)
-    respond_to do |format|
-      format.xml { return convert_to_xml(model, @element) }
-      format.html { haml :"#{model.to_s.pluralize}/show" }
-    end
+  @element = driver.send(model, credentials, { :id => params[:id]} )
+  instance_variable_set("@#{model}", @element)
+  respond_to do |format|
+    format.xml { return convert_to_xml(model, @element) }
+    format.html { haml :"#{model.to_s.pluralize}/show" }
   end
 end
 
@@ -209,12 +205,10 @@ get "/api/instances/new" do
 end
 
 def instance_action(name)
-  safely do
-    @instance = driver.send(:"#{name}_instance", credentials, params[:id])
-    respond_to do |format|
-      format.xml { return convert_to_xml(:instance, @instance) }
-      format.html { haml :"instances/show" }
-    end
+  @instance = driver.send(:"#{name}_instance", credentials, params[:id])
+  respond_to do |format|
+    format.xml { return convert_to_xml(:instance, @instance) }
+    format.html { haml :"instances/show" }
   end
 end
 



Mime
View raw message