Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
a few DRUNK BONERS
Mar 25, 2016

Does anyone have any ideas / examples of how to design a project with different databases for different users? The idea is you would log in with username / password / group code and then be in a different database based on the group code (with no shared auth, each database has its own auth table). Database routers have no access to requests. There's some bullshit online about using thread local variables which seems dumb and fragile. Possibly this isn't something that Django can handle with a basic single server setup but maybe there's something I'm missing.

Adbot
ADBOT LOVES YOU

a few DRUNK BONERS
Mar 25, 2016

skull mask mcgee posted:

Is this the thread local variable solution you’re referring to? Because it doesn’t look terribly unreasonable for the constraints you laid out.

I don’t think there’s really gonna be a “clean” solution to this problem because the level of segregation you’re talking about is usually achieved by having a separate instance of the application for each database, which might be worth exploring even if you are constrained to a single server.

Basically I don't trust doing that kind of thing with threads when you're deployed on some cloud VM. I think you're right that there should be separate instances.

a few DRUNK BONERS
Mar 25, 2016

`self.fieldsets` is a class attribute (not an instance attribute) and modifying it is not thread safe. I think what you want is to override get_fieldsets instead.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply