Re: one model, multiple database instances
Sebastien Bigaret <[email protected]> 10 Aug 2004 07:47:43 +0200
| Newsgroups | gmane.comp.python.modeling |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Delio Brignoli <[email protected]> wrote:
> Hello,
>
> I'm evaluating the use of modeling for our new project(s) and was
> wondering if some of you could give me pointers on how to access
> multiple database instances of the same model in the same
> application. (I understand that each database instance will be
> isolated and don't expect to insert object from an objectStore into
> another) After creating my first model definition and 30 minutes dive
> in the docs, it seems I'll have to create an EC passing a 'properly
> crafted' :-) ObjectStore instance. Am I on the right track?
Without more details, I guess you intend to do some load-balancing between db-instances in aread-only app., right?
First, if you want to do that in different processes, simply change
the model's connection dictionary before using it; each process will
then use its own db instance.
Regarding EC(parentObjectStore): it's usually used to make child ECs;
passing it a dedicated ObjectStore is completely untested. But you're on
the right track: you can either give it a dedicated DBContext, or use
the default behaviour (which assigns a ObjectStoreCoordinator) and
design your own ObjStoreCoord. so that e.g. it returns different
DBContexts for different ECs.
In both cases, you'll have to take care of the DBContext's Database
(see e.g. DBContext.handleNotification): either each one gets its own,
or they all share the same. If every DBContext gets its own Database
object, then each EC should *always* get the same DBContext, or you'll
defeat the snapshotting ref. counting.
-- Sébastien.
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285