You are viewing a plain text version of this content. The canonical link for it is here.
Posted to olio-commits@incubator.apache.org by ws...@apache.org on 2009/03/15 07:45:34 UTC

svn commit: r754627 - in /incubator/olio/webapp/rails/branches/caching: app/controllers/ app/helpers/ app/models/ app/views/events/ app/views/layouts/ bin/ config/ config/environments/ db/migrate/ etc/ lib/ vendor/plugins/country_select/ vendor/plugins...

Author: wsobel
Date: Sun Mar 15 07:45:32 2009
New Revision: 754627

URL: http://svn.apache.org/viewvc?rev=754627&view=rev
Log:
Fix for OLIO-59: Made caching configurable. Now has 3 modes: File, Memcached, and none

Added:
    incubator/olio/webapp/rails/branches/caching/bin/
      - copied from r754621, incubator/olio/webapp/rails/trunk/bin/
    incubator/olio/webapp/rails/branches/caching/bin/start_thin
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/bin/start_thin
    incubator/olio/webapp/rails/branches/caching/bin/stop_thin
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/bin/stop_thin
    incubator/olio/webapp/rails/branches/caching/db/migrate/20090226193152_improve_indexes.rb
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/db/migrate/20090226193152_improve_indexes.rb
    incubator/olio/webapp/rails/branches/caching/db/migrate/20090302210151_increase_db_field_sizes.rb
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/db/migrate/20090302210151_increase_db_field_sizes.rb
    incubator/olio/webapp/rails/branches/caching/etc/
      - copied from r754621, incubator/olio/webapp/rails/trunk/etc/
    incubator/olio/webapp/rails/branches/caching/etc/nginx.conf
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/etc/nginx.conf
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/
      - copied from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/MIT-LICENSE
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/MIT-LICENSE
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/README
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/README
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/init.rb
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/init.rb
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/install.rb
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/install.rb
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/lib/
      - copied from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/lib/
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/lib/country_select.rb
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/lib/country_select.rb
    incubator/olio/webapp/rails/branches/caching/vendor/plugins/country_select/uninstall.rb
      - copied unchanged from r754621, incubator/olio/webapp/rails/trunk/vendor/plugins/country_select/uninstall.rb
Modified:
    incubator/olio/webapp/rails/branches/caching/app/controllers/application.rb
    incubator/olio/webapp/rails/branches/caching/app/controllers/events_controller.rb
    incubator/olio/webapp/rails/branches/caching/app/controllers/users_controller.rb
    incubator/olio/webapp/rails/branches/caching/app/helpers/application_helper.rb
    incubator/olio/webapp/rails/branches/caching/app/helpers/events_helper.rb
    incubator/olio/webapp/rails/branches/caching/app/models/document.rb
    incubator/olio/webapp/rails/branches/caching/app/models/event.rb
    incubator/olio/webapp/rails/branches/caching/app/models/geolocation.rb
    incubator/olio/webapp/rails/branches/caching/app/models/image.rb
    incubator/olio/webapp/rails/branches/caching/app/views/events/_attendees.html.erb
    incubator/olio/webapp/rails/branches/caching/app/views/events/_event_list.html.erb
    incubator/olio/webapp/rails/branches/caching/app/views/layouts/site.rhtml
    incubator/olio/webapp/rails/branches/caching/config/boot.rb
    incubator/olio/webapp/rails/branches/caching/config/environment.rb
    incubator/olio/webapp/rails/branches/caching/config/environments/production.rb
    incubator/olio/webapp/rails/branches/caching/lib/lazy.rb

Modified: incubator/olio/webapp/rails/branches/caching/app/controllers/application.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/controllers/application.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/controllers/application.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/controllers/application.rb Sun Mar 15 07:45:32 2009
@@ -3,7 +3,7 @@
 
 class ApplicationController < ActionController::Base
   # Pick a unique cookie name to distinguish our session data from others'
-  session :session_key => '_perf_session_id'# unless $Memcached
+  session :session_key => '_perf_session_id'
   
   def authorize
     begin

Modified: incubator/olio/webapp/rails/branches/caching/app/controllers/events_controller.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/controllers/events_controller.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/controllers/events_controller.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/controllers/events_controller.rb Sun Mar 15 07:45:32 2009
@@ -5,26 +5,27 @@
     :new, :edit, :create, :update, :destroy, 
     :attend, :unattend, :tag
   ]
+
+  MAX_ATTENDEES = 20
+  
+  if CACHED
   # Turned off for memcached
-  protect_from_forgery :only => [:update, :destroy, :delete, :create] unless Memcached
+    protect_from_forgery :only => [:update, :destroy, :delete, :create] unless Memcached
 
