From 1ffb44de021b276d3ae25fc9d9b09ec1f0f9aa16 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 9 Mar 2011 10:24:49 +0100 Subject: old database config removed --- lib/environment.rb | 32 +------------------------------- lib/helper.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 31 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3