Hello community,

here is the log from the commit of package python-django-picklefield for 
openSUSE:Factory checked in at 2012-12-19 11:53:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-picklefield (Old)
 and      /work/SRC/openSUSE:Factory/.python-django-picklefield.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-django-picklefield", Maintainer is ""

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-django-picklefield/python-django-picklefield.changes
      2012-05-08 06:48:00.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-django-picklefield.new/python-django-picklefield.changes
 2012-12-19 11:53:19.000000000 +0100
@@ -1,0 +2,6 @@
+Mon Dec 10 11:38:23 UTC 2012 - alexan...@exatati.com.br
+
+- Update to 0.3.0:
+   * Python 3 support (thanks to Rafal Stozek).
+
+-------------------------------------------------------------------

Old:
----
  django-picklefield-0.2.1.tar.bz2

New:
----
  django-picklefield-0.3.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-django-picklefield.spec ++++++
--- /var/tmp/diff_new_pack.470kUt/_old  2012-12-19 11:53:20.000000000 +0100
+++ /var/tmp/diff_new_pack.470kUt/_new  2012-12-19 11:53:20.000000000 +0100
@@ -20,7 +20,7 @@
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from 
distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
 
 Name:           python-django-picklefield
-Version:        0.2.1
+Version:        0.3.0
 Release:        0
 Url:            http://github.com/gintas/django-picklefield
 Summary:        Pickled object field for Django

++++++ django-picklefield-0.2.1.tar.bz2 -> django-picklefield-0.3.0.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-picklefield-0.2.1/PKG-INFO 
new/django-picklefield-0.3.0/PKG-INFO
--- old/django-picklefield-0.2.1/PKG-INFO       2012-04-23 02:03:42.000000000 
+0200
+++ new/django-picklefield-0.3.0/PKG-INFO       2012-12-09 10:25:43.000000000 
+0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: django-picklefield
-Version: 0.2.1
+Version: 0.3.0
 Summary: Pickled object field for Django
 Home-page: http://github.com/gintas/django-picklefield
 Author: Gintautas Miliauskas
@@ -122,10 +122,10 @@
         Changes
         -------
         
-        Changes in version 0.2.1
+        Changes in version 0.3.0
         ========================
         
-         * Use __slots__ to optimize _ObjectWrapper (thanks to Simon Charette)
+         * Python 3 support (thanks to Rafal Stozek).
         
         Changes in version 0.2.0
         ========================
@@ -200,6 +200,13 @@
         Send feedback and suggestions to gintau...@miliauskas.lt .
         
 Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
+Classifier: Development Status :: 5 - Production/Stable
 Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-picklefield-0.2.1/README 
new/django-picklefield-0.3.0/README
--- old/django-picklefield-0.2.1/README 2012-04-23 02:03:17.000000000 +0200
+++ new/django-picklefield-0.3.0/README 2012-12-09 10:17:14.000000000 +0100
@@ -114,10 +114,10 @@
 Changes
 -------
 
-Changes in version 0.2.1
+Changes in version 0.3.0
 ========================
 
- * Use __slots__ to optimize _ObjectWrapper (thanks to Simon Charette)
+ * Python 3 support (thanks to Rafal Stozek).
 
 Changes in version 0.2.0
 ========================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-picklefield-0.2.1/setup.py 
new/django-picklefield-0.3.0/setup.py
--- old/django-picklefield-0.2.1/setup.py       2012-04-23 02:01:49.000000000 
+0200
+++ new/django-picklefield-0.3.0/setup.py       2012-12-09 10:18:21.000000000 
+0100
@@ -19,21 +19,35 @@
 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
-
+import codecs
 from setuptools import setup, find_packages
 
+
+DESC=codecs.open('README', encoding='utf-8').read()
+
+
 setup(name='django-picklefield',
-    version='0.2.1',
+    version='0.3.0',
     description='Pickled object field for Django',
-    long_description=open('README').read(),
+    long_description=DESC,
     author='Gintautas Miliauskas',
     author_email='gintau...@miliauskas.lt',
     url='http://github.com/gintas/django-picklefield',
     packages=find_packages('src'),
     package_dir={'' : 'src'},
+    install_requires=[
+        'six',
+    ],
     classifiers=[
-        'Development Status :: 4 - Beta',
+        'Development Status :: 5 - Production/Stable',
         'Framework :: Django',
+        'Intended Audience :: Developers',
         'License :: OSI Approved :: MIT License',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 2.5',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
     ]
 )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/django-picklefield-0.2.1/src/django_picklefield.egg-info/PKG-INFO 