-  after_filter :expire_home, :only => :index
-  after_filter :expire_calendar, :only => :update_calendar
-  after_filter :expire_tag, :only => :tag
-  
-  caches_page :index, {:expire => 2.minutes.to_i}
-  cache_sweeper :event_sweeper, :only => [:create, :destroy, :update]
-  
-  # This will reduce load times for pages that don't use 
-  # TinyMCE by not forcing all pages to unnecessarily load TinyMCE's .js files - Hubert
-  uses_tiny_mce :only => [:new, :edit, :show]
+    after_filter :expire_home, :only => :index
+    after_filter :expire_calendar, :only => :update_calendar
+    after_filter :expire_tag, :only => :tag
   
+    caches_page :index, {:expire => 2.minutes.to_i}
+    cache_sweeper :event_sweeper, :only => [:create, :destroy, :update]
+  end
+    
   ### CRUD Actions ######################################################## 
   
   # GET /events
   # GET /events.xml
   def home
-    if !session[:user_id].nil?
+    if CACHED and !session[:user_id].nil?
       do_index_page
       respond_to do |format|
         format.html { render :template => "events/index.html.erb" } # index.html.erb
@@ -38,7 +39,7 @@
   
   # "home" = root page for those not logged in
   def index
-    if session[:user_id].nil?
+    if !CACHED or session[:user_id].nil?
       do_index_page
       respond_to do |format|
         format.html # index.html.erb
@@ -53,7 +54,8 @@
   # GET /events/1
   # GET /events/1.xml  
   def show
-    @event = lazy { Event.find(params[:id]) }
+    @event = lazy { Event.find(params[:id], :include => [:image, :document, {:comments => :user }, :address]) }
+    @attendees = lazy { attendee_list(@event, MAX_ATTENDEES) }
     @comment = Comment.new
     @comment.rating = 0
     respond_to do |format|
@@ -81,6 +83,9 @@
     @event.user_id = session[:user_id]
     @event.set_date
     @address = Address.new(params[:address])
+    @geolocation = Geolocation.new(@address.street1, @address.city, @address.state, @address.zip)
+    @address.longitude = @geolocation.longitude
+    @address.latitude = @geolocation.latitude
     begin
       Event.transaction do
         @address.save!
@@ -140,7 +145,9 @@
         
         @event.image = Image.make_from_upload(params[:event_image], @event.id) if new_image?
         @event.document = Document.make_from_upload(params[:event_document], @event.id) if new_document?
-        
+        @geolocation = Geolocation.new(@address.street1, @address.city, @address.state, @address.zip)
+        @address.longitude = @geolocation.longitude
+        @address.latitude = @geolocation.latitude
         @event.save! # must come after all other updates
         
         set_tags(@event)
@@ -235,7 +242,7 @@
       end
     end
     
-    @attendees = @event.users
+    @attendees = attendee_list(@event, MAX_ATTENDEES)
     
     respond_to do |format|
       format.html { redirect_to(event_path(@event)) }
@@ -258,7 +265,7 @@
       end
     end
     
-    @attendees = @event.users
+    @attendees = attendee_list(@event, MAX_ATTENDEES)
     
     respond_to do |format|
       format.html { redirect_to(event_path(@event)) }
@@ -309,10 +316,9 @@
 
     session[:order] = params[:order] || session[:order] || 'event_date'
       
-    @events = Event.paginate :page => params[:page], :conditions => conditions, :order => session[:order], :per_page => 10, :include => [:address, :image]
+    @events = Event.paginate :page => params[:page], :conditions => conditions, :order => session[:order], :per_page => 10,  :include => [:address, :image]
     if @zipcode and !@zipcode.empty?
       @events.delete_if { |e| e.address.zip != @zipcode }
-      @geolocation = Geolocation.find_by_zip @zipcode
     end
       
     @tags = lazy { Event.top_n_tags(50) }
@@ -338,6 +344,17 @@
   def new_document?
     return (params[:event_document] == '') ? false : true
   end
+
+  def attendee_list(event, max)
+    users = event.users.find(:all, :limit => max)
+    if session[:user_id]
+      included = users.find { |u| u.id == session[:user_id] }
+      if !included and event.users.count(:conditions => ["users.id = ?",  session[:user_id]]) > 0
+        users<< (@user || User.find(session[:user_id]))
+      end
+    end
+    users
+  end
   
   # CACHING - methods to expire fragments
   

