--- /dev/null
+.. change::
+ :tags: usecase, type
+ :tickets: 6646
+
+ Add a impl parameter to :class:`.PickleType` constructor, so the user
+ can customize the default implementation to avoid the issue that the
+ default LargeBinary impl might not be big enough to store the binary
+ object.
\ No newline at end of file
cache_ok = True
def __init__(
- self, protocol=pickle.HIGHEST_PROTOCOL, pickler=None, comparator=None
+ self,
+ protocol=pickle.HIGHEST_PROTOCOL,
+ pickler=None,
+ comparator=None,
+ impl=None,
):
"""
Construct a PickleType.
to compare values of this type. If left as ``None``,
the Python "equals" operator is used to compare values.
+ :param impl: Any implementation class that support storing
+ binary object. (e.g. :class: `.mysql.LONGBLOB`).
+ If let as ``None``, the impl would use class's default impl
+ `:class:`.LargeBinary`
+
"""
self.protocol = protocol
self.pickler = pickler or pickle
self.comparator = comparator
super(PickleType, self).__init__()
+ if impl:
+ self.impl = to_instance(impl)
+
def __reduce__(self):
return PickleType, (self.protocol, None, self.comparator)
):
assert p1.compare_values(p1.copy_value(obj), obj)
+ def test_customized_impl(self):
+ p1 = PickleType(impl=mysql.LONGBLOB)
+
+ assert isinstance(p1.impl, mysql.LONGBLOB)
+
class CallableTest(fixtures.TestBase):
@testing.provide_metadata