view · edit · sidebar · attach · print · history

< Niklaus.20160504-ydim-html-to-utf8 | Index | Niklaus.20160502-ydim-html-ruby-2-3 >>

20160503-ydim-html-ruby-2-3

Summary

  • Port ydim-html to Ruby 2.3

Commits

Index

Keep in Mind for work to do
  • Fix dojo error http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/#forgot-dom-ready
  • I removed on May-27 tests for ix_registrationss, fix_sequences, fix_compositions, fix_packages from test/test_plugin/swissmedic.rb,as he could not find any references for them in the src code. Did I erroneously remove stuff when cleaning up the swissmedic import earlier?
  • The whole test for older/newer Packages must be adapted to xlsx. One must compare the rows (e.g. by creating csv files) and do the same stuff in xlsx!
  • creat gem: task: input=file with ean-codes, standard output show ean-codes + atc-code. Source is Swissmedic Packungen.xlsx or XML.
  • Import via data/medreg_companies.yaml
  • Fix problem with radioactivatum 99m-technetio when parsing Wirkstoffe
  • Fix galenic_forms when parsing swissmedic.xlsx
  • Cleanup generic_type. Replace it everywhere by sl_generic_type and adapt code accordingly.
  • Get updated ATC-codes from EPha for oddb.org, too.
  • Use refdatabase for oddb.org, too.
  • Check whether we should revert the part which touche src/plugin/text_info.rb of commit 17af82ba4d76a5838683411b260de265531f9e74. We should improve test/stub/oddbapp.rb to work similar for update/pointer as the real oddbapp. In this case we would have a good Stub for plugins. May we need a different stub when working with plugins (which create/modify/destroy ODDB-Objects), when in most other cases a very simple stub is sufficient.
  • When a logged in admin user changes an atc_code of a product, the corresponding atc_class must update its sequences, too.
  • Order of entering search type and value should not matter. Both should show long URL with search
  • Remove parser for minifi (but keep the minifi)
  • BSV-Plugin does not send mail. Is it sending two mails at once?
  • remove obsolete pdf_patinfo in model, admin/views

Port ydim-html to Ruby 2.3

Looking at several suggestions made by Zeno:

  • Useage of rockit. Rockit was never used inside ydim-html nor ydim (e.g. the code as used on thinpower from 2013, does not contain any method/class from rockit). Therefore I cannot uncomment a rockit process as Masa did http://dev.ywesee.com/Masa/20111006-ruby193-oddb#Rockit.
  • Rockit was used inside the sbsm (Version 1.2.3), via a require 'rockit/rockit' from lib/sbsm/flavored_uri_parser.rb, where it defined a method SBSM._flavored_uri_parser, where it defines a grammar for _, language, flavor, event and variables.

I am adding debug printfs in the ydim/html/state/global.rb, as I think some paths are not taken correctly. It looks like Invoice.new(@session, @session.invoice(id.to_i)) work. But after pressing "Speichern" and "Kunden" the URL switches to https://ydim.oddb-ci2.dyndns.org/de/debitors/, but no debitors are visible.

See

As pressing "Email" or "Name" to sort by E-Mail does not work neither, I added debug statements and see now

  • In apache error_log:
    • SBSM::Request.drb_process cgi.params {"default_flavor"=>nil, "language"=>"de", "flavor"=>"sort", "event"=>"state_id", "69911742359600"=>"sortvalue", "email"=>"", "ssl-secure-reneg"=>"1"} @request.unparsed_uri /de/sort/state_id/69911742359600/sortvalue/email
    • SBSM::Request.drb_process cgi.params {"default_flavor"=>nil, "language"=>"de", "flavor"=>"sort", "event"=>"state_id", "69911742359600"=>"sortvalue", "name"=>"", "ssl-secure-reneg"=>"1"} @request.unparsed_uri /de/sort/state_id/69911742359600/sortvalue/name
  • In ydim-html standard output
    • YDIM::Html::Util::Session process /de/sort/state_id/69911742359600/sortvalue/email
      • sbsm process /de/sort/state_id/69911742359600/sortvalue/email @state.request_path /de @active_state.zone
      • sbsm process state #<YDIM::Html::State::Debitors:0x007f2b31235060> zone
    • YDIM::Html::Util::Session process /de/sort/state_id/69911742359600/sortvalue/name
      • sbsm process /de/sort/state_id/69911742359600/sortvalue/name @state.request_path /de @active_state.zone
      • sbsm process state #<YDIM::Html::State::Debitors:0x007f2b31235060> zone