Modified: incubator/olio/webapp/rails/branches/caching/app/controllers/users_controller.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/controllers/users_controller.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/controllers/users_controller.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/controllers/users_controller.rb Sun Mar 15 07:45:32 2009
@@ -2,14 +2,7 @@
   
   before_filter :authorize, :except => [ :new, :create, :login, :check_name, :show ]
   layout "site"
-  
-  # CACHING
-  #cache_sweeper :event_sweeper, :only => [:login, :logout]
-  
-  # This will reduce load times for pages that don't use 
-  # TinyMCE by not forcing all pages to unnecessarily load TinyMCE's .js files - Hubert
-  uses_tiny_mce :only => [:new, :edit]
-  
+    
   # GET /users
   # GET /users.xml
   def index
@@ -79,6 +72,9 @@
   def create
     @user = User.new(params[:user])
     @address = Address.new(params[:address])
+    @geolocation = Geolocation.new(@address.street1, @address.city, @address.state, @address.zip)
+    @address.longitude = @geolocation.longitude
+    @address.latitude = @geolocation.latitude
     begin
       User.transaction do
         @user.image = Image.make_from_upload params[:user_image], @user.id if new_image?
@@ -157,14 +153,14 @@
         session[:upcoming] = user.upcoming_events[0,3].map { |e| e.id } # top 3 upcoming events
         uri = session[:original_uri]
         session[:original_uri] = nil
-        
-        #flash[:notice] = "Successfully logged in!"
+                
+        flash[:notice] = "Successfully logged in!"
         redirect_to(uri || events_path)
       else
         user = nil
         params[:email] = nil
         params[:password] = nil
-        #flash[:notice] = "Invalid user/password combination."
+        flash[:notice] = "Invalid user/password combination."
         redirect_to(root_path)
       end
     end

Modified: incubator/olio/webapp/rails/branches/caching/app/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/helpers/application_helper.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/helpers/application_helper.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/helpers/application_helper.rb Sun Mar 15 07:45:32 2009
@@ -65,7 +65,7 @@
   #depends on calling controller having a tagged action, defaults to events_controller
   def tag_cloud_items(tags, target_controller = 'events')
     links = []
-    tag_cloud_font_sizes tags do |name, font_size|
+    tag_cloud_font_sizes(tags) do |name, font_size|
       link = link_to name, {:controller => target_controller, :action => 'tagged', :tag => name}, {:style => font_size}
       links << link
     end

Modified: incubator/olio/webapp/rails/branches/caching/app/helpers/events_helper.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/helpers/events_helper.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/helpers/events_helper.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/helpers/events_helper.rb Sun Mar 15 07:45:32 2009
@@ -3,7 +3,7 @@
   def attendance_links(event)
     links = ""
     if logged_in?
-      attending = event.users.map{ |u| u.id }.include?(session[:user_id])
+      attending = @attendees.find { |u| u.id == session[:user_id] }
       if attending
         links += form_remote_tag :url => unattend_event_path(event), :method => :post, :html => {:method => :post}
         links += submit_tag "Unattend"

Modified: incubator/olio/webapp/rails/branches/caching/app/models/document.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/models/document.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/models/document.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/models/document.rb Sun Mar 15 07:45:32 2009
@@ -11,7 +11,8 @@
 
 class Document < ActiveRecord::Base
   
-  has_attachment :content_type => ['application/pdf', 'application/msword', 'text/plain'],
+  has_attachment :content_type => ['application/pdf', 'application/pdf; charset=ISO-8859-1',
+                                   'application/msword', 'text/plain'],
                  :storage => :file_system, 
                  :path_prefix => DOCUMENT_STORE_PATH
   

Modified: incubator/olio/webapp/rails/branches/caching/app/models/event.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/models/event.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/models/event.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/models/event.rb Sun Mar 15 07:45:32 2009
@@ -48,7 +48,7 @@
   end
   
   def new_attendee(user)
-    users << user if user.valid? && !users.include?(user)
+    users << user if !users.include?(user)
   end
   
   def remove_attendee(user)

Modified: incubator/olio/webapp/rails/branches/caching/app/models/geolocation.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/models/geolocation.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/models/geolocation.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/models/geolocation.rb Sun Mar 15 07:45:32 2009
@@ -1,30 +1,24 @@
-# +------------+--------------+------+-----+---------+----------------+
-# | Field      | Type         | Null | Key | Default | Extra          |
-# +------------+--------------+------+-----+---------+----------------+
-# | id         | int(11)      | NO   | PRI | NULL    | auto_increment | 
-# | zip        | int(11)      | YES  | MUL | NULL    |                | 
-# | state_code | varchar(255) | YES  |     | NULL    |                | 
-# | state      | varchar(255) | YES  |     | NULL    |                | 
-# | city       | varchar(255) | YES  |     | NULL    |                | 
-# | longitude  | float        | YES  |     | NULL    |                | 
-# | latitude   | float        | YES  |     | NULL    |                | 
-# | created_at | datetime     | YES  |     | NULL    |                | 
-# | updated_at | datetime     | YES  |     | NULL    |                | 
-class Geolocation < ActiveRecord::Base
+require 'net/http'
+require 'cgi'
 
