view · edit · sidebar · attach · print · history

20120228-sbsm-htmlgrid-odba-mock-application

<< | Index | >>


summary

  • updated mock application. (sbsm, htmlgrid, odba)
  • learned State and event are specified by Session class.
    • SBSM needed SESSION and VALIDATOR in my Session class)
    • VALIDATOR parse request parameters.

commits (on github)

index


fixed VIEW and VALIDATOR definition

I could fix error of yesterday.
Tha problem is that my Session class was not called.

refs

If you use SBSM gem, make sure definitions of following constants in app file (like a oddbapp.rb).
We can load view in our Session class by these value.

  • SESSION
  • VALIDATOR

z.B.

This is the most tiny app file
src/util/shoeapp.rb (like a oddbapp.rb)

require 'sbsm/drbserver'
require 'sbsm/index'
require 'util/shoeconfig'
require 'util/session'
require 'util/validator'
require 'fileutils'

module SHOE
  class App < SBSM::DRbServer
    SESSION   = Session
    VALIDATOR = Validator
    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

How handle SBSM params, state and event

SBSM needs following class in application.

  • Session (extneds SBSM::Session)
    • This class use Validator.
  • Validator (extends SBSM::Validator)
    • This class parse request parameters. target State and event are specified by this validator.
    • At least, Validator class needs EVENTS constant.

In mock, Session class has follownig values specified by Validator.

  • @valid_input
  • @active_state

url parameters

http://example.com/(lang)/(flavor)/(event)

http://example.com/de/test/hallo

@validator    = {:default_flavor=>"gcc", :language=>"de", :flavor=>"test", :event=>:hello}
@active_state = #<SHOE::State::Greet::Hello:0xa184638>

http://example.com/de/test/goodbye

@validator    = {:default_flavor=>"gcc", :language=>"de", :flavor=>"test", :event=>:goodbye}
@active_state = #<SHOE::State::Greet::Hello:0xa047540>

view, composite and partial (files for HtmlGrid)

We can freely, setup view files.
HtmlGrid has Composite class as main feature.

z.B.

in /path/to/project/src

  • view/
    • composite/ # => as global composite
      • head.rb
      • foot.rb
    • greet/ # => bundled files relating to state
      • composite/
        • subhead.rb
      • partial/
        • external_link.rb
      • hello.rb
      • goodbye.rb

bind(2) error (Errno::EADDRINUSE)

I have yet another problem im my mock application.
Once, connect to mock via browser (It works),
After few minutes later of previous connection, bind(2) Error of DRuby caused via Apache.

It seems that few connection from Apache to DRbServer remains.

  1. . Onece, connect to http://shoe.localhost/de/gcc/hello via Browser.
  2. . After few minutes later, connect again.
  3. . Then Apache crashed (following error caused)
  4. . DRbServer is OK. (application process like a oddbd)
  5. . restart Apache, then It works, again. (without restarting of application process)
[Tue Feb 28 18:38:48 2012] [error] mod_ruby: error in ruby
[Tue Feb 28 18:38:48 2012] [error] mod_ruby: /usr/local/lib/ruby/1.9.1/drb/drb.rb:861:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:861:in `open'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:861:in `open_server'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:759:in `block in open_server'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:757:in `each'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:757:in `open_server'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:1342:in `initialize'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:1624:in `new'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/drb/drb.rb:1624:in `start_service'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /var/www/shoe/doc/index.rbx:6:in `<top (required)>'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/apache/ruby-run.rb:53:in `load'
[Tue Feb 28 18:38:48 2012] [error] mod_ruby:   from /usr/local/lib/ruby/1.9.1/apache/ruby-run.rb:53:in `handler'
NOTE

to check actions on using ports with lsof -i

view · edit · sidebar · attach · print · history
Page last modified on February 28, 2012, at 07:06 PM