tags:

views:

47

answers:

2

Do any of the popular web frameworks solve this problem well?

Here's an example: suppose you're running one of these web frameworks and you want to install a blog plugin. Except instead of a single blog, you need to run two separate instances of the blog plugin, and you want to keep them segregated.

Or say you want to install multiple instances of a user authentication plugin, because you want to segregate your administrative users from your customer user accounts.

Or say you want to install multiple instances of a wiki plugin for different parts of your site, or multiple instances of a comments plugin, or whatever else.

It seems to me that at the basic level, each instance of plugin would need to be able to configured with a different set of database tables, and would need to be 'installed' at a different URL path.

My experience is mostly with Django and Symfony, and I haven't seen a clean solution to this problem in either of them. They both tend to assume that each plugin (or app, in Django's case) is only ever going to be installed once.

I'm curious if the Rails folks have figured out a clean solution to this problem, or any other framework authors (in any language).

And if you were going to design a solution to this problem, what would it look like?

A: 

It would look like a BlogFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactoryFactory...

Ignacio Vazquez-Abrams
A: 

In the Ruby/Rails world at least there wouldn't be a need to install two copies of a plugin. A single copy should be able to handle the use cases you're talking about (either multiple blogs, or multiple user types, either multiple tables or using STI.) Neither of these would or should require a plugin to be installed multiple times.

x1a4
Can you elaborate a bit? How would you segregate each running instance so, for example, a list of all blog posts returns correctly for both blogs? Are you adding an extra column to the BlogPost model and filtering for that? Or something totally different? How do you differentiate between Blog A and Blog B based on the URL?
Steven Wei
Based on URL? Have a field in your blogs table with that information, then check the request URI in a controller before_filter to set which blog you're wanting to work with, then go from there. You can even go up a level, and instead have a Site model that keeps a list of domains, setting the site, and having blogs, etc. scoped to site instead of directly to URL.
x1a4
Ok, so you have to extend the plugin to get it working. That's about the same as the other web frameworks I've used.
Steven Wei
Yes, the use case you're speaking of would generally be solved with multiple deployments of a single app. If you really need to make a single installation of a codebase pretend that it's completely separate installations, you'll have to roll up your sleeves.
x1a4