On Tuesday, 28 June 2016 21:54:06 UTC-5, Tres Seaver wrote: > > > On 06/28/2016 03:42 AM, Gerhard Schmidt wrote: > > Hi, > > > > is there a simple way to use more than one ZODB databases in one > > Pyramid app. > > If you can wean yourself from the mountpoint idea, it is quite feasible > to define different root factories[1] for separate routes (path > prefixes). The downside is that you would not be able to store > cross-database references, as you might have with mountpoints: I > consider that an advantage, actually. >
Another option is to simply configure a ZODB multi-database. If you remember that the logical traversal containment structure is completely separate from the ZODB database containment, then you can manually partition your objects amongst the DBs any way you choose. You can do this at app setup time; for example, use zope.generations to put the root folder in DB1, and the users folder---which is a child of the root folder---in DB2, and their other children will [mostly] automatically follow along. Or you can do this at object creation time; for example, if you traverse to content via a username, like /users/<User>/path/to/object, then when you create a new user account, you could hash it and choose a database to assign it to and it and all its children will [mostly] automatically live in that DB. The code to distribute objects can usually be contained to a very small area. The upside is that you have a single traversal tree. (One of my apps does this, and I can confirm it works well.) The downside is that you're dealing with a ZODB multi-database and cross-database references. As Tres notes, both can be complex to manage. (One of my apps does this, and I can confirm it has been operationally complex to manage.) Jason -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/50389f49-e2c4-4906-bc64-bf53ce1a77a7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
