Chapter 16. Multi-Databases, Alternative to SiteGroups - ALPHA

MultiDB allows the use of different databases for separate phases of a midgard request. It can be an alternative to using sitegroups.

The following directives have been added: MidgardPageDatabase [dbname] [username] [password] MidgardAuthDatabase [dbname] [username] [password]

When either of these are not specified they default to the values of the most recent MidgardDatabase directive.

MidgardPageDatabase will cause the page and style information to be read from that database instead of the main database. After the page and style info have been collected the active database will be switched to the main database (specified by MidgardDatabase) so authentication will be done against the main database. You can use this to make a shared site available while not making the actual site resources available.

You can use MidgardAuthDatabase to force authentication against another database. You will probably want to have a MidgardPageDatabase with the same values if you use this. I only added this directive so you could log into someone elses database while not having access to the account passwords therein; WARNINGI mainly meant this to be used for root-type users, so using this directive will force you to root status. This will also set your user ID to 0 so be careful what you do; the user id will not exist in the database you're rooting around in (so that's where the expression originated) so if you were to create a page, for example, it would never show up in an mgd_list_page call.WARNING

1. main site <virtualhost 127.0.0.1:80> Servername www.domain.com MidgardDatabase midgard midgard midgard </virtualhost>

2. client admin site. He'd see the pages of the admin site but there through the admin # interface he will only see the resources of his own site; the admin site will be totally # invisible. <virtualhost 127.0.0.1:80> Servername admin.domain.com MidgardPageDatabase adminsite midgard midgard MidgardDatabase midgard midgard midgard </virtualhost>

3. Access the client site using the shared database as root. Authenticate agains acounts # in the shared database. <virtualhost 127.0.0.1:80> Servername root.domain.com MidgardDatabase midgard midgard midgard MidgardPageDatabase adminsite midgard midgard MidgardAuthDatabase adminsite midgard midgard </virtualhost>

4. Normal access to the shared site for maintenance <virtualhost 127.0.0.1:80> Servername maint.isp.com MidgardDatabase adminsite midgard midgard </virtualhost>

Using MidgardPageDatabase is almost transparent, but one thing to note: $midgard->page will refer to the ID of the page served from the MidgardPageDatabase, which will not be available when the page starts executing, so $midgard->page should not be used. Likewise, page parameters will not be retrieveable. Page blobs are OK since they'll be served by mod_midgard. All these restrictions do not apply to example 4 of course since it doesn't use PageDatabase but uses the database as the main database.