diff options
| author | Gaëtan de Menten <gdementen@gmail.com> | 2010-02-14 21:21:40 +0000 |
|---|---|---|
| committer | Gaëtan de Menten <gdementen@gmail.com> | 2010-02-14 21:21:40 +0000 |
| commit | ded4e1d76b634b94a161bc91a3b4eb9d8777332b (patch) | |
| tree | 506bbae8952047314bd2e576edd04d5060fdc708 /lib/sqlalchemy | |
| parent | f43ef377289eef8e8ae936723c0c0903e83075e9 (diff) | |
| download | sqlalchemy-ded4e1d76b634b94a161bc91a3b4eb9d8777332b.tar.gz | |
- fix C version of rowproxy pickling so that it pickles to the same format
as the Python version.
- changelog my earlier processor optimization work
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/cextension/resultproxy.c | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 21 |
2 files changed, 10 insertions, 15 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c index 14ea1828e..048d74d74 100644 --- a/lib/sqlalchemy/cextension/resultproxy.c +++ b/lib/sqlalchemy/cextension/resultproxy.c @@ -26,7 +26,7 @@ typedef struct { ****************/ static PyObject * -rowproxy_reconstructor(PyObject *self, PyObject *args) +safe_rowproxy_reconstructor(PyObject *self, PyObject *args) { PyObject *cls, *state, *tmp; BaseRowProxy *obj; @@ -560,7 +560,7 @@ static PyTypeObject BaseRowProxyType = { static PyMethodDef module_methods[] = { - {"rowproxy_reconstructor", rowproxy_reconstructor, METH_VARARGS, + {"safe_rowproxy_reconstructor", safe_rowproxy_reconstructor, METH_VARARGS, "reconstruct a RowProxy instance from its pickled form."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 4dc9665c0..ff475ee3d 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1596,21 +1596,16 @@ def _proxy_connection_cls(cls, proxy): # This reconstructor is necessary so that pickles with the C extension or # without use the same Binary format. -# We need a different reconstructor on the C extension so that we can -# add extra checks that fields have correctly been initialized by -# __setstate__. try: - from sqlalchemy.cresultproxy import rowproxy_reconstructor - - # this is a hack so that the reconstructor function is pickled with the - # same name as without the C extension. - # BUG: It fails for me if I run the "python" interpreter and - # then say "import sqlalchemy": - # TypeError: 'builtin_function_or_method' object has only read-only attributes (assign to .__module__) - # However, if I run the tests with nosetests, it succeeds ! - # I've verified with pdb etc. that this is the case. - #rowproxy_reconstructor.__module__ = 'sqlalchemy.engine.base' + # We need a different reconstructor on the C extension so that we can + # add extra checks that fields have correctly been initialized by + # __setstate__. + from sqlalchemy.cresultproxy import safe_rowproxy_reconstructor + # The extra function embedding is needed so that the reconstructor function + # has the same signature whether or not the extension is present. + def rowproxy_reconstructor(cls, state): + return safe_rowproxy_reconstructor(cls, state) except ImportError: def rowproxy_reconstructor(cls, state): obj = cls.__new__(cls) |
