rpms/python-turbojson/EL-5 python-turbojson-SAfix-r3749.patch, NONE, 1.1 python-turbojson.spec, 1.3, 1.4

Toshio くらとみ (toshio) fedora-extras-commits at redhat.com
Sat Feb 2 18:01:48 UTC 2008


Author: toshio

Update of /cvs/pkgs/rpms/python-turbojson/EL-5
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32633

Modified Files:
	python-turbojson.spec 
Added Files:
	python-turbojson-SAfix-r3749.patch 
Log Message:
- Backport fix for 1.1.2's SQLAlchemy breakage.


python-turbojson-SAfix-r3749.patch:

--- NEW FILE python-turbojson-SAfix-r3749.patch ---
Index: turbojson/jsonify.py
===================================================================
--- turbojson/jsonify.py.orig
+++ turbojson/jsonify.py
@@ -75,7 +75,7 @@ try:
             result[name] = getattr(obj, name)
         return result
     jsonify_sqlobject = jsonify.when(
-            'isinstance(obj, sqlobject.SQLObject)')(jsonify_sqlobject)
+            'isinstance(obj, sqlobject.SQLObject) and not hasattr(obj, "__json__")')(jsonify_sqlobject)
 
     def jsonify_select_results(obj):
         return list(obj)
@@ -95,7 +95,7 @@ try:
            props[key] = getattr(obj, key)
        return props
     jsonify_saobject = jsonify.when(
-            "hasattr(obj, 'c') and isinstance(obj.c,sqlalchemy.util.OrderedProperties)")(jsonify_saobject)
+            "hasattr(obj, 'c') and isinstance(obj.c,sqlalchemy.util.OrderedProperties) and not hasattr(obj, '__json__')")(jsonify_saobject)
 
 except ImportError:
     pass
Index: turbojson/tests/test_jsonify.py
===================================================================
--- turbojson/tests/test_jsonify.py.orig
+++ turbojson/tests/test_jsonify.py
@@ -37,6 +37,7 @@ def test_so():
     except ImportError:
         return
     so.sqlhub.processConnection = so.connectionForURI('sqlite:/:memory:')
+
     class Person(so.SQLObject):
         fname = so.StringCol()
         mi = so.StringCol(length=1, default=None)
@@ -44,20 +45,40 @@ def test_so():
     Person.createTable()
     p = Person(fname="Peter", mi="P", lname="Pasulke")
     pj = jsonify.jsonify(p)
+    print pj
     assert pj == {'fname' : "Peter", 'mi' : "P", 'lname' : "Pasulke", 'id' : 1}
+
+    class ExplicitPerson(so.SQLObject):
+        fname = so.StringCol()
+        def __json__(self):
+            return {'customized': True}
+    ExplicitPerson.createTable()
+    ep = ExplicitPerson(fname="Peter")
+    epj = jsonify.jsonify(ep)
+    print epj
+    assert epj == {'customized': True}
+
     class A(InheritableSQLObject):
         foo = so.StringCol()
-
     A.createTable()
+
     class B(A):
         bar = so.StringCol()
-
     B.createTable()
 
+    class C(A):
+        baz = so.StringCol()
+        def __json__(self):
+            return {'customized': True}
+    C.createTable()
+
     
     b = B(foo="foo", bar="bar")
     bj = jsonify.jsonify(b)
     print bj
     assert bj == {'foo' : "foo", 'bar' : "bar", 'id' : b.id, 'childName' : None}
 
-
+    c = C(foo="foo", baz="baz")
+    cj = jsonify.jsonify(c)
+    print cj
+    assert cj == {'customized': True}


Index: python-turbojson.spec
===================================================================
RCS file: /cvs/pkgs/rpms/python-turbojson/EL-5/python-turbojson.spec,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- python-turbojson.spec	27 Nov 2007 20:24:51 -0000	1.3
+++ python-turbojson.spec	2 Feb 2008 18:01:13 -0000	1.4
@@ -5,13 +5,16 @@
 
 Name:           python-turbojson
 Version:        1.1.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Python template plugin that supports json
 
 Group:          Development/Languages
 License:        MIT
 URL:            http://cheeseshop.python.org/pypi/TurboJson
 Source0:        http://pypi.python.org/packages/source/T/TurboJson/TurboJson-%{version}.tar.gz
+# Backport of upstream patch to fix SQLAlchemy support::
+# http://trac.turbogears.org/changeset/3749?format=diff&new=3749
+Patch0:         python-turbojson-SAfix-r3749.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 
@@ -26,6 +29,7 @@
 
 %prep
 %setup -q -n TurboJson-%{version}
+%patch0 -p0
 
 %build
 %{__python} setup.py build
@@ -33,8 +37,7 @@
 
 %install
 rm -rf %{buildroot}
-%{__python} setup.py install --skip-build --root=%{buildroot} \
-    --single-version-externally-managed
+%{__python} setup.py install --skip-build --root=%{buildroot}
 
 
 %clean
@@ -48,6 +51,12 @@
 
 
 %changelog
+* Sat Feb 2 2008 Toshio Kuratomi <tkuratom at redhat.com> 1.1.2-3
+- ...and remember to include the patch in cvs.
+
+* Sat Feb 2 2008 Toshio Kuratomi <tkuratom at redhat.com> 1.1.2-2
+- Backport fix for 1.1.2's SQLAlchemy breakage.
+
 * Tue Nov 27 2007 Luke Macken <lmacken at redhat.com> 1.1.2-1
 - 1.1.2
 




More information about the fedora-extras-commits mailing list