mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-01 07:18:12 +08:00
By reverting django.core.signing to Django 1.11.8 version Django-Q works This is not designed as a 'good' solution just to show where I think the problem is.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""Package signing."""
|
|
try:
|
|
import cPickle as pickle
|
|
except ImportError:
|
|
import pickle
|
|
|
|
from django_q import core_signing as signing
|
|
|
|
from django_q.conf import Conf
|
|
|
|
BadSignature = signing.BadSignature
|
|
|
|
|
|
class SignedPackage(object):
|
|
|
|
"""Wraps Django's signing module with custom Pickle serializer."""
|
|
|
|
@staticmethod
|
|
def dumps(obj, compressed=Conf.COMPRESSED):
|
|
return signing.dumps(obj,
|
|
key=Conf.SECRET_KEY,
|
|
salt=Conf.PREFIX,
|
|
compress=compressed,
|
|
serializer=PickleSerializer)
|
|
|
|
@staticmethod
|
|
def loads(obj):
|
|
return signing.loads(obj,
|
|
key=Conf.SECRET_KEY,
|
|
salt=Conf.PREFIX,
|
|
serializer=PickleSerializer)
|
|
|
|
|
|
class PickleSerializer(object):
|
|
|
|
"""Simple wrapper around Pickle for signing.dumps and signing.loads."""
|
|
|
|
@staticmethod
|
|
def dumps(obj):
|
|
return pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL)
|
|
|
|
@staticmethod
|
|
def loads(data):
|
|
return pickle.loads(data)
|