[python-sqlamp/f16] Backported support for SA 0.7.2 from sqlamp 0.6 branch

Martin Bacovsky mbacovsk at fedoraproject.org
Sat Dec 3 19:06:32 UTC 2011


commit 2f4b4bfca6ce356c9fd4ab734b71f2f5c3ebdd70
Author: Martin Bačovský <mbacovsk at redhat.com>
Date:   Sat Dec 3 20:04:40 2011 +0100

    Backported support for SA 0.7.2 from sqlamp 0.6 branch
    
    - cleaned patches

 python-sqlamp.spec                |   13 +++++---
 sa-0.7.2-compatibility.patch      |   64 +++++++++++++++++++++++++++++++++++++
 sa0.6.6.patch                     |   24 --------------
 sqlite-3.6.x-bug-workaround.patch |   24 +++++++-------
 4 files changed, 84 insertions(+), 41 deletions(-)
---
diff --git a/python-sqlamp.spec b/python-sqlamp.spec
index 65decd6..d4cb820 100644
--- a/python-sqlamp.spec
+++ b/python-sqlamp.spec
@@ -4,15 +4,15 @@
 
 Name:           python-sqlamp
 Version:        0.5.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Library for working with hierarchical data structures using SQLAlchemy
 
 Group:          Development/Languages
 License:        BSD
 URL:            http://sqlamp.angri.ru/
 Source0:        http://sqlamp.angri.ru/sqlamp-%{version}.tar.gz
-Patch0:         sa0.6.6.patch
-Patch1:         sqlite-3.6.x-bug-workaround.patch
+Patch0:         sqlite-3.6.x-bug-workaround.patch
+Patch1:         sa-0.7.2-compatibility.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 
@@ -30,8 +30,8 @@ with hierarchical data structures. sqlamp uses (and depends on) SQLAlchemy.
 
 %prep
 %setup -q -n sqlamp-%{version}
-%patch0 -p1
-%patch1 -p1
+%patch0 -p1 -b .sqlite36x
+%patch1 -p1 -b .sa72
 
 %build
 %{__python} setup.py build
@@ -67,6 +67,9 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Thu Dec 01 2011 Martin Bacovsky <mbacovsk at redhat.com> - 0.5.2-3
+- Backported support for SA 0.7.2 from 0.6 branch of sqlamp
+
 * Mon Mar 28 2011 Martin Bacovsky <mbacovsk at redhat.com> - 0.5.2-2
 - Fixed support of SQLAlchemy 0.6.6 in MPOptions.order_by_clause(). Patch by Josip Delic.
 - Workaround for bug in sqlite 3.6.x (problems with binding two integer attributes). Initial patch by Josip Delic.
diff --git a/sa-0.7.2-compatibility.patch b/sa-0.7.2-compatibility.patch
new file mode 100644
index 0000000..62c7384
--- /dev/null
+++ b/sa-0.7.2-compatibility.patch
@@ -0,0 +1,64 @@
+diff -up sqlamp-0.5.2/CHANGES.sa72 sqlamp-0.5.2/CHANGES
+--- sqlamp-0.5.2/CHANGES.sa72	2011-12-02 13:23:32.887982415 +0100
++++ sqlamp-0.5.2/CHANGES	2011-12-02 13:25:41.049320307 +0100
+@@ -2,6 +2,7 @@
+ -------------------------
+ - Workaround for bug in sqlite 3.6.x (problems with binding two integer
+   attributes). Initial patch by Josip Delic.
++- Backported support for SA 0.7.2 from 0.6 branch of sqlamp
+ 
+ 0.5.2: released 2010-09-19
+ --------------------------
+diff -up sqlamp-0.5.2/sqlamp/__init__.py.sa72 sqlamp-0.5.2/sqlamp/__init__.py
+--- sqlamp-0.5.2/sqlamp/__init__.py.sa72	2011-12-02 13:21:20.813603674 +0100
++++ sqlamp-0.5.2/sqlamp/__init__.py	2011-12-02 13:22:33.311360487 +0100
+@@ -77,8 +77,18 @@ ALPHABET = "0123456789ABCDEFGHIJKLMNOPQR
+ PATH_FIELD_LENGTH = 255
+ 
+ 
+-class PathOverflowError(Exception):
+-    "Base class for exceptions in calculations of node's path."
++if hasattr(sqlalchemy.exc, 'DontWrapMixin'):
++    # SQLAlchemy 0.7.2+ allows deriving from this special mixin in order to
++    # let exceptions raised from types methods during flush pass intact.
++    class PathOverflowError(Exception, sqlalchemy.exc.DontWrapMixin):
++        "Base class for exceptions in calculations of node's path."
++else:
++    # SQLAlchemy < 0.7 doesn't need any special base class.
++    class PathOverflowError(Exception):
++        "Base class for exceptions in calculations of node's path."
++    # 0.7 and 0.7.1 wrap exceptions and reraise
++    # sqlalchemy.exc.StatementError, so are not fully supported.
++
+ 
+ class TooManyChildrenError(PathOverflowError):
+     "Maximum children limit is exceeded. Raised during flush."
+@@ -203,10 +213,10 @@ class MPOptions(object):
+         `Query.order_by()`. Used to sort subtree query
+         by `tree_id` and `path`.
+         """
+-        return sqlalchemy.sql.expression.ClauseList(
++        return str(sqlalchemy.sql.expression.ClauseList(
+             self.tree_id_field,
+             self.path_field
+-        )
++        ).compile())
+ 
+ 
+ class _InsertionsParamsSelector(object):
+@@ -1016,6 +1026,13 @@ class DeclarativeMeta(BaseDeclarativeMet
+         super(DeclarativeMeta, cls).__init__(name, bases, dct)
+         mp_manager = MPManager(cls.__table__, **opts)
+         setattr(cls, mp_manager_name, mp_manager)
+-        mp_class_manager = getattr(cls, mp_manager_name)
+-        cls.__mapper__.extension.append(mp_manager.mapper_extension)
++        mapper_ext = mp_manager.mapper_extension
++        if hasattr(cls.__mapper__, 'extension'):
++            # SQLAlchemy < 0.7
++            cls.__mapper__.extension.append(mapper_ext)
++        else:
++            # SQLAlchemy 0.7+
++            from sqlalchemy import event
++            event.listen(cls.__mapper__, 'before_insert', mapper_ext.before_insert, propagate=True)
++            event.listen(cls.__mapper__, 'after_insert', mapper_ext.after_insert, propagate=True)
+ 
diff --git a/sqlite-3.6.x-bug-workaround.patch b/sqlite-3.6.x-bug-workaround.patch
index 2955cad..5b5135e 100644
--- a/sqlite-3.6.x-bug-workaround.patch
+++ b/sqlite-3.6.x-bug-workaround.patch
@@ -1,19 +1,19 @@
-diff -r 7beb2c6cf64b -r 964320ab0ff5 CHANGES
---- a/CHANGES	Mon Jan 24 00:24:03 2011 +0300
-+++ b/CHANGES	Tue Feb 15 21:57:02 2011 +0100
-@@ -2,6 +2,8 @@
- -------------------------
- - Fixed support of SQLAlchemy 0.6.6 in :meth:`MPOptions.order_by_clause`.
-   Patch by Josip Delic.
+diff -up sqlamp-0.5.2/CHANGES.sqlite36x sqlamp-0.5.2/CHANGES
+--- sqlamp-0.5.2/CHANGES.sqlite36x	2010-09-19 16:19:09.000000000 +0200
++++ sqlamp-0.5.2/CHANGES	2011-12-02 13:19:54.989707752 +0100
+@@ -1,3 +1,8 @@
++0.5.3: *not released yet*
++-------------------------
 +- Workaround for bug in sqlite 3.6.x (problems with binding two integer
 +  attributes). Initial patch by Josip Delic.
- 
++
  0.5.2: released 2010-09-19
  --------------------------
-diff -r 7beb2c6cf64b -r 964320ab0ff5 sqlamp/__init__.py
---- a/sqlamp/__init__.py	Mon Jan 24 00:24:03 2011 +0300
-+++ b/sqlamp/__init__.py	Tue Feb 15 21:57:02 2011 +0100
-@@ -237,14 +237,14 @@
+ - SQLAlchemy of versions 0.6.x is now supported as well as 0.5.x.
+diff -up sqlamp-0.5.2/sqlamp/__init__.py.sqlite36x sqlamp-0.5.2/sqlamp/__init__.py
+--- sqlamp-0.5.2/sqlamp/__init__.py.sqlite36x	2010-09-19 16:21:10.000000000 +0200
++++ sqlamp-0.5.2/sqlamp/__init__.py	2011-12-02 13:18:07.718587932 +0100
+@@ -237,14 +237,14 @@ class _InsertionsParamsSelector(object):
              # `tree_id` is next unused integer value,
              # `depth` for root nodes is equal to zero,
              # `path` should be empty string.


More information about the scm-commits mailing list