diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-03-09 10:24:49 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-03-09 10:24:49 +0100 |
commit | 1ffb44de021b276d3ae25fc9d9b09ec1f0f9aa16 (patch) | |
tree | e9b271b11b3a602b808693f9d451db092a17b721 | |
parent | 2b0ad7c00ec9559d05e07e78cee5f7846d51ee5f (diff) |
old database config removed
-rw-r--r-- | lib/environment.rb | 32 | ||||
-rw-r--r-- | lib/helper.rb | 13 |
2 files changed, 14 insertions, 31 deletions
diff --git a/lib/environment.rb b/lib/environment.rb index 4f04e48..59578c1 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -23,37 +23,7 @@ else end # database -=begin -if CONFIG[:database] - ['dm-core', 'dm-serializer', 'dm-timestamps', 'dm-types', 'dm-migrations', 'dm-validations' ].each{|lib| require lib } - case CONFIG[:database][:adapter] - when /sqlite/i - db_dir = File.join(basedir, "db") - FileUtils.mkdir_p db_dir - DataMapper::setup(:default, "sqlite3://#{db_dir}/opentox.sqlite3") - #when /yaml/i - #db_dir = File.join(basedir, "db") - #FileUtils.mkdir_p db_dir - #DataMapper::setup(:default, {:adapter => "yaml", :directory => 'db'}) - else - DataMapper.setup(:default, { - :adapter => CONFIG[:database][:adapter], - :database => CONFIG[:database][:database], - :username => CONFIG[:database][:username], - :password => CONFIG[:database][:password], - :host => CONFIG[:database][:host]}) - end - #db_dir = File.join(basedir, "db") - #FileUtils.mkdir_p db_dir - #DataMapper::setup(:in_memory, "in_memory") - #require 'redis' - - #DataMapper.setup(:default, {:adapter => "redis"}) - - #DataMapper::Model.raise_on_save_failure = true -end -=end -require 'ohm' +`redis-server /opt/redis/redis.conf` unless File.exists? "/var/run/redis.pid" Ohm.connect :thread_safe => true # load mail settings for error messages diff --git a/lib/helper.rb b/lib/helper.rb index 37238bd..3031b74 100644 --- a/lib/helper.rb +++ b/lib/helper.rb @@ -42,6 +42,19 @@ helpers do return env['REQUEST_URI'] =~ /\/login$/ end + def uri_available?(urlStr) + url = URI.parse(urlStr) + unless @subjectid + Net::HTTP.start(url.host, url.port) do |http| + return http.head(url.request_uri).code == "200" + end + else + Net::HTTP.start(url.host, url.port) do |http| + return http.post(url.request_uri, "subjectid=#{@subjectid}").code == "202" + end + end + end + end before do |