provisionning: pass data to spooler function in body parameter (#56991)
The `data` can be very long, by spooler files cannot be longer thant 64k except for the body bytes parameter. See https://uwsgi-docs.readthedocs.io/en/latest/Spooler.html#spool-files Using the body parameters is only possible with pass_arguments=False (not documented).
This commit is contained in:
parent
ded8905ebc
commit
d84fd70def
|
@ -21,7 +21,7 @@ from django.conf import settings
|
|||
from django.db import connection
|
||||
from django.http import HttpResponseBadRequest, HttpResponseForbidden, JsonResponse
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
from hobo.provisionning.utils import NotificationProcessing, TryAgain
|
||||
|
@ -58,14 +58,20 @@ class ProvisionningMiddleware(MiddlewareMixin, NotificationProcessing):
|
|||
from hobo.provisionning.spooler import provision
|
||||
|
||||
tenant = getattr(connection, 'tenant', None)
|
||||
domain = getattr(tenant, 'domain_url', None)
|
||||
domain = getattr(tenant, 'domain_url', '')
|
||||
object_type = object_type or ''
|
||||
domain = domain or ''
|
||||
issuer = issuer or ''
|
||||
action = action or ''
|
||||
full = 'true' if full else 'false'
|
||||
body = json.dumps(data)
|
||||
provision.spool(
|
||||
object_type=object_type,
|
||||
domain=domain,
|
||||
issuer=issuer,
|
||||
action=action,
|
||||
data=data,
|
||||
full=full,
|
||||
object_type=force_bytes(object_type),
|
||||
domain=force_bytes(domain),
|
||||
issuer=force_bytes(issuer),
|
||||
action=force_bytes(action),
|
||||
body=force_bytes(body),
|
||||
full=force_bytes(full),
|
||||
)
|
||||
else:
|
||||
self.provision(object_type=object_type, issuer=issuer, action=action, data=data, full=full)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from django.db import connection
|
||||
|
@ -14,16 +15,16 @@ def set_connection(domain):
|
|||
connection.set_tenant(tenant)
|
||||
|
||||
|
||||
@spool(pass_arguments=True)
|
||||
def provision(*args, **kwargs):
|
||||
@spool
|
||||
def provision(args):
|
||||
try:
|
||||
set_connection(kwargs['domain'])
|
||||
set_connection(args['domain'])
|
||||
NotificationProcessing.provision(
|
||||
object_type=kwargs['object_type'],
|
||||
issuer=kwargs['issuer'],
|
||||
action=kwargs['action'],
|
||||
data=kwargs['data'],
|
||||
full=kwargs['full'],
|
||||
object_type=args['object_type'],
|
||||
issuer=args['issuer'],
|
||||
action=args['action'],
|
||||
data=json.loads(args['body']),
|
||||
full=True if args['full'] == 'true' else False,
|
||||
)
|
||||
except Exception:
|
||||
# we need to catch every exceptions otherwise the task will be re scheduled for ever and ever
|
||||
|
|
Loading…
Reference in New Issue