Looks good, I remember trying acrcms a while ago, didn't understand
the concept very much but looked solid.  On the other hand I'll try
what you're suggesting, although looking at multisite.py code I'm
guessing this is where it chooses which database to link, isn't it?.

    def force_thread_env(self, environ):
        if environ:
            try:
                script_name = environ['SCRIPT_FILENAME']
            except:
                script_name = environ['HTTP_HOST']
        else:
            script_name = None
        self.tl.forced_script = script_name

    def __getattr__(self, name):
        if name in ('engines', 'forced_script', 'force_script',
'configs', 'tl'):
            return object.__getattribute__(self, name)

        config_key = None
        try:
            try:
                config_key = request.environ['SCRIPT_FILENAME']
            except:
                config_key = request.environ['HTTP_HOST']
        except:
            pass

        if not self.forced_script and config_key and not
self.configs.has_key(config_key):
            self.configs[config_key] = config['sqlalchemy.url']

        try:
            used_db = self.configs[config_key]
        except KeyError:
            used_db = config['sqlalchemy.url']


On Apr 21, 4:12 pm, Alessandro Molina <[email protected]>
wrote:
> On Thu, Apr 21, 2011 at 10:36 PM, Juparave <[email protected]> wrote:
> > I've been looking/waiting for a simple way to have a second database
> > running on my app.  But there's a catch, I want the second DB to be
> > selected upon the domain name. i.e.
>
> I had to do a similar thing to make multiple domains/web sites run
> inside only one ACRCms instance,
> you can take a look at 
> ithttps://bitbucket.org/_amol_/acrcms/src/243cfcaa48c4/acr_cms/acr/lib/...
>
> How it can be used can be seen here for the 
> authenticator:https://bitbucket.org/_amol_/acrcms/src/243cfcaa48c4/acr_cms/acr/conf...
>
> and here for the model 
> engine:https://bitbucket.org/_amol_/acrcms/src/243cfcaa48c4/acr_cms/acr/mode...
>
> I had to implement also an authenticator as otherwise repoze would end
> getting all the users informations from the first database instead of
> querying them based upon the domain/site instance.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to