view · edit · sidebar · attach · print · history

20120227-odba-and-drbprocess

<< | Index | >>


summary

  • learned ODBA and models in ch.oddb.org
  • started to create sample application to learn more structure of oddb.org with sbsm, htmlgrid, (now without odba)
    • I could connect from client (via Apache) to DRbServer (like a oddbd).
    • But, I could not yet make response in State class.

index


ODBA

ODBA (Open DataBase Access)

  • Storage is Singleton
  • Cache is Singleton
    • replaced Stub object
  • ODBA::Stub object are created into followings methods
    • ODBA::Persistable.odba_isolated_stub (via odba_dup)
    • ODBA::Persistable.odba_replace_persistables
    • ODBA::Persistable.odba_stubize
    • odba_stubize in Array, Hash included Persistable
  • We can access original object by ODBA::Stub.odba_instance (alias to odba_receiver).

in ODBA::Stub

...
    def method_missing(meth_symbol, *args, &block)
      if(NO_OVERRIDE.include?(meth_symbol))
        super
      else
        odba_instance.send(meth_symbol, *args, &block)
      end 
    end 
    def respond_to?(msg_id, *args)
      case msg_id
      when :_dump, :marshal_dump
        false
      when *NO_OVERRIDE
        super
      else
        odba_instance.respond_to?(msg_id, *args)
      end 
    end 
...

ODBA in ODDB

  • ODDB each model class include ODDB::Persistence
    • These Models has parent "*Common" class (Class for Drugs)
      • Registration
      • Sequence
      • Package (directly include ODBA::Persistable, also)
  • ODDB::Persistence include ODBA::Persistable

check via bin/admin

ch.oddb> registrations.first
-> ["00035", #<ODBA::Stub:74052420#712139 @odba_class=ODDB::Registration @odba_container=111505790#22>]
ch.oddb> registrations.values.first.class
ODDB::Registration
ch.oddb> registrations.values.first.is_a? ODBA::Stub
-> true
  • We can access cache of ODBA via ODBA::Cache.instance', directly
ch.oddb> ODBA.cache.class
-> ODBA::Cache
ch.oddb> ODBA.cache.count(Registration)
-> 10978

check with "inderal"

ch.oddb> registration('31706')
-> #<ODDB::Registration:0xdbf24f0>
ch.oddb> registration('31706').company
-> AstraZeneca AG
ch.oddb> registration('31706').odba_id
-> 28487
ch.oddb> ODBA.cache.fetch(28487, :bin_admin)
-> #<ODDB::Registration:0xdbf24f0>
ch.oddb> ODBA.cache.fetch(28487, :bin_admin).company
-> AstraZeneca AG 

connect to DRbServer

I started to create sample application with most tiny codes

  • setup DRbServer application.
  • use sbsm, htmlgrid.
  • connect from client (via Apache) to server process.

src/util/sampleapp.rb

module SAMPLE
  class App < SBSM::DRbServer
    MEMORY_LIMIT = 20480
    def initialize opts={}
      start = Time.now
      puts "init system"
      puts "init system: #{Time.now - start}"
      puts "setup drb-delegation"
      # pending
      puts "system initialized"
      puts "initialized: #{Time.now - start}"
      super()
    end 
  end 
end

NOTE: make sure to call SBSM::DRbServer.initialize() in this server application.

return response from DRbServer

created simple state class, and wiew, template.
then send request from browser, got following errors,

error in SBSM::Session#process: /
NoMethodError
undefined method `validate' for nil:NilClass
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:241:in `block in import_user_input'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:224:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:224:in `import_user_input'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:359:in `process'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:170:in `block in drb_process'
error in SBSM::Session#to_html: /
NoMethodError
undefined method `new' for nil:NilClass
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/state.rb:243:in `view'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/state.rb:179:in `to_html'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:447:in `to_html'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:171:in `block in drb_process'
<internal:prelude>:10:in `synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:169:in `drb_process'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
error in SBSM::Session#http_headers: /
NoMethodError
undefined method `new' for nil:NilClass
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/state.rb:243:in `view'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/state.rb:144:in `http_headers'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:320:in `http_headers'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'

Are my some definitions in State and Session and wrong ?
in /path/to/sbsm/state.rb

Note by Masa:


The error comes from Nil of @klass in SBSM::State class

 http://dev.ywesee.com/wiki.php/Yasu/20120227-odba-and-drbprocess#response_from_drbserver

This probably means that your original State class is not called. Please check if your State and Session class is actually called or not.


....
   def view
      klass = @default_view
      if(klass.is_a?(Hash))
        klass = klass.fetch(@session.user.class) {
          klass[:default]
        }   
      end 
      model = @filter ? @filter.call(@model) : @model
      view = klass.new(model, @session)
      @http_headers = view.http_headers
      view
    end
...

TODO:

  • to fix errors when Server application makes response in State Class.
view · edit · sidebar · attach · print · history
Page last modified on February 28, 2012, at 08:30 AM