I think I have resolved the problem. For ODDB.ORG we had to introduce flavor (after working with ydim). Therefore a debitor is displayed correctly when using an URL like https://ydim.oddb-ci2.dyndns.org/de/gcc/debitor/unique_id/9 instead of https://ydim.oddb-ci2.dyndns.org/de/debitor/unique_id/9. gcc has no influence, as ydim has no notion of flavor. It may be any string, even an empty one.

After adding DEFAULT_FLAVOR = "gcc" into ib/ydim/html/util/session.rb, the link work, but the lnf has changed and displays a white background. Renaming the DEFAULT_FLAVOR to 'ydim' and moving doc/resources/ydim.css into doc/resources/ydim/ydim.yss fixed this problem.

See

Adding a new invoice does not work correctly. It is possible to add the header, but when trying to add a position, I cannot enter number and prices. But the invoice can be saved (even when containing Umlaute). See

Investigating the necessary changes to make the AJAX-scripts work again.

When looking at the output I see

error in SBSM::Session#process: /de/ydim/ajax_create_item/state_id/70080653642640/unique_id/10002
NoMethodError
undefined method `collect' for "10002":String
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/storage.rb:441:in `retrieve_from_condition_index'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/index.rb:333:in `fetch_ids'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/stub.rb:112:in `method_missing'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/cache.rb:458:in `retrieve_from_index'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/persistable.rb:135:in `block (2 levels) in odba_index'

Loaded ydim database from thinpower. All debitors display, but some names are ugly (UTF-8 problem). When creating a PDF, only a PDF containing NoMethodError undefined method `each' for "<b>#012470</b>":String is created.

Callstack is

error in SBSM::Session#to_html: /de/ydim/pdf/unique_id/12470
NoMethodError
undefined method `each' for "<b>#012470</b>":String
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/pdf-writer-1.1.8/lib/pdf/writer.rb:2375:in `text'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/pdfinvoice/invoice.rb:61:in `pdf_header'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/pdfinvoice/invoice.rb:26:in `to_pdf'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/ydim/invoice.rb:131:in `to_pdf'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/drbwrapper.rb:28:in `method_missing'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop'
/mnt/src/ydim-html/lib/ydim/html/view/pdf.rb:12:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/state.rb:181:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:449:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:173:in `block in drb_process'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:171:in `synchronize'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:171:in `drb_process'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop'

Committed Bumped version to 1.3.2, use bundler/gemtasks and using my Ruby 2.x compatible version of the pdf-writer. Now the errors are no longer in the PDF-header but