-  # For now, everything assumed is to be in the United States
-  # Will more countries be added later?
-  validates_presence_of :zip, :city
-  validates_uniqueness_of :zip
+class Geolocation
+  attr_reader :address, :city, :state, :zip, :country, :latitude, :longitude
   
-  # As of now, zip code ranges from 1001 to 99950 in current database
+  @@url = 'http://localhost:8080/geocoder/geocode?appid=gsd5f'
   
-  validates_numericality_of :latitude, :longitude
-  validates_inclusion_of :latitude,
-                         :in => -90..90,
-                         :message => "must be between -90 and 90 degrees"
-  validates_inclusion_of :longitude,
-                         :in => -180..180,
-                         :message => "must be between -180 and 180 degrees"
-
+  def self.url=(url)
+    @@url = url
+  end
+  
+  def initialize(street, city, state, zip)
+    args = %w{street city state zip}.zip([street, city, state, zip]).map do |n, v|
+      "#{n}=#{CGI::escape(v)}"
+    end.join('&')
+    response = Net::HTTP.get(URI.parse("#{@@url}&#{args}"))
+    if response
+      eval(response.scan(%r{<([A-Za-z]+)>\s*([^<]+)\s*</\1>}m).map do |k, v|
+        "@#{k.downcase} = '#{v.chomp}'"
+      end.join(';'))
+    end
+  end
 end

Modified: incubator/olio/webapp/rails/branches/caching/app/models/image.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/models/image.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/models/image.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/models/image.rb Sun Mar 15 07:45:32 2009
@@ -13,6 +13,10 @@
 #  thumbnail    :string(255)     
 #
 
+unless Technoweenie::AttachmentFu.content_types.include? 'image/jpeg; charset=ISO-8859-1'
+  Technoweenie::AttachmentFu.content_types << 'image/jpeg; charset=ISO-8859-1'
+end
+
 class Image < ActiveRecord::Base
   has_attachment :content_type => :image, 
                  :storage => :file_system, 
@@ -23,6 +27,13 @@
   validates_uniqueness_of :filename
   validates_as_attachment
   
+  # Overload the thumbnail name so it's compatible with the php file generator.
+  def thumbnail_name_for(thumbnail = nil)
+    name = super
+    name.sub!(/_thumb/, 't')
+    name
+  end
+  
   include Uploadable
   
 end

Modified: incubator/olio/webapp/rails/branches/caching/app/views/events/_attendees.html.erb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/views/events/_attendees.html.erb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/views/events/_attendees.html.erb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/views/events/_attendees.html.erb Sun Mar 15 07:45:32 2009
@@ -1,16 +1,16 @@
 <div id="attendees">
-  <h2 class="smaller_heading"><%= pluralize @event.users.size, 'Attendee' %>:</h2><br/>
+  <h2 class="smaller_heading">At least <%= pluralize @attendees.size, 'Attendee' %>:</h2><br/>
   
   <%= attendance_links(@event) %> 
 
-  <% if @event.users.empty? -%>
+  <% if @attendees.nil? or @attendees.empty? -%>
     <br />
   <% else -%>
     <ol>
-    <% for attendee in @event.users.reverse -%>
+    <% for attendee in @attendees.reverse -%>
       <li><%= link_to attendee.username, user_path(attendee) %></li>
     <% end -%>
     </ol>
   <% end -%>
 
-</div>
\ No newline at end of file
+</div>

Modified: incubator/olio/webapp/rails/branches/caching/app/views/events/_event_list.html.erb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/views/events/_event_list.html.erb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/views/events/_event_list.html.erb (original)
+++ incubator/olio/webapp/rails/branches/caching/app/views/events/_event_list.html.erb Sun Mar 15 07:45:32 2009
@@ -39,9 +39,6 @@
     <div>
       <h1 class="tight_heading"><%= @date.nil? ? "All Events" : "#{simple_date(@date)} events" %></h1>
       <h2 id="which_timezone" class="tight_heading"><%= (@zipcode and !@zipcode.nil? and !@zipcode.empty?) ? "for #{@zipcode}" : "for all locations" %>
-  		<% if @geolocation %>
-  			<%= "(#{@geolocation.city}, #{@geolocation.state_code})" %>
-  		<% end %>
   		</h2>
 		</div>
       

