lib/ezframe/controller.rb in ezframe-0.0.1 vs lib/ezframe/controller.rb in ezframe-0.0.3

- old
+ new

@@ -7,26 +7,37 @@ @request = request Config.load_files("./config") Model.init model = Model.get_clone Auth.init_warden - Auth.model = model + @request.env["model"] = model + # Auth.model = model mylog("exec: path=#{request.path_info} params=#{request.params}") klass, method = PageBase::decide_route(request.path_info) - mylog "klass=#{klass}, method=#{method}" + unless klass + response.status = 404 + response['Content-Type'] = 'text/html; charset=utf-8' + response.body = [ Html.convert(Ht.p("file not found")) ] + return + end + method = "default" if !method || method=="undefined" page = klass.new(request, model) if request.post? method_full_name = "public_#{method}_post" else method_full_name = "public_#{method}_page" end - warden.authenticate! if page.auth + if page.auth + warden.authenticate! + end # request.env["rack.session"]["kamatest"]="usable" - mylog "method: #{klass}.#{method_full_name}" - mylog "rack.session.id=#{request.env['rack.session'].id}" + # mylog "method: #{klass}.#{method_full_name}" + #mylog "rack.session.id=#{request.env['rack.session'].id}" mylog "rack.session.keys=#{request.env['rack.session'].keys}" + #mylog "warden=#{request.env['warden'].inspect}" + mylog "klass=#{klass}, method=#{method_full_name}" body = if page.respond_to?(method_full_name) page.send(method_full_name) else mylog "no such method: #{method_full_name}" page.public_default_page @@ -39,14 +50,13 @@ response['Content-Type'] = 'text/html; charset=utf-8' end response.status = 200 end - - def file_not_found(response) - response.body = ['path not found'] - response.status = 404 - end +# def file_not_found(response) +# response.body = ['path not found'] +# response.status = 404 +# end def warden @request.env["warden"] end