new/django-picklefield-0.3.0/src/django_picklefield.egg-info/PKG-INFO
--- old/django-picklefield-0.2.1/src/django_picklefield.egg-info/PKG-INFO       
2012-04-23 02:03:42.000000000 +0200
+++ new/django-picklefield-0.3.0/src/django_picklefield.egg-info/PKG-INFO       
2012-12-09 10:25:43.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: django-picklefield
-Version: 0.2.1
+Version: 0.3.0
 Summary: Pickled object field for Django
 Home-page: http://github.com/gintas/django-picklefield
 Author: Gintautas Miliauskas
@@ -122,10 +122,10 @@
         Changes
         -------
         
-        Changes in version 0.2.1
+        Changes in version 0.3.0
         ========================
         
-         * Use __slots__ to optimize _ObjectWrapper (thanks to Simon Charette)
+         * Python 3 support (thanks to Rafal Stozek).
         
         Changes in version 0.2.0
         ========================
@@ -200,6 +200,13 @@
         Send feedback and suggestions to gintau...@miliauskas.lt .
         
 Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
+Classifier: Development Status :: 5 - Production/Stable
 Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/django-picklefield-0.2.1/src/django_picklefield.egg-info/SOURCES.txt 
new/django-picklefield-0.3.0/src/django_picklefield.egg-info/SOURCES.txt
--- old/django-picklefield-0.2.1/src/django_picklefield.egg-info/SOURCES.txt    
2012-04-23 02:03:42.000000000 +0200
+++ new/django-picklefield-0.3.0/src/django_picklefield.egg-info/SOURCES.txt    
2012-12-09 10:25:43.000000000 +0100
@@ -3,8 +3,10 @@
 src/django_picklefield.egg-info/PKG-INFO
 src/django_picklefield.egg-info/SOURCES.txt
 src/django_picklefield.egg-info/dependency_links.txt
+src/django_picklefield.egg-info/requires.txt
 src/django_picklefield.egg-info/top_level.txt
 src/picklefield/__init__.py
+src/picklefield/compat.py
 src/picklefield/fields.py
 src/picklefield/models.py
 src/picklefield/tests.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/django-picklefield-0.2.1/src/django_picklefield.egg-info/requires.txt 
new/django-picklefield-0.3.0/src/django_picklefield.egg-info/requires.txt
--- old/django-picklefield-0.2.1/src/django_picklefield.egg-info/requires.txt   
1970-01-01 01:00:00.000000000 +0100
+++ new/django-picklefield-0.3.0/src/django_picklefield.egg-info/requires.txt   
2012-12-09 10:25:43.000000000 +0100
@@ -0,0 +1 @@
+six
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-picklefield-0.2.1/src/picklefield/compat.py 
new/django-picklefield-0.3.0/src/picklefield/compat.py
--- old/django-picklefield-0.2.1/src/picklefield/compat.py      1970-01-01 
01:00:00.000000000 +0100
+++ new/django-picklefield-0.3.0/src/picklefield/compat.py      2012-12-09 
10:12:06.000000000 +0100
@@ -0,0 +1,15 @@
+# django 1.5 introduces force_text instead of force_unicode
+try:
+    from django.utils.encoding import force_text
+except ImportError:
+    from django.utils.encoding import force_unicode as force_text
+
+# python 3.x does not have cPickle module
+try:
+    from cPickle import loads, dumps # cpython 2.x
+except ImportError:
+    from pickle import loads, dumps # cpython 3.x, other interpreters
+try:
+    from django.utils import simplejson as json
+except ImportError:
+    import json
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-picklefield-0.2.1/src/picklefield/fields.py 
new/django-picklefield-0.3.0/src/picklefield/fields.py
--- old/django-picklefield-0.2.1/src/picklefield/fields.py      2012-04-23 
01:51:58.000000000 +0200
+++ new/django-picklefield-0.3.0/src/picklefield/fields.py      2012-12-09 
10:12:06.000000000 +0100
@@ -1,17 +1,14 @@
 """Pickle field implementation for Django."""
-
 from copy import deepcopy
 from base64 import b64encode, b64decode
 from zlib import compress, decompress
-try:
-    from cPickle import loads, dumps
-except ImportError:
-    from pickle import loads, dumps
-
+import six
+import django
 from django.db import models
-from django.utils.encoding import force_unicode
 
 from picklefield import DEFAULT_PROTOCOL
+from picklefield.compat import force_text, loads, dumps
+
 
 class PickledObject(str):
     """
@@ -24,9 +21,9 @@
     remove PickledObject and its references, you won't be able to pass
     in pre-encoded values anymore, but you can always just pass in the
     python objects themselves.
-
     """
 
