J.Daniel Schmidt write:
ref: refs/heads/registration commit c6c85811dd73c2f217a5a0ed12db733f9de2127c Author: J. Daniel Schmidt <jdsn@suse.de> Date: Thu Oct 8 20:19:28 2009 +0200
add debug output and context default --- .../app/controllers/configuration_controller.rb | 3 +- .../app/controllers/registration_controller.rb | 13 +++++---- plugins/registration/app/models/registration.rb | 27 +++++++++++++++---- 3 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/plugins/registration/app/controllers/configuration_controller.rb b/plugins/registration/app/controllers/configuration_controller.rb index 765c709..77315bb 100644 --- a/plugins/registration/app/controllers/configuration_controller.rb +++ b/plugins/registration/app/controllers/configuration_controller.rb @@ -1,17 +1,16 @@ # = RegistrationConfiguration controller # Provides access to the configuration of the registration system +#class Registration::ConfigurationController < ApplicationController class ConfigurationController < ApplicationController
before_filter :login_required
- def update # PUT # setRegistrationServerDetails @registration = "PUT to /registration/configuration" end
- def show @registration = Registration.new( { } ) # do not run registration diff --git a/plugins/registration/app/controllers/registration_controller.rb b/plugins/registration/app/controllers/registration_controller.rb index 56cb2f1..0362770 100644 --- a/plugins/registration/app/controllers/registration_controller.rb +++ b/plugins/registration/app/controllers/registration_controller.rb @@ -5,20 +5,21 @@ class RegistrationController < ApplicationController
before_filter :login_required
- # @registration = Registration.new( { :doo => :daa } ) - - def update end
def create + puts "-> REGISTRATION CREATE" ^^^^ Hi, please don't add debugging output as puts. It is not rails way, you don't have filtering ability of logging and it is confusing. Please use rails logger. For usage look at other modules. If you have any questions just ask.
# POST to registration => run registration @registration = Registration.new({}) - + puts "-> NEW registration" + puts @registration.inspect # TODO: parse post data and set context data #@registration.set_context( { } ) - @registration.register - + ret = @registration.register + puts "-> RAN register" + puts ret.inspect + puts "-> PUT inpect ^" end
def show diff --git a/plugins/registration/app/models/registration.rb b/plugins/registration/app/models/registration.rb index 772e154..44e0133 100644 --- a/plugins/registration/app/models/registration.rb +++ b/plugins/registration/app/models/registration.rb @@ -12,8 +12,18 @@ class Registration @reg = ''
def initialize(hash) + # set context defaults + @context = { 'yastcall' => 1, + 'norefresh' => 1, + 'restoreRepos' => 1, + 'forcereg' => 0, + 'nohwdata' => 1, + 'nooptional' => 1, + 'logfile' => '/root/.suse_register.log' } + + # merge custom context data if hash.class.to_s == 'Hash' - @context = hash + @context.merge hash else raise "Invalid or missing registration initialization context data." end @@ -32,15 +42,20 @@ class Registration end
def register - @reg = YastService.Call("YSR::stateless_register", @context ) + puts "-> called registration.register" + @reg = YastService.Call("YSR::stateless_register", { 'ctx' => @context, 'arguments' => @arguments } ) + puts "-> YSR::stateless_register was called" + puts @reg.inspect + return @reg.inspect
Returning inspect, which should change in next rails version is not good idea. If you want formated description for user I think that user welcome more html way then pure string.
end
- def get_registration_server_details - @reg = "get-reg-srv-det" + def get_registration_config + return @reg.inspect end
- def set_registration_server_details(url, ca) - @reg = "you want to set URL: #{ url }" + def set_registration_config(url, ca) + # TODO: write registration config + return @reg.inspect end
At overall I think that you overload controller layer. It should be thin layer which connect model with view. I think that many your methods should go to model. Controller should contain only model initialization and model changing. Rest model manipulation should go to model. Look e.g. at time module or language, how thin should be controller layer. -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, webyast modules language and time -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org