bcarneiro/django-tenant-schemas — pull request #67 by pnw (2013-09-15 02:11:20+00:00)
Title: Added ability to use context managers if no tenant is set on connection.

If no tenant is set on the connection (e.g. after calling connection.set_schema_to_public()), then the schema_context and the tenant_context would raise an exception on exit. previous_tenant would be `None` in the finally blocks, and connection.set_tenant(None) would raise an AttributeError. The context managers no longer assume that a tenant is not None prior to entering the context.