error in SBSM::Session#to_html: /de/ydim/pdf/unique_id/12470
NoMethodError
undefined method `each' for "":String
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/pdfinvoice/invoice.rb:191:in `pdf_lines'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/pdfinvoice/invoice.rb:65:in `pdf_header'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/pdfinvoice/invoice.rb:26:in `to_pdf'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/ydim-1.0.1/lib/ydim/invoice.rb:131:in `to_pdf'
(druby://localhost:12375) /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/drbwrapper.rb:28:in `method_missing'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop'
(druby://localhost:12375) /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop'
/mnt/src/ydim-html/lib/ydim/html/view/pdf.rb:12:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/state.rb:181:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:449:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:173:in `block in drb_process'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:171:in `synchronize'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:171:in `drb_process'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop'

After handling strings and arrays differently in lib/pdfinvoice/invoice.rb:191:in `pdf_lines' the first PDF was generated correctly and display a 'é' without problems.

But I want to resolve first the problem that customer get displayed like 68 V�toquinol AG info@vetoquinol.ch.

While visiting https://ydim.oddb-ci2.dyndns.org/de/ydim/debitor/unique_id/389 (Grünenthal) I got the error Encoding::CompatibilityError incompatible character encodings: ISO-8859-1 and UTF-8

error in SBSM::Session#to_html: /de/ydim/debitor/unique_id/389
Encoding::CompatibilityError
incompatible character encodings: ISO-8859-1 and UTF-8
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/grid.rb:296:in `join'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/grid.rb:296:in `block in to_html'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:15:in `nn_element'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:21:in `nn_element_def'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/grid.rb:295:in `to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/composite.rb:266:in `to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/form.rb:59:in `block in to_html'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:324:in `form'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/form.rb:58:in `to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:42:in `block (3 levels) in to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:40:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:40:in `inject'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:40:in `block (2 levels) in to_html'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:15:in `nn_element'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:21:in `nn_element_def'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:39:in `block in to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:38:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:38:in `each_with_index'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:38:in `to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:42:in `block (3 levels) in to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:40:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:40:in `inject'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:40:in `block (2 levels) in to_html'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:15:in `nn_element'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:21:in `nn_element_def'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:39:in `block in to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:38:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:38:in `each_with_index'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/divcomposite.rb:38:in `to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/template.rb:123:in `block in to_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/template.rb:116:in `template_tags'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/template.rb:111:in `block (2 levels) in template_html'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:55:in `nO_element'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:62:in `nO_element_def'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/template.rb:110:in `block in template_html'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:55:in `nO_element'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:62:in `nO_element_def'
/usr/local/lib/ruby/2.3.0/cgi/html.rb:423:in `html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/template.rb:109:in `template_html'
/usr/local/lib/ruby/gems/2.3.0/gems/htmlgrid-1.0.8.1/lib/htmlgrid/template.rb:122:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/state.rb:181:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:449:in `to_html'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:173:in `block in drb_process'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:171:in `synchronize'
/usr/local/lib/ruby/site_ruby/2.3.0/x86_64-linux/sbsm/session.rb:171:in `drb_process'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop'
/usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop'

Do we need a migrate script to change all database entries to UTF_8? And how should I call it?

After adding a number of calls to force_encoding I was able to generate a new invoice containing Umlauts. See

But loading customer with umlaut still leads to ArgumentError invalid byte sequence in UTF-8

Copied relevant methods from oddb.org/util/oddbapp.rb to ydim/bin/migrate_to_utf8 and adapted all needed classes. The method itself needs some updating, too, as iconv has gone with ruby 2.x.

Added bin/migrate_to_utf (see Attach:migrate_to_utf8.txt). But when running no tables are found

sudo -u apache /usr/local/bin/bundle exec bin/migrate_to_utf_8 
2016-05-03 17:31:55 +0200: Loading bin/migrate_to_utf_8
/mnt/src/ydim/vendor/ruby/2.3.0/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `initialize' may cause serious problems
/mnt/src/ydim/vendor/ruby/2.3.0/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `object_id' may cause serious problems
/mnt/src/ydim/vendor/ruby/2.3.0/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `__send__' may cause serious problems
2016-05-03 17:32:04 +0200: Calling migrate_to_utf8
FEHLER:  Relation &#65533;object&#65533; existiert bereits
FEHLER:  Relation &#65533;prefetchable_index&#65533; existiert bereits
FEHLER:  Relation &#65533;extent_index&#65533; existiert bereits
FEHLER:  Relation &#65533;object_connection&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_index&#65533; existiert bereits
FEHLER:  Relation &#65533;collection&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_ydim_autoinvoice_unique_id&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_ydim_debitor_email&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_ydim_debitor_name&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_ydim_debitor_unique_id&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_ydim_invoice_status&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_ydim_invoice_unique_id&#65533; existiert bereits
Migrating table {nil=>true, :serialized=>{}, :finalizer=>#<Proc:0x007f59a04df8b8@bin/migrate_to_utf_8:32>}
 60: Migrating NilClass
2016-05-03 17:32:05 +0200: Finished migrate_to_utf8

The bin/admin command migrate_to_utf8 from odddb.org probably does not work anymore. Therefore I need to adapt even more stuff. Adding a RootUser and RootSession. Trying to convert first all debitors. Loop is not yet perfect, as it only goes over one item. Will continue tomorrow.

Reverted Yasuhiros commit for Zeno Revert "Update path to use absolut_path via expand_path"

view · edit · sidebar · attach · print · history
Page last modified on May 03, 2016, at 06:15 PM