view · edit · sidebar · attach · print · history

20101215-update-bbmb-ch

<< Masa.20101216-update-import_de_oddb_org_Festbe_Zubef | 2010 | Masa.20101214-update-bbmb-ch >>


  1. Test bbmb.ch locally with server's files
  2. Check differences one by one
  3. Update bbmb.ch

Goal
  • Update bbmb.ch on bbmb.ch server / 90%
Milestones
  1. Test run locally with files on bbmb.ch server 8:45
  2. Resolve pull errors on server 16:00
  3. Update bbmb.ch except for fastthread gem updating
  4. (bbmb.ch setup script)
Summary
Commits
ToDo Tomorrow
Keep in Mind
  1. rpdf2txt announcement
  2. export_fachinfo test locally
  3. All test cases YamlExporter test cases oddb.org 20101213
  4. On Ice
  5. emerge --sync

Test bbmb.ch locally with server's files

step 1 : confrim bbmbd

Run

masa@masa ~/ywesee/bbmb.ch $ bin/bbmbd 
[DEPRECATED] By requiring 'spreadsheet/excel' you are loading a Compatibility
             layer which provides a drop-in replacement for Spreadsheet::Excel
             versions <= 0.3.5.1. This code will be removed in Spreadsheet
             version 1.0.0

no such file to load -- /home/masa/ywesee/bbmb.ch/etc/access_gag.rb
loading testenvironment
disabling UPDATER
BbmbApp::RUN_UPDATER=false
BbmbApp::RUN_STATISTICS=false
BBMB::CustomBehaviorGag::MAIL_RECIPIENTS=["mhatakeyama@ywesee.com"]
/usr/lib64/ruby/site_ruby/1.8/mnemonic/Mnemonic.rb:148: warning: Object#type is deprecated; use Object#class
...
running cleaner thread
running cleaner thread
starting drb-service

Result

  • Ok

step 2 : copy bin/bbmbd

Run

masa@masa ~/ywesee/bbmb.ch $ bin/bbmbd 
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- fastthread (LoadError)
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from bin/bbmbd:6

Result

  • failed

Check fastthread on server

$ gem search fastthread

*** LOCAL GEMS ***

fastthread (0.6.4.1, 0.4)
    Optimized replacement for thread.rb primitives

$ emerge -s fastthread
Searching...    
[ Results for search key : fastthread ]
[ Applications found : 1 ]

*  dev-ruby/fastthread
      Latest version available: 1.0.7
      Latest version installed: [ Not Installed ]
      Size of files: 21 kB
      Homepage:      http://mongrel.rubyforge.org/
      Description:   Optimized replacement for thread.rb primitives
      License:       Ruby

Note

  • There are 2 versions of gem installed

Check fastthread on remote

masa@masa ~/ywesee/bbmb.ch $ gem search fastthread -r

*** REMOTE GEMS ***

blackwinter-fastthread (1.0.7)
fastthread (1.0.7)

Note

  • fastthread on bbmb.ch server is not the latest version

step 3 : copy doc/index.rbx

Note

  • bin/bbmbd is replaced back to the original

Run

masa@masa ~/ywesee/bbmb.ch $ bin/bbmbd 
[DEPRECATED] By requiring 'spreadsheet/excel' you are loading a Compatibility
             layer which provides a drop-in replacement for Spreadsheet::Excel
             versions <= 0.3.5.1. This code will be removed in Spreadsheet
             version 1.0.0

no such file to load -- /home/masa/ywesee/bbmb.ch/etc/access_gag.rb
loading testenvironment
disabling UPDATER
BbmbApp::RUN_UPDATER=false
BbmbApp::RUN_STATISTICS=false
BBMB::CustomBehaviorGag::MAIL_RECIPIENTS=["mhatakeyama@ywesee.com"]
/usr/lib64/ruby/site_ruby/1.8/mnemonic/Mnemonic.rb:148: warning: Object#type is deprecated; use Object#class
...
running cleaner thread
running cleaner thread
starting drb-service

Result

  • It looks working as well

step 4 : copy src/util/bbmbconfig.rb

Note

  • keep doc/index.rbx

Run bin/bbmbd

Result

  • It looks working as well

step 5 : copy src/view/favorites.rb

Note

  • Keep doc/index.rbx, src/util/bbmbconfig.rb

Run bin/bbmbd

Result

  • I can log-in as well
  • but I have not understood yet what part changes by this replacement

step 6 : src/view/format.rb

Note

  • Keep doc/index.rbx, src/util/bbmbconfig.rb, src/view/favorites.rb

