Commit Graph

61 Commits

Author SHA1 Message Date
Christophe Siraut e1b1afb2cf set application_name to tenant name (#7849) 2020-07-17 16:32:54 +02:00
Benjamin Dauvergne c5d54b917e postgresql_backend: fix typo in contenttypes cache access and clear base Content.objects._cache (#32248) 2019-04-15 14:00:10 +02:00
Benjamin Dauvergne 22d7ace8c0 postgresql_backend: cache ContentType based on the manager object and model classes (#32248)
model classes and manager object are duplicated during migrations.
2019-04-12 17:13:46 +02:00
Benjamin Dauvergne 631743c45e override ContentType.__init__ to use a thread local cache (fixes #26206) 2019-04-10 19:13:03 +02:00
Frédéric Péters b3914c84cf fix custom content type cache __get__ method (#10308) 2018-08-12 21:31:13 +02:00
Benjamin Dauvergne eb0a27e712 Replace the cache dictionnary by a thread local variable (~ #9891)
This makes it safe to use multitenancy with threads.
2018-08-12 21:31:13 +02:00
viatrak 7e104037c9 Content type cache should be cleared not just at the beginning of a request, but *anytime* the schema is changed (which happens in middle of requests). set_tenant() will also now result in a set_schema() call so it will claer_cache() at the beginning of a request, and on subsequent set_schema calls 2017-09-07 12:43:40 -05:00
viatrak 86c4050856 Redundant code in set_tenant as set_schema(). Make it DRY 2017-09-07 12:41:12 -05:00
viatrak 953040943d Redundant code to set_schema(). Make it DRY 2017-09-07 12:34:11 -05:00
Adnan Umer 24fd09d007 Merge branch 'master' into master 2017-05-26 15:19:05 +05:00
Mateu Cànaves 73fdfdff8e Resolved conflicts 2017-04-18 12:19:40 +02:00
Stéphane Raimbault 36e1ba3800 Django 1.11 support (#463)
* Added Django 1.11 to Travis

- related to #435
- 😉 to tomturner/django-tenants#120

* Replace direct use of import_module by proper load_backend

Handle new 'django.db.backends.postgresql' name (Django 1.9)

* Fix 'default' already present in _fields in Django 1.11

* Fix not existing access to original_backend.DatabaseError (Django 1.11)

Removed exports because django.db.utils.DatabaseError and
django.db.utils.IntegrityError must be used instead.

This change must be stated in release notes.

* The signature of DatabaseWrapper._cursor has changed in Django 1.11

Use the public API

* Add missing allowed hosts for tests

* Don't override default user or blocks Unix socket DB connection

* Updated tox.ini for Django 1.11rc1

* Properly add '.test.com' to ALLOWED_HOSTS in test cases

* Internal tests don't use TenantTestCase so set allowed hosts manually

* Drop Django 1.9 support

Django 1.8 is still within LTS until the end of 2017.
2017-04-17 15:03:59 +05:00
Stéphane Raimbault 1cb00dc6db Django 1.11 support (#463)
* Added Django 1.11 to Travis

- related to #435
- 😉 to tomturner/django-tenants#120

* Replace direct use of import_module by proper load_backend

Handle new 'django.db.backends.postgresql' name (Django 1.9)

* Fix 'default' already present in _fields in Django 1.11

* Fix not existing access to original_backend.DatabaseError (Django 1.11)

Removed exports because django.db.utils.DatabaseError and
django.db.utils.IntegrityError must be used instead.

This change must be stated in release notes.

* The signature of DatabaseWrapper._cursor has changed in Django 1.11

Use the public API

* Add missing allowed hosts for tests

* Don't override default user or blocks Unix socket DB connection

* Updated tox.ini for Django 1.11rc1

* Properly add '.test.com' to ALLOWED_HOSTS in test cases

* Internal tests don't use TenantTestCase so set allowed hosts manually

* Drop Django 1.9 support

Django 1.8 is still within LTS until the end of 2017.
2017-04-12 15:06:19 +10:00
Bernardo Pires 3b0ec772dc Fixed test cases for Django 1.9 2015-12-28 17:13:13 +01:00
Brian Lao 94d325bcf4 must set search_path again after a transaction rollback 2015-12-17 15:16:19 -05:00
Bernardo Pires 88651600b1 Fixed migrations when limiting set search_path calls. Thanks @bjersey, @philfriesen, @bjs987. Fixes #253. 2015-07-30 13:12:02 +02:00
Bernardo Pires ce73fa9795 Added support for PostGIS. Thanks @tecnosegugio, @george-silva. Fixes #240. 2015-07-30 13:06:37 +02:00
Bernardo Pires 3fd5332c8f Fixed deprecated warning on importlib. 2015-07-30 11:19:08 +02:00
Bernardo Pires c16a2d7d79 Patched DatabaseIntrospection to only returns the list of tables in the currently selected schemas. Fixes Django 1.7 not being able to have the same app under TENANT_APPS and SHARED_APPS. 2015-01-05 15:13:09 +01:00
David Burke d1eb9dd30d Fix #191 need to check for psycopg2.InternalError too
This fix corrects the problem when used with django-simple-import
https://github.com/burke-software/django-simple-import/issues/37
2014-11-19 13:04:11 -05:00
Jérôme Schneider 6501ad56f4 postgresql_backend: catch exception from django.db.utils and not from the backend
really fix #191
2014-11-18 22:59:11 +01:00
Benjamin Dauvergne 8da5075ef7 Hide database errors when setting the search path
It's needed to allow ROLLBACK to be executed on the DB. It resolves
issue #191.
2014-10-04 09:10:42 +02:00
Bernardo Pires b11ccf1295 Merge pull request #175 from rev112/schema_name_validation
Added validator for TenantMixin.schema_name, check for 'pg_' prefix
2014-09-09 11:35:12 +02:00
Anton Ovchinnikov 7e7f19a8f7 Fix minor Py3 issues 2014-09-02 15:23:00 +02:00
Anton Ovchinnikov 49705b2cff Add validator for TenantMixin.schema_name, check for 'pg_' prefix 2014-08-27 11:37:47 +02:00
Anton Ovchinnikov f740df449d PEP8 and typos 2014-08-21 10:33:24 +02:00
balcorn f8974b2206 Rename TENANT_PARANOID
* Rename to TENANT_LIMIT_SET_CALLS and get_limit_set_calls(), per
  pull request feedback.
2014-07-30 14:23:05 -04:00
balcorn 3236e7badc doc typo 2014-07-25 00:30:03 -04:00
balcorn 347b34ce5e Make "fast and loose" behavior opt-in
* Add support for a `settings.TENANT_SCHEMAS_PARANOID` variable;
  if false, limit calls to `set search_path`
2014-07-25 00:26:01 -04:00
balcorn 8dde29cbe0 Revert to setting search_path in _cursor()
Ensure called only once, via an instance variable to track.
2014-07-24 23:52:35 -04:00
balcorn 9e8ada6352 Speed enhancement for set search_path()
* Refactor out of _cursor() to perform `set search_path()` once during a request cycle.
2014-07-23 16:12:14 -04:00
Kevin Lynch 6fa3502968 Fixes #142 Use old style indexing in format strings
Unable to set search_path with Python 2.6 due to unindexed format string.
2014-06-03 16:51:39 -04:00
Chris Franklin fe672b1b90 Fix #41 - set settings_dict['SCHEMA'] for south.
This is required by SOUTH to perform migrations correctly.
2014-04-27 10:15:18 +01:00
Bernardo Pires 17e7c79047 cleaning up code and fixed #65, fixed #115, fixed #121 2014-03-21 14:36:34 +01:00
Owais Lone 25d8779561 Fixed #113: Added a setting variable that lets devs add extra paths to postgresql's search_path.
This way developers can install postgresql extensions in a dedicated schema and make it available globally.
Extensions can be installed to `public` schema too but the `public` is not always added to search_path, for example when running database migrations on --tenant apps.
2014-02-20 18:20:54 +05:30
Bernardo Pires 9d5a9e6782 fixed get_schema_name not being called get_schema 2013-11-15 09:09:09 +01:00
Bernardo Pires 98f7067f41 readded backwards compatibility (get_schema_name and get_tenant) 2013-11-15 09:01:17 +01:00
Walkman 9664056bce Removed unneccesary PGThread.
Django connections are thread locals by default, it's safe to attach
attributes to the DatabaseWrapper, because those are thread safe.
Removed connection.get_schema() and connection.get_tenant() methods,
those were not very pythonic at all. Use connection.schema_name and
connection.tenant properties instead.
2013-11-15 00:50:05 +01:00
Stephen J. Fuhry 99a71c5db8 remove redundant re-raising of swallowed exception 2013-10-14 15:14:58 -04:00
Walkman 25bcf3b668 Fixed import from previous commit 2013-09-17 07:15:28 +02:00
Caio Ariede c1ca1f24d7 Sets SCHEMA, since South relies on it for database migrations. 2013-06-05 11:48:02 -03:00
Bernardo Pires d80a1444ec code should now be pep8 compliant 2013-06-03 22:00:44 +02:00
Bernardo Pires eee7ff9615 removing 'print' method 2012-12-14 21:20:00 +01:00
Bernardo Pires 77c7ffc19f schema_context and tenant_context now re-sets the tenant properly 2012-12-14 21:19:14 +01:00
Caio Ariede 3fc83719d2 Move 'public' to PUBLIC_SCHEMA_NAME setting 2012-11-19 11:31:37 -02:00
Bernardo Pires 6013d36839 updated docs. connections now always include the public schema, except when syncding the db. 2012-11-18 19:58:11 +01:00
Bernardo Pires 40da3d53ba added public schema to search path 2012-10-20 10:19:26 +02:00
Bernardo Pires a3f95341be making the tenant always available when creating commands inheriting BaseTenantCommand. Access via connection.get_tenant() 2012-08-08 12:11:00 +02:00
Bernardo Pires db5844bf2d no longer entering transaction management from the database backend. updated tests to conform with the new public schema token 2012-08-07 18:32:48 +02:00
Tay Ray Chuan 2d86d440fc postgresql_backend: avoid a circular import
This module was failing to be imported. django.db.connection was
importing it, and the module in turn was importing django.db.connection.
Fix this by delaying this import till it's actually needed.
2012-07-22 14:12:28 +08:00