Modified: incubator/olio/webapp/rails/branches/caching/app/views/layouts/site.rhtml
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/app/views/layouts/site.rhtml?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/app/views/layouts/site.rhtml (original)
+++ incubator/olio/webapp/rails/branches/caching/app/views/layouts/site.rhtml Sun Mar 15 07:45:32 2009
@@ -5,9 +5,6 @@
 <head>
   <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
   <title>Rails Performance: <%= controller.action_name %></title>
-  <% # Include TinyMCE before other JS to avoid problems -%>
-  <%= javascript_include_tiny_mce_if_used %>
-  <%= tiny_mce if using_tiny_mce? %>
   <%= javascript_include_tag :defaults %>
   <%= stylesheet_link_tag 'scaffold' %>
   <%= stylesheet_link_tag 'site' %>

Modified: incubator/olio/webapp/rails/branches/caching/config/boot.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/config/boot.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/config/boot.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/config/boot.rb Sun Mar 15 07:45:32 2009
@@ -83,7 +83,8 @@
       def load_rubygems
         require 'rubygems'
 
-        unless rubygems_version >= '0.9.4'
+        gem_ver = defined? Gem::RubyGemsVersion ? Gem::RubyGemsVersion : rubygems_version
+        unless gem_ver >= '0.9.4'
           $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
           exit 1
         end

Modified: incubator/olio/webapp/rails/branches/caching/config/environment.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/config/environment.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/config/environment.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/config/environment.rb Sun Mar 15 07:45:32 2009
@@ -11,9 +11,13 @@
 require File.join(File.dirname(__FILE__), 'boot')
 require 'hodel_3000_compliant_logger'
 
-Memcached = true
+CACHED = true
+Memcached = false
 
-if Memcached
+IMAGE_STORE_PATH = 'public/uploaded_files'
+DOCUMENT_STORE_PATH = 'public/uploaded_files'
+
+if CACHED and Memcached
   require 'memcache'
   CACHE = MemCache.new :c_threshold => 1_000,:compression => true,:debug => false,:namespace => 'mycachespace',:readonly => false,:urlencode => false
   CACHE.servers = '10.251.63.95:11211'
@@ -53,7 +57,7 @@
   # config.active_record.default_timezone = :utc
 
   # Memcached Config ## START ##
-  if Memcached
+  if CACHED and Memcached
     config.action_controller.session_store = :mem_cache_store
     config.action_controller.cache_store = CACHE, {}
     config.action_controller.fragment_cache_store = CACHE, {}
@@ -80,7 +84,7 @@
   # See Rails::Configuration for more options  
 end
 
-if Memcached
+if CACHED and Memcached
   # Memcached Config ## START ##
   ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.merge!({ 'cache' => CACHE })
   # Memcached Config ## END ##
@@ -96,6 +100,5 @@
 require 'lazy'
 require RAILS_ROOT + '/test/selenium_helper' if defined? SeleniumOnRails::FixtureLoader
 
-IMAGE_STORE_PATH = 'public/assets'
-DOCUMENT_STORE_PATH = 'public/assets'
-
+require 'geolocation'
+Geolocation.url = 'http://localhost:8080/geocoder/geocode?appid=gsd5f'

Modified: incubator/olio/webapp/rails/branches/caching/config/environments/production.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/config/environments/production.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/config/environments/production.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/config/environments/production.rb Sun Mar 15 07:45:32 2009
@@ -16,6 +16,11 @@
 # config.action_controller.asset_host                  = "http://assets.example.com"
 
 # Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
-#config.action_controller.cache_store = :file_store, RAILS_ROOT + '/tmp/cache/'
-config.action_controller.cache_store = :mem_cache_store
+if CACHED
+  if Memcached
+    config.action_controller.cache_store = :mem_cache_store
+  else
+    config.action_mailer.raise_delivery_errors = false
+    config.action_controller.cache_store = :file_store, RAILS_ROOT + '/tmp/cache/'
+  end
+end
\ No newline at end of file

Modified: incubator/olio/webapp/rails/branches/caching/lib/lazy.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/branches/caching/lib/lazy.rb?rev=754627&r1=754626&r2=754627&view=diff
==============================================================================
--- incubator/olio/webapp/rails/branches/caching/lib/lazy.rb (original)
+++ incubator/olio/webapp/rails/branches/caching/lib/lazy.rb Sun Mar 15 07:45:32 2009
@@ -13,7 +13,7 @@
   end
   
   def resolve
-    puts caller.join("\n") unless @obj
+    # puts caller.join("\n") unless @obj
     @obj ||= @block.call
   end