Run bin/bbmbd

Result

  • Also I can log-in as well
  • but I have not understood yet what part changes by this replacement

Summary

  • Except for bin/bbmbd (require 'fastthread'), the files on bbmb.ch server can be replaced

Check differences one by one

Differences between bbmb.ch server and git server

  1. bin/bbmbd
  2. doc/index.rbx
  3. src/custom/behavior.rb
  4. src/util/bbmbconfig.rb
  5. src/view/favorites.rb
  6. src/view/format.rb

1. bin/bbmbd

Note

  • fastthread is a Ruby extension which re-implements the primitives in Ruby's thread.rb in C
  • fasthread should be updated to 1.0 due to bugs in Ruby 1.8.6 if we use 'fastthread'
  • but we do not have to use 'fastthread' if the server is not accessed by many users
  • It seems to be merged in after Ruby 1.8.7
  • There is NOT the requirement of 'fastthread' in git repository from the begining
  • The first adding 'bin/bbmbd' was at http://groups.google.com/group/ruby-talk-google/browse_thread/thread/7933e7e987dad1c3
  • bin/bbmbd was moved from src/util/bbmb.rb, but bbmb.rb does not have 'require 'fastthread'' either

Link

Experiment (install fastthread 1.0.7 and run again)

masa@masa ~/ywesee/bbmb.ch $ sudo gem install fastthread
Passwort: 
Building native extensions.  This could take a while...
Successfully installed fastthread-1.0.7
1 gem installed
Installing ri documentation for fastthread-1.0.7...

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump
Installing RDoc documentation for fastthread-1.0.7...

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump
masa@masa ~/ywesee/bbmb.ch $ gem search fastthread

*** LOCAL GEMS ***

fastthread (1.0.7)

Run bin/bbmbd

Result

  • Looks no problem

Conclution

  • It is no problem 'require 'fastthread', but we should update it version 1.0 due to some bugs of 'fastthread'
  • Before updating, we have to check the other application on the server which are using 'fastthread'
  • But I think no problem it is updated

2. doc/index.rbx

Note

  • There are same statements in index.rbx
$: << File.expand_path("../src", File.dirname(__FILE__))
$: << File.expand_path('../src', File.dirname(__FILE__))
  • I guess one line should be deleted

Conclution

  • It is no problem to update index.rbx
  • but we should delete one line as I mention above

3. src/custom/behavior.rb

Note

  • The changes regarding email addresses are no problem

Checking point is

        def transmit_order(user, order, flavor=BBMB::DEFAULT_FLAVOR)
            if(order.empty?)
                raise ProcessingException.new(:order, :empty, order)
            end
            name = transmission_filename(user, order, flavor)
            if(flavor == 'vetoquinol')
                require 'fileutils'
                dir = '/var/www/bbmb.ch/data/vetoquinol/'
                FileUtils.mkdir_p(dir)
                path = File.join(dir, name)
                File.open(path, 'w') { |fh|
                    fh.puts(transmission_format(user, order))
                }
            else
                remote_file(:transmit_order, name).open("w") { |file|
                    file.puts(transmission_format(user, order))
                }
            end
        end

Check the data on bbmb.ch server

/var/www/bbmb.ch/data/vetoquinol $ ls -al
total 8
drwxr-xr-x 2 apache apache  16 2006-10-01 21:04 .
drwxr-xr-x 5 apache apache  24 2006-09-29 16:07 ..
-rw-r--r-- 1 apache apache 470 2006-09-29 16:35 KD126043_1159540504.dat
-rw-r--r-- 1 apache apache 584 2006-10-01 21:04 KD126823_1159729490.dat

Conclution

  • We should replace the change above, because the data has not been used anymore since 2006

4. src/util/bbmbconfig.rb

Note

  • The second SERVER_URI is used, if there is, in bin/bbmbd
