#5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities"))
by Luc Saffre · in Developers · assigned to Luc Saffre
Kokkuvõte
My current plan is packed into the userspaces branch. I believe that it would work, but right now we have no real-life use case.
A new model users.UserSpace with just a name field.
New plugin setting users.with_user_spaces.
New models 'users.UserSpace' and 'users.Membership'.
New field User.current_space points to UserSpace.
Plugin method get_default_userspace().
New class attribute Model.interspace_models = False
All models having this True automatically get a field 'userspace' injected (a non-nullable pointer to users.UserSpace),
When a model is interspace, get_request_queryset() adds a filter(user_space=ar.get_user().current_space) and on_create() sets that field to User.userspace.
There will be one SiteConfig per userspace. And dd.today() will move from Site to BaseRequest or User because it needs the userspace.
Should users be able to switch between the different user spaces of which they are members?
The word for this is multitenancy, so I'd replace "user space" by "tenant".
Which tenant to use for anonymous user? A default tenant in the settings?
Should a multitenant Lino site have only one shared Site instance for all tenants?
Don't we want each tenant to choose their language distribution? Which would mean that each tenant has their own site cache.
So even settings.SITE would actually just become a property, which would return a different Site instance dependaing on whats the current tenant.
The current tenant would be a variable similar to the current language, i.e. it would be set by the middleware, and we would have a module lino.core.tenants, similar to django.utils.languages.
Children
- #6469 (Move today() from Site to User) (by Luc Saffre in Developers)
Kommentaarid
- 9 kuud, 2 nädalat ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : todo: Generate the site cache per tenant. Add options like use_accounting, use_cms etc to SiteConfig. Add an action to run "pm prepare" via web on a given tenant.
- 9 kuud, 4 nädalat ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : See also #6469 (Move today() from Site to BaseRequest).
- 9 kuud, 4 nädalat ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : The site_config property will move from Site to User (and AnonymousUser needs a default implementation). And the site cache will not depend only on user_type but also on tenant.
- 11 kuud, 3 nädalat ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : "Multitentant" is the word we have been looking for! "A multitenant system is when a single instance of software runs on a server and serves multiple customers (tenants).
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : I moved my local changes in (lino, xl, book, cms, noi, welfare and voga) to a new branch "userspaces" and plan to leave them waiting there. Right I rather feel that this idea was wrong. We don't need the userspaces feature for synodalworld (what we need there is individual menu tree for pages who wa...
- 1 aasta, 2 kuud ago by Luc Saffre in reply to Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : For example even dd.today() needs to know the userspace. OMG.
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) (1 reply) : A rather wide-reaching impact of this new feature is that site_config no longer can be cached on the Site object, you need to know the userspace in order to get your SiteConfig instance.
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : I'm still fiddling with a basic question: i want multiple "home pages" on a same site. For example the laundry and synodalworld fixtures should each create their tree of pages, each with their own top menu. So this top menu should not be given by the site but by the current page. Meditating...
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : I think that the SubscribeToLedger action will disappear together with the ledgers plugin. But I'm not yet sure.
- 1 aasta, 2 kuud ago by Luc Saffre in reply to Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : In order to show multiple userspaces, I want both demo fixtures synodalworld and laundry. I imagine these two very different organizations sharing a same Lino site (noi2))
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) (1 reply) : I have a feeling that lino_cms and cms1 are going to disappear. We don't need them any more because we use have with_cms in Noi.
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : Cool: I have first successes locally. Todo: new user role "SpaceAdmin" for users who can change their own userspace and that of others. A ui element to switch to a different userspace.
- 1 aasta, 2 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : I started to write down my plan (in the description of this ticket).
- 1 aasta, 5 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) (1 reply) : When a new user registers online on a Lino site with multiple "ledgers" or "spaces", how are we going to know in which space this user is to be created?
- 1 aasta, 6 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : I re-read my blog entry once more, and the word "system" still seems weird. So I replaced the word "system" by "space" (right now only in my mind).
- 1 aasta, 6 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : The ledger plugin is already functional, but not used anywhere in production. I think that the as_ref_prefix() should get implemented differently: the Referrable plugin would say unique_together for ref and ledger when ledger is installed. Note that ledger is similar to the teams plugin: User.team i...
- 1 aasta, 8 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : Maybe the word "System" isn't optimal. Doesn't the sentence "We run a Lino site with multiple systems" sound a bit silly? Slack calls them "Workspaces".
- 1 aasta, 8 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : I wrote a [url luc.lino-framework.org/blog/2025/0202.html blog entry] to get rid of my ideas.
- 1 aasta, 8 kuud ago by Luc Saffre about #5904 (Multitenancy (multiple "user spaces, "ledgers" or "communities")) : Created new Ticket #5904 (Lino sites with multiple "systems").