Projet

Général

Profil

0003-prevent-hobo-cook-from-changing-the-current-tenant-t.patch

Benjamin Dauvergne, 22 mai 2018 09:00

Télécharger (1,41 ko)

Voir les différences:

Subject: [PATCH 3/5] prevent hobo-cook from changing the current tenant (to be
 rebased)

 hobo/contrib/ozwillo/models.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
hobo/contrib/ozwillo/models.py
27 27
from django.db.transaction import atomic
28 28
from django.utils.text import slugify
29 29
from django.core.management import call_command
30
from django.db import connection
31

  
32
from tenant_schemas.utils import tenant_context
30 33

  
31 34

  
32 35
class OzwilloInstance(models.Model):
......
127 130
        with tempfile.NamedTemporaryFile() as recipe_file:
128 131
            json.dump(template_recipe, recipe_file)
129 132
            recipe_file.flush()
130
            call_command('cook', recipe_file.name, timeout=1000, verbosity=0)
133

  
134
            # cook play with the tenant context, we must protect from that
135
            with tenant_context(connection.tenant):
136
                call_command('cook', recipe_file.name, timeout=1000, verbosity=0)
131 137

  
132 138
        # Load user portal template
133 139
        logger.info(u'ozwillo: loading combo template')
134
-