Pyramid app with multiple ZODB Mountpoints

50 views
Skip to first unread message

Gerhard Schmidt

unread,
Jun 28, 2016, 3:45:15 AM6/28/16
to pylons-...@googlegroups.com
Hi,

is there a simple way to use more than one ZODB databases in one Pyramid
app.

Haven't found any example of doing this.

Regards
Estartu

--
----------------------------------------------------------------------------
Gerhard Schmidt | http://www.augusta.de/~estartu/ |
Fischbachweg 3 | | PGP Public Key
86856 Hiltenfingen | JabberID: est...@augusta.de | auf Anfrage/
Tel: 08232 77 36 4 | | on request
Fax: 08232 77 36 3 | |
estartu.vcf
signature.asc

Tres Seaver

unread,
Jun 28, 2016, 10:54:06 PM6/28/16
to pylons-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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.


[1] http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/hybrid.ht
ml

Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tse...@palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJXczg5AAoJEPKpaDSJE9HYFv4P/36EUVA+nFMRNt4HqnqFXtrM
YZsLoimW2Fz5vkUoh0l2a3l5Ciqb46gQ3vTraX5tIfJDIweFlLKbA4JK9c6VxcjN
wlOjfR+a+4KuakVhPk8YZGDMS0hAEJpdMQP4PLDv66bbxhNtHPJrjoPD/y+8cGCz
NoYol7/tTVEl7IpWPAEK5XRKm3rgBRnSt+GZg8Fji8EeVrXzeax7Ol7IEUMhuJUZ
An3tgAErjw25ujMkdi2M6yto/C8YoEWkzjapqUXiLFoTIFwdif1eXryMfFvXAe+A
HjKFjGMsoYtSMbXgK7jGHx6cnXAs+aUUE5kZGvUKbhVH2erXLIUzeFbbHP3ZssBP
QNpSpfcjbE5abfCHit6utdP1p1nz9LjI6Nro7Zdcff9Hd5wCBDVkpfLyCislgfm9
V+nGhDAoPT+gCBBY/qWHeUFj3trnfEOG1GdaaCTKpRKMOg0kxtw/Asrpe/y2yLGn
KECDGh7/0IwhGWngSo2dVPqRum5unXKV+7IlrNk9sbi6/oW8NJ6pOCgzN/5P2dH3
yAer8JcfuKC7cd4XLMo+vIuxGw97xtdbnJN3VRWPvsAwuNRXypjEtropNwuf/Bha
0JLwPmHVgtdWOSQE7GuhTOqdyiK0+A7FbNO3n0VGbFcKpKZMXBkuWD/AqBK2424O
QHpB5O6ktNC79XL9uwaF
=R+vg
-----END PGP SIGNATURE-----

Jason Madden

unread,
Jun 29, 2016, 8:26:45 AM6/29/16
to pylons-discuss, tse...@palladion.com

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
 
Reply all
Reply to author
Forward
0 new messages