masa@masa ~/ywesee/bbmb.ch $ grep -r SERVER_URI *
bin/bbmbd:if(BBMB::SERVER_URI.is_a? Array)
bin/bbmbd:      BBMB::SERVER_URI.each { |uri|
bin/bbmbd:      DRb.start_service(BBMB::SERVER_URI, bbmb)
src/util/bbmbconfig.rb: SERVER_URI = ["druby://localhost:9999"]#, "druby://192.168.0.35:9876"]
src/util/bbmbconfig.rb:         if(SERVER_URI.is_a? Array)
src/util/bbmbconfig.rb:                 SERVER_URI.first
src/util/bbmbconfig.rb:                 SERVER_URI.to_s
test/stub_bbmb.rb:      remove_const :SERVER_URI
test/stub_bbmb.rb:      SERVER_URI = "druby://localhost:2153"
test/test_bbmbapp.rb:                   drbsession_uri = BBMB::SERVER_URI
test/test_bbmbapp.rb:                   drbsession_uri = BBMB::SERVER_URI
test/test_bbmbapp.rb:                   drbsession_uri = BBMB::SERVER_URI

bin/bbmbd

if(BBMB::SERVER_URI.is_a? Array)
    BBMB::SERVER_URI.each { |uri|
        DRb.start_service(uri, bbmb)
    }
else
    DRb.start_service(BBMB::SERVER_URI, bbmb)
end

Conclusion

  • it is no problem to comment out the second URI if it is used only for one domain, maybe.

5. src/view/favorites.rb

    class FavoritesListGag < ProductsListGag
        include SizeInputMethods
        POSITION_MODIFIER = "favorite_search"
        CSS_CLASS = 'favorites'
        COMPONENT_CSS_MAP = {
            [1,0]       =>  "input-tiny",
            [4,0]       =>  "list-big",
            [9,0,3] =>  'info',              # <= here
        }
        def size(model)
            input = SizeInput.new(model, @session, self)
            input
        end
    end

Question

  • When is 'FavoritesListGag' called?

Consideration

  • This must be corresponding to src/state/favorites.rb

Check src/view/favorites.rb

    class FavoritesListGag < ProductsListGag
...
    end
    class FavoritesFormGag < FavoritesForm
        def products(model)
            FavoritesListGag.new(model.sorted, @session, self)
        end
    end
    class FavoritesCompositeGag < FavoritesComposite
        COMPONENTS = {
...
            [0,1]   =>  FavoritesFormGag,
...
        }
    end
    class FavoritesViewGag < OrderView
        CONTENT = FavoritesCompositeGag
    end

Check src/state/favorites.rb

module BBMB
    class FavoritesState < OrderState
...
        VIEW = FavoritesView
        def init_view
            user = @session.user
            if(user.value(:group_short) == 'Vétoqu')
                @default_view = FavoritesViewVetoquinol
            elsif(@session.flavor == 'gag')
                @default_view = FavoritesViewGag
            end
        end

Note

  • FavoritesViewGag (FavoritesView) is corresponding to FavoritesState
  • FavoritesViewGag includes FavoritesListGag

Next

  • I have to check when FavoritesState is called

grep search

masa@masa ~/ywesee/bbmb.ch $ grep -r FavoritesState *
src/model/hospital.rb:          NAVIGATION = [ :home, OrdersState, FavoritesState, ProductHistoryState,
src/state/favoriteresult.rb:                    FavoritesState.new(@session, nil)
src/state/favorites.rb:# FavoritesState -- bbmb -- 21.04.2004 -- hwyss@ywesee.com
src/state/favorites.rb: class FavoritesState < OrderState
src/state/hospitaluser.rb:                      :favorites               

Consideration

  • Probably I guess Favorites is called from HospitalUserState

Then

masa@masa ~/ywesee/bbmb.ch $ grep -r HospitalUserState *
src/state/hospitaluser.rb:# HospitalUserState -- bbmb -- 21.04.2004 -- hwyss@ywesee.com
src/state/hospitaluser.rb:      module HospitalUserState
src/state/login.rb:                             state.extend(HospitalUserState)

Note

  • HospitalUserState is called from login process

Check src/state/login.rb

        def login
            @session.login
            case @session.user
            when RootUser
                state = AdminsState.new(@session, nil)
                state.extend(RootState)
                state
            when AdminUser
                state = HospitalsState.new(@session, nil)
                state.extend(AdminUserState)
                state
            when SubAdminUser
                state = HospitalsState.new(@session, nil)
                state.extend(SubAdminUserState)
                state
            when HospitalUser
                state = CurrentOrderState.new(@session, nil)
                state.extend(HospitalUserState)
                state
            when SupplierUser
                state = BackordersState.new(@session, nil)
                state.extend(SupplierUserState)
                state
            else
                self
            end
        end

Note

  • HospitalUserState is called when the login user is HospitalUser

Question

  • What is the 'HospitalUser'?

Experiment

        def login
            @session.login
            case @session.user
            when RootUser
p "login as RootUser"
                state = AdminsState.new(@session, nil)
                state.extend(RootState)
                state
            when AdminUser
p "login as AdminUser"
                state = HospitalsState.new(@session, nil)
                state.extend(AdminUserState)
                state
            when SubAdminUser
p "login as SubAdminUser"
                state = HospitalsState.new(@session, nil)
                state.extend(SubAdminUserState)
                state
            when HospitalUser
p "login as HospitalUser"
                state = CurrentOrderState.new(@session, nil)
                state.extend(HospitalUserState)
                state
            when SupplierUser
p "login as SupplierUser"
                state = BackordersState.new(@session, nil)
                state.extend(SupplierUserState)
                state
            else
p "login as who?"
                self
            end
        end

Result

  • when I login by using 'customer@ywesee.com' then HospitalUser is selected

Note

  • If I click 'schnellbestellung' then 'FavoritesState#init_view' is called

Experiment

src/view/favorites.rb

        COMPONENTS = {
            [1,0]       =>  "input-tiny",
            [4,0]       =>  "list-big",
            [9,0,3] =>  'info',
        }

Note

  • These values are for CSS, which means the setting parameter 'how to show' the components

Experiment

  • Even if I delete the first 'input-tiny', nothing changes
  • If I delete the second 'list-big', then underlines are put on product names
    • This indicates the first number is corresponding to the column number of the product list
  • Then, 'info' means the CSS setting of 'FI' 'DDD' links
  • I cannot see the FI and DDD icons locally, though

Check HTML source

...class="info" title="Fachinformation">Fi</A><...
...class="info">DDD</A>...

Conclusion

  • This change should be merged with git server
  • But not so important change

6. src/view/format.rb

Note

  • The change point is in article_backorder method
        def article_backorder(model)
            if(model.value(:article_backorder))
                comment = model.backorder_comment
                if(comment.to_s.empty?)    # <= Here

Consideration

  • I have to know the class of comment, and model variables
  • Then I can automatically understand why the 'to_s' is necessary

Experiment

src/view/format.rb

        def article_backorder(model)
p "getin ValueFormat#article_backorder"
print "model.class=", model.class, "\n"

            if(model.value(:article_backorder))
                comment = model.backorder_comment
print "comment.class=", comment.class, "\n"
print "comment.empty?=", comment.empty?, "\n"
print "comment.to_s.empty?=", comment.to_s.empty?, "\n"
                if(comment.to_s.empty?)

Run (login as customer@ywesee.com (HospitalUser))

Result

"getin ValueFormat#article_backorder"
model.class=BBMB::Position
"getin ValueFormat#article_backorder"
model.class=BBMB::Position
"getin ValueFormat#article_backorder"
model.class=BBMB::Position
"getin ValueFormat#article_backorder"
model.class=BBMB::Position
comment.class=BBMB::BackorderComment

comment.empty?=true
comment.to_s.empty?=false

"getin ValueFormat#article_backorder"
model.class=BBMB::Position

Note

  • I do not know why but 'comment.to_s.empty?' and 'comment.empty' are different

Check BBMB::BackorderComment

src/model/backorder_comment.rb

module BBMB
    class BackorderComment
...
        def empty?
            @attributes.nil? || @attributes.empty? \
                || @attributes.all? { |key, val| val.to_s.empty? }
        end

Note

  • There is a definition regarding BBMB::BackorderComment#empty?
  • In my opinion, this method should be modified, rather than modification of src/view/favorites.rb

Consideration

  • 'comment.empty?' causes an error, if 'comment' == nil
  • but 'comment.to_s.empty?' become false without error even if 'comment' == nil
  • Probably there is a case where 'comment' becomes nil
  • That is why Hannes-san changed this code
  • But this is not smart solution and this messed up the code logic

Conclusion

  • Keep this change on bbmb.ch server

Update bbmb.ch

Commit

On bbmb.ch server

  1. git stash
  2. git pull

But I failed to update fastthread through gem

ywesee@whitie /var/www/bbmb.ch $ gem search fastthread -r

*** REMOTE GEMS ***
ERROR:  While executing gem ... (Gem::RemoteSourceException)
   HTTP Response 302

Memo (git log failed but git log|cat works, due to the character code)

/var/www/bbmb.ch $ git log
invalid charset name
/var/www/bbmb.ch $ git log | cat | more
Date:   Wed Dec 15 15:41:51 2010 +0100

    Changed files as on bbmb.ch server

commit 2283d32aba16fdfebb2f5150b29a5f89c6f8e429
Author: Masaomi Hatakeyama <mhatakeyama@ywesee.com>
Date:   Tue Dec 14 16:19:22 2010 +0100

    Change /ywesee/Out to /YWESEE/Out

...

Davatz-san updated gem and fastthread on bbmb.ch server

view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 12:05 PM