<< Masa.20101116-create-grant_download-command-de_oddb_org | 2010 | Masa.20101111-setup-eshop update-customer-data >>
Experiment
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> grant_download 'mhatakeyama@ywesee.com', 'oddb.csv', 1, Time.local(2011,1,1) -> http://oddb.masa.org/de/gcc/download/invoice/25518091/email/mhatakeyama@ywesee.com/filename/oddb.csv masa@masa ~/ywesee/oddb.org/data/downloads $ ls masa@masa ~/ywesee/oddb.org/data/downloads $
Access to the link on browser
Experiment
masa@masa ~/ywesee/oddb.org/data/downloads $ ls -al insgesamt 5444 drwxr-xr-x 2 masa masa 8 15. Nov 09:10 . drwxr-xr-x 8 masa masa 48 15. Nov 09:03 .. -rw-r--r-- 1 masa masa 5573371 15. Nov 09:10 oddb.csv
Access to the same link
Experiment
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> grant_download 'aaa@bbb.ccc', 'oddb.csv', 1000, Time.local(2011,2,2) -> http://oddb.masa.org/de/gcc/download/invoice/25518094/email/aaa@bbb.ccc/filename/oddb.csv
Access to the link
Notes
Hypotheses
Experiment
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb#process
def process(request)
begin
@request = request
@request_method = request.request_method
@request_path = @request.unparsed_uri
open("/home/masa/work/test.dat","a"){|f| f.print "@request_path=", @request_path, "\n"}
...
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
masa@masa ~/work $ cat test.dat @request_path=/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat
Notes
Experiment
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb#import_user_input
def import_user_input(request)
open("/home/masa/work/test.dat","a"){|f| f.print "getin import_user_input\n"}
# attempting to read the cgi-params more than once results in a
# DRbConnectionRefused Exception. Therefore, do it only once...
return if(@user_input_imported)
request.params.each { |key, value|
open("/home/masa/work/test.dat","a"){|f| f.print "key=", key, " value=", value, "\n"}
...
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
masa@masa ~/work $ cat test.dat getin process @request_path=/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat getin import_user_input key=language value=de key=invoice value=25518097 key=event value=download key=default_flavor value=gcc key=filename value=test.dat key=flavor value=gcc key=email value=aaa@bbb.ccc
Notes
Consideration
Experiment
def download
open("/home/masa/work/test.dat","a"){|f| f.print "getin src/state/global.rb#download\n"}
open("/home/masa/work/test.dat","a"){|f| f.print caller(0).pretty_inspect, "\n"}
...
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
masa@masa ~/work $ cat test.dat getin process @request_path=/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat getin import_user_input key=language value=de key=invoice value=25518097 key=event value=download key=default_flavor value=gcc key=filename value=test.dat key=flavor value=gcc key=email value=aaa@bbb.ccc getin import_cookies key=language value=de getin src/state/global.rb#download ["/home/masa/ywesee/oddb.org/src/state/global.rb:221:in `download'", "/usr/lib64/ruby/1.8/open-uri.rb:32:in `open_uri_original_open'", "/usr/lib64/ruby/1.8/open-uri.rb:32:in `open'", "/home/masa/ywesee/oddb.org/src/state/global.rb:221:in `download'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:214:in `send'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:214:in `_trigger'", "/home/masa/ywesee/oddb.org/src/state/global.rb:657:in `_trigger'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:203:in `trigger'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:412:in `process'", "/home/masa/ywesee/oddb.org/src/util/session.rb:111:in `process'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:176:in `drb_process'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `synchronize'", "/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `drb_process'", "/usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__'", "/usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block'", "/usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform'", "/usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop'", "/usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop'", "/usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop'", "/usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start'", "/usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop'", "/usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run'", "/usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start'", "/usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run'", "/usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize'", "/usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new'", "/usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service'", "bin/oddbd:38"]
Experiment
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb#drb_process
def drb_process(request)
open("/home/masa/work/test.dat","a"){|f| f.print "SBSM::Session#getin-drb_process\n"}
start = Time.now
html = @mutex.synchronize do
process(request)
to_html
end
(@@stats[@request_path] ||= []).push(Time.now - start)
return_value = html
open("/home/masa/work/test.dat","a"){|f| f.print "html=", return_value, "\n"}
# html
return_value
end
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
masa@masa ~/work $ cat test.dat SBSM::Session#getin-drb_process html=
Note
Consideration
Experiment
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb#process
def process(request)
begin
@request = request
@request_method = request.request_method
@request_path = @request.unparsed_uri
@validator.reset_errors() if @validator
import_user_input(request)
import_cookies(request)
@state = active_state.trigger(event())
#FIXME: is there a better way to distinguish returning states?
# ... we could simply refuse to init if event == :sort, but that
# would not solve the problem cleanly, I think.
# unless(@state.request_path)
# @state.request_path = @request_path
# @state.init
# end
# unless @state.volatile?
# @active_state = @state
# @attended_states.store(@state.object_id, @state)
# end
# @zone = @active_state.zone
# @active_state.touch
# cap_max_states
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
Experiment /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb#process
def process(request)
begin
@request = request
@request_method = request.request_method
@request_path = @request.unparsed_uri
@validator.reset_errors() if @validator
import_user_input(request)
import_cookies(request)
# @state = active_state.trigger(event())
#FIXME: is there a better way to distinguish returning states?
# ... we could simply refuse to init if event == :sort, but that
# would not solve the problem cleanly, I think.
# unless(@state.request_path)
# @state.request_path = @request_path
# @state.init
# end
# unless @state.volatile?
# @active_state = @state
# @attended_states.store(@state.object_id, @state)
# end
# @zone = @active_state.zone
# @active_state.touch
# cap_max_states
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
Notes
Experiment /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb#process
def process(request)
begin
@request = request
@request_method = request.request_method
@request_path = @request.unparsed_uri
@validator.reset_errors() if @validator
import_user_input(request)
import_cookies(request)
@state = active_state.trigger(event())
open("/home/masa/work/test.dat","a"){|f| f.print "@state.class=", @state.class, "\n"}
#FIXME: is there a better way to distinguish returning states?
# ... we could simply refuse to init if event == :sort, but that
# would not solve the problem cleanly, I think.
# unless(@state.request_path)
# @state.request_path = @request_path
# @state.init
# end
# unless @state.volatile?
# @active_state = @state
# @attended_states.store(@state.object_id, @state)
# end
# @zone = @active_state.zone
# @active_state.touch
# cap_max_states
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
@state.class=ODDB::State::User::Download
Experiment
module ODDB
module View
module User
class Download < HtmlGrid::PassThru
def init
open("/home/masa/work/test.dat","a"){|f| f.print "getin src/view/user/download.rb#init\n"}
if(filename = @session.user_input(:filename))
@path = File.join('..', 'data', 'downloads', filename)
end
end
def to_html(context)
open("/home/masa/work/test.dat","a"){|f| f.print "getin src/view/user/download.rb#to_html\n"}
line = [
nil,
@session.remote_addr,
@session.user_input(:email),
@path,
].join(';')
LogFile.append(:download, line, Time.now)
@session.passthru(@path)
''
end
end
end
end
end
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
@state.class=ODDB::State::User::Download getin src/view/user/download.rb#init getin src/view/user/download.rb#to_html
Notes
Experiment
def download
open("/home/masa/work/test.dat","a"){|f| f.print "getin src/state/global.rb#download\n"}
if(@session.is_crawler?)
return State::Drugs::Init.new(@session, nil)
end
email = @session.user_input(:email)
email ||= @session.get_cookie_input(:email)
oid = @session.user_input(:invoice)
file = @session.user_input(:filename)
return_value = nil
if((invoice = @session.invoice(oid)) \
&& invoice.yus_name == email \
&& invoice.payment_received? \
&& (item = invoice.item_by_text(file)) \
&& !item.expired?)
#State::User::Download.new(@session, item)
return_value = State::User::Download.new(@session, item)
else
#State::PayPal::Return.new(@session, invoice)
return_value = State::PayPal::Return.new(@session, invoice)
end
open("/home/masa/work/test.dat","a"){|f| f.print "return_value=", return_value, "\n"}
return return_value
end
Reboot oddb.org/bin/oddbd
Access to 'http://oddb.masa.org/de/gcc/download/invoice/25518097/email/aaa@bbb.ccc/filename/test.dat'
Result
masa@masa ~/work $ cat test.dat getin src/state/global.rb#download return_value=#<ODDB::State::User::Download:0x7f54fa0b1c78>
Access to 'http://oddb.masa.org/de/gcc/download/invoice/12345/email/aaa@bbb.ccc/filename/test.dat'
Result
getin src/state/global.rb#download return_value=#<ODDB::State::PayPal::Return:0x7f54fb4f72f0>
Consideration
Just for information
masa@masa ~/ywesee/oddb.org $ cat log/download/2010/11.log 2010-11-15 15:05:49 CET;127.0.0.1;aaa@bbb.ccc;../data/downloads/test.dat
Core part
module ODDB
module View
module User
class Download < HtmlGrid::PassThru
def init
#open("/home/masa/work/test.dat","a"){|f| f.print "getin src/view/user/download.rb#init\n"}
if(filename = @session.user_input(:filename))
@path = File.join('..', 'data', 'downloads', filename)
end
end
def to_html(context)
#open("/home/masa/work/test.dat","a"){|f| f.print "getin src/view/user/download.rb#to_html\n"}
#open("/home/masa/work/test.dat","a"){|f| f.print caller(0).pretty_inspect}
line = [
nil,
@session.remote_addr,
@session.user_input(:email),
@path,
].join(';')
LogFile.append(:download, line, Time.now)
@session.passthru(@path)
''
end
Notes
General structure (flow) of SBSM and HtmlGrid
grep search
masa@masa ~/ywesee/de.oddb.org $ grep -r passthru lib lib/oddb/html/view/download.rb:require 'htmlgrid/passthru' lib/oddb/html/view/download.rb: @session.passthru(@model)
lib/oddb/html/view/download.rb
require 'htmlgrid/passthru'
module ODDB
module Html
module View
class Download < HtmlGrid::PassThru
def to_html(context)
@session.passthru(@model)
''
end
end
end
end
end
lib/oddb/html/state/download.rb
require 'oddb/html/state/global_predefine'
require 'oddb/html/view/download'
module ODDB
module Html
module State
class Download < State::Global
VIEW = View::Download
VOLATILE = true
end
end
end
end
def _download(file)
path = File.join ODDB.config.export_dir, file
if File.exist?(path)
Download.new(@session, path)
elsif match = /(.+)_(.+).csv/.match(file)
packages = _search_local match[1].tr('-', ' '), match[2]
packages.filename = file
Drugs::DownloadExport.new(@session, packages)
end
end
def process(request)
@request_path = request.unparsed_uri
@process_start = Time.now
super
if(!is_crawler? && lookandfeel.enabled?(:query_limit))
limit_queries
end
'' ## return empty string across the drb-border
end
Notes
(Tomorrow)