On 3/20/06, Piers Cawley <[EMAIL PROTECTED]> wrote:>> And it's a *huge* change, 
touching pretty much everything. Even when I> 'cheat' by overriding 
perform_action_without_filters (an undocumented,> but very useful 
ActionController::Base method) to look like:>>   def 
perform_action_without_filters>     scope_for_content = {:find => {:conditions 
=> "blog_id = #{this_blog.id}"},>                          :create => {:blog_id 
=> this_blog.id}}>>     Content.with_scope(scope_for_content) do>       
Article.with_scope(scope_for_content) do>         
Comment.with_scope(scope_for_content) do>           
Trackback.with_scope(scope_for_content) do>             
Page.with_scope(scope_for_content) do>               super>             end>    
       end>         end>       end>     end>> there's still an awful lot of 
stuff to find and change (it turns out> that 'new' doesn't respect scoping, 
which is annoying, arguably> correct, and fixable if you're prepared to mess 
with overriding> undo!
cumented bits of Rails (which hasn't stopped us before)).
Heh.  Easy.  Since we're single-threaded, we can just do:
  def perform_action_without_filters    scope_for_content = {:find => 
{:conditions => "blog_id = #{this_blog.id}"},                         :create 
=> {:blog_id => this_blog.id}}
    Content.with_scope(scope_for_content) do      
Article.with_scope(scope_for_content) do        
Comment.with_scope(scope_for_content) do          
Trackback.with_scope(scope_for_content) do            
Page.with_scope(scope_for_content) do              $blog_id = this_blog.id      
        super            end          end        end      end    end
    class Content      def initialize        ...        self.blog_id = $blog_id 
     end    end
Should work.  It's horrifically ugly, but it should end up working.
I'm not really advocating doing it this way, but it's probably theshortest path 
to working multi-blog support.  It's also the shortestpath to madness, but we 
might be able to extract it into somethingless evil.

Scott
_______________________________________________
Typo-list mailing list
Typo-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/typo-list

Reply via email to