Exemple #1
0
 def handle(self, *args, **options):
     all_tenants = options.pop('all_tenants')
     dispatch_uid = options.pop('dispatch_uid')
     databases = []
     
     database = options.pop('database')
     if database == '-':
         databases.extend(map(lambda i: i.strip(), sys.stdin.readlines()))
     elif all_tenants:
         databases.extend([tenant['name'] for tenant in Tenant.objects.values('name')])
     else:
         databases.append(database)
     
     random.shuffle(databases)
     for database in databases:
         if database not in settings.MULTITENANT_PUBLIC_DATABASES:
             connect_tenant_provider(dispatch_uid, database)
         
         opts = options.copy()
         opts.update({
             'database': database,
         })
         
         print 'Syncdb {database}...'.format(database=database)
         response = super(Command, self).handle(*args, **opts)
         connections[database].close()
         disconnect_tenant_provider(dispatch_uid)
 def handle(self, *args, **options):
     all_tenants = options.pop('all_tenants')
     dispatch_uid = options.pop('dispatch_uid')
     databases = []
     
     database = options.pop('database')
     if database == '-':
         databases.extend(map(lambda i: i.strip(), sys.stdin.readlines()))
     elif all_tenants:
         databases.extend([tenant['name'] for tenant in Tenant.objects.values('name')])
     else:
         databases.append(database)
     
     random.shuffle(databases)
     for database in databases:
         if database not in tenant_settings.MULTITENANT_PUBLIC_DATABASES:
             db.dbs[database] = self.get_south_wrapper(database, settings.DATABASES[database]['ENGINE'])
             connect_tenant_provider(self, database)
         
         opts = options.copy()
         opts.update({
             'database': database,
         })
         
         print 'Migrating {database}...'.format(database=database)
         response = super(Command, self).handle(*args, **opts)
         connections[database].close()
         disconnect_tenant_provider(self)
 def process_request(self, request):
     request.tenant = None
     
     name = self.identify_tenant(request)
     if name:
         tenant = get_object_or_404(Tenant, name=name)
         request.tenant = tenant
         connect_tenant_provider(request, tenant.ident)
     return None
Exemple #4
0
 def process_request(self, request):
     request.tenant = None
     
     name = self.identify_tenant(request)
     if name:
         tenant = get_object_or_404(Tenant, name=name)
         request.tenant = tenant
         connect_tenant_provider(request, tenant.ident)
     return None