+
 class _ObjectWrapper(object):
     """
     A class used to wrap object that have properties that may clash with the 
@@ -41,11 +38,13 @@
     def __init__(self, obj):
         self._obj = obj
 
+
 def wrap_conflictual_object(obj):
     if hasattr(obj, 'prepare_database_save') or callable(obj):
         obj = _ObjectWrapper(obj)
     return obj
 
+
 def dbsafe_encode(value, compress_object=False, 
pickle_protocol=DEFAULT_PROTOCOL):
     # We use deepcopy() here to avoid a problem with cPickle, where dumps
     # can generate different character streams for same lookup value if
@@ -53,22 +52,31 @@
     # The reason this is important is because we do all of our lookups as
     # simple string matches, thus the character streams must be the same
     # for the lookups to work properly. See tests.py for more information.
-    if not compress_object:
-        value = b64encode(dumps(deepcopy(value), pickle_protocol))
-    else:
-        value = b64encode(compress(dumps(deepcopy(value), pickle_protocol)))
+    value = dumps(deepcopy(value), protocol=pickle_protocol)
+    if compress_object:
+        value = compress(value)
+    value = b64encode(value).decode() # decode bytes to str
     return PickledObject(value)
 
 
 def dbsafe_decode(value, compress_object=False):
-    if not compress_object:
-        value = loads(b64decode(value))
-    else:
-        value = loads(decompress(b64decode(value)))
-    return value
+    value = value.encode() # encode str to bytes
+    value = b64decode(value)
+    if compress_object:
+        value = decompress(value)
+    return loads(value)
+
+
+def _get_subfield_superclass():
+    # hardcore trick to support django < 1.3 - there was something wrong with
+    # inheritance and SubfieldBase before django 1.3
+    # see 
https://github.com/django/django/commit/222c73261650201f5ce99e8dd4b1ce0d30a69eb4
+    if django.VERSION < (1,3):
+        return models.Field
+    return six.with_metaclass(models.SubfieldBase, models.Field)
 
 
-class PickledObjectField(models.Field):
+class PickledObjectField(_get_subfield_superclass()):
     """
     A field that will accept *any* python object and store it in the
     database. PickledObjectField will optionally compress its values if
@@ -78,8 +86,7 @@
     can still do lookups using None). This way, it is still possible to
     use the ``isnull`` lookup type correctly.
     """
-
-    __metaclass__ = models.SubfieldBase
+    __metaclass__ = models.SubfieldBase  # for django < 1.3
 
     def __init__(self, *args, **kwargs):
         self.compress = kwargs.pop('compress', False)
@@ -111,7 +118,7 @@
         B64decode and unpickle the object, optionally decompressing it.
 
         If an error is raised in de-pickling and we're sure the value is
-        a definite pickle, the error is allowed to propogate. If we
+        a definite pickle, the error is allowed to propagate. If we
         aren't sure if the value is a pickle or not, then we catch the
         error and return the original value instead.
 
@@ -145,13 +152,13 @@
 
         """
         if value is not None and not isinstance(value, PickledObject):
-            # We call force_unicode here explicitly, so that the encoded string
+            # We call force_text here explicitly, so that the encoded string
             # isn't rejected by the postgresql_psycopg2 backend. Alternatively,
             # we could have just registered PickledObject with the psycopg
             # marshaller (telling it to store it like it would a string), but
             # since both of these methods result in the same value being 
stored,
             # doing things this way is much easier.
-            value = force_unicode(dbsafe_encode(value, self.compress, 
self.protocol))
+            value = force_text(dbsafe_encode(value, self.compress, 
self.protocol))
         return value
 
     def value_to_string(self, obj):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-picklefield-0.2.1/src/picklefield/tests.py 
new/django-picklefield-0.3.0/src/picklefield/tests.py
--- old/django-picklefield-0.2.1/src/picklefield/tests.py       2012-02-18 
01:26:02.000000000 +0100
+++ new/django-picklefield-0.3.0/src/picklefield/tests.py       2012-12-09 
10:12:06.000000000 +0100
@@ -3,46 +3,54 @@
 from django.test import TestCase
 from django.db import models
 from django.core import serializers
-from picklefield.fields import PickledObjectField, wrap_conflictual_object
+from picklefield.compat import json
+from picklefield.fields import (PickledObjectField, wrap_conflictual_object,
+                                dbsafe_encode)
+
+
+S1 = 'Hello World'
+T1 = (1, 2, 3, 4, 5)
+L1 = [1, 2, 3, 4, 5]
+D1 = {1: 1, 2: 4, 3: 6, 4: 8, 5: 10}
+D2 = {1: 2, 2: 4, 3: 6, 4: 8, 5: 10}
+
 
 class TestingModel(models.Model):
     pickle_field = PickledObjectField()
     compressed_pickle_field = PickledObjectField(compress=True)
-    default_pickle_field = PickledObjectField(default=({1: 1, 2: 4, 3: 6, 4: 
8, 5: 10}, 'Hello World', (1, 2, 3, 4, 5), [1, 2, 3, 4, 5]))
+    default_pickle_field = PickledObjectField(default=(D1, S1, T1, L1))
+
 
 class MinimalTestingModel(models.Model):
     pickle_field = PickledObjectField()
 
+
 class TestCustomDataType(str):
     pass
 
+
 class PickledObjectFieldTests(TestCase):
     def setUp(self):
-        self.testing_data = (
-            {1:2, 2:4, 3:6, 4:8, 5:10},
-            'Hello World',
-            (1, 2, 3, 4, 5),
-            [1, 2, 3, 4, 5],
-            TestCustomDataType('Hello World'),
-            MinimalTestingModel,
-        )
+        self.testing_data = (D2, S1, T1, L1,
+                             TestCustomDataType(S1),
+                             MinimalTestingModel)
         return super(PickledObjectFieldTests, self).setUp()
 
-    def testDataIntegriry(self):
+    def testDataIntegrity(self):
         """
         Tests that data remains the same when saved to and fetched from
         the database, whether compression is enabled or not.
-
         """
         for value in self.testing_data:
-            model_test = TestingModel(pickle_field=value, 
compressed_pickle_field=value)
+            model_test = TestingModel(pickle_field=value,
+                compressed_pickle_field=value)
             model_test.save()
             model_test = TestingModel.objects.get(id__exact=model_test.id)
             # Make sure that both the compressed and uncompressed fields return
             # the same data, even thought it's stored differently in the DB.
             self.assertEquals(value, model_test.pickle_field)
             self.assertEquals(value, model_test.compressed_pickle_field)
-            # Make sure we can also retreive the model
+            # Make sure we can also retrieve the model
             model_test.save()
             model_test.delete()
 
@@ -51,7 +59,8 @@
         model_test = TestingModel()
         model_test.save()
         model_test = TestingModel.objects.get(id__exact=model_test.id)
-        self.assertEquals(({1: 1, 2: 4, 3: 6, 4: 8, 5: 10}, 'Hello World', (1, 
2, 3, 4, 5), [1, 2, 3, 4, 5]), model_test.default_pickle_field)
+        self.assertEquals((D1, S1, T1, L1),
+            model_test.default_pickle_field)
 
     def testLookups(self):
         """
@@ -130,7 +139,7 @@
 
         # Make sure that lookups of the same value work, even when referenced
         # differently. See the above docstring for more info on the issue.
-        value = ({1: 1, 2: 4, 3: 6, 4: 8, 5: 10}, 'Hello World', (1, 2, 3, 4, 
5), [1, 2, 3, 4, 5])
+        value = (D1, S1, T1, L1)
         model_test = TestingModel(pickle_field=value, 
compressed_pickle_field=value)
         model_test.save()
         # Test lookup using an assigned variable.
@@ -138,19 +147,25 @@
         self.assertEquals(value, model_test.pickle_field)
         # Test lookup using direct input of a matching value.
         model_test = TestingModel.objects.get(
-            pickle_field__exact = ({1: 1, 2: 4, 3: 6, 4: 8, 5: 10}, 'Hello 
World', (1, 2, 3, 4, 5), [1, 2, 3, 4, 5]),
-            compressed_pickle_field__exact = ({1: 1, 2: 4, 3: 6, 4: 8, 5: 10}, 
'Hello World', (1, 2, 3, 4, 5), [1, 2, 3, 4, 5]),
+            pickle_field__exact = (D1, S1, T1, L1),
+            compressed_pickle_field__exact = (D1, S1, T1, L1),
         )
         self.assertEquals(value, model_test.pickle_field)
         model_test.delete()
 
     def testSerialization(self):
-        model_test = MinimalTestingModel(pickle_field={'foo': 'bar'})
-        json_test = serializers.serialize('json', [model_test])
-        self.assertEquals(json_test,
-                          '[{"pk": null,'
-                          ' "model": "picklefield.minimaltestingmodel",'
-                          ' "fields": {"pickle_field": 
"gAJ9cQFVA2Zvb3ECVQNiYXJxA3Mu"}}]')
-        for deserialized_test in serializers.deserialize('json', json_test):
+        model = MinimalTestingModel(pickle_field={'foo': 'bar'})
+        serialized = serializers.serialize('json', [model])
+        data = json.loads(serialized)
+
+        # determine output at runtime, because pickle output in python 3
+        # is different (but compatible with python 2)
+        p = dbsafe_encode({'foo': 'bar'})
+
+        self.assertEquals(data,
+            [{'pk': None, 'model': 'picklefield.minimaltestingmodel',
+              'fields': {"pickle_field": p}}])
+
+        for deserialized_test in serializers.deserialize('json', serialized):
             self.assertEquals(deserialized_test.object,
-                              model_test)
+                              model)

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to