Sha256: 2d6d58ac9f664f5909af9e015c0cd504e12e6f896405dbd83583d6e7fccbc03a

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 KB

Contents

require 'omf_common/lobject'
require 'omf-web/session_store'
require 'omf-web/rack/rack_exceptions'

module OMF::Web::Rack
      
  class UpdateHandler < OMF::Common::LObject
    
    def initialize(opts = {})
    end
    
    
    def call(env)
      req = ::Rack::Request.new(env)
      begin
        sid = req.params['sid']
        unless sid
          raise MissingArgumentException.new "Called update without a 'sid' (#{req.inspect})"
        end
        Thread.current["sessionID"] = sid
        
        ds_id = req.path_info[1 .. -1].to_sym
        ds_proxy = OMF::Web::DataSourceProxy[ds_id]
        unless ds_proxy
          raise MissingArgumentException.new "Can't find data source proxy '#{ds_id}'"
        end
        body, headers = ds_proxy.on_update(req)
        
        # comp_path = id.split(':')
        # h = OMF::Web::SessionStore.find_tab_from_path(comp_path)
        # Thread.current["sessionID"] = h[:sid]
        # tab_inst = h[:tab_inst]
        # sub_path = h[:sub_path]
        #body, headers = tab_inst.on_update(req, sub_path.dup)
      rescue MissingArgumentException => mex
        debug mex
        return [412, {"Content-Type" => 'text'}, [mex.to_s]]
      rescue Exception => ex
        error ex
        debug ex.to_s + "\n\t" + ex.backtrace.join("\n\t")
        return [500, {"Content-Type" => 'text'}, [ex.to_s]]
      end
      
      if headers.kind_of? String
        headers = {"Content-Type" => headers}
      end
      [200, headers, [body]] 
    end
  end # UpdateHandler
  
end # OMF:Web


      
        

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
omf_web-1.0.0 lib/omf-web/rack/update_handler.rb
omf_web-0.9.9 lib/omf-web/rack/update_handler.rb
omf_web-0.9.8 lib/omf-web/rack/update_handler.rb
omf_web-0.9.7 lib/omf-web/rack/update_handler.rb
omf_web-0.9.6 lib/omf-web/rack/update_handler.rb
omf_web-0.9.5 lib/omf-web/rack/update_handler.rb
omf_web-0.9.4 lib/omf-web/rack/update_handler.rb
omf_web-0.9.3 lib/omf-web/rack/update_handler.rb
omf_web-0.9.1 lib/omf-web/rack/update_handler.rb
omf_web-0.9 lib/omf-web/rack/update_handler.rb