-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Michael Bayer ha scritto:
>
> On Oct 11, 2009, at 8:06 AM, Manlio Perillo wrote:
>
> Hi.
>
> I have noted a problem when a I try to pickle an instance of
> sqlalchemy.engine.base.RowProxy:
>
> <...>
> File "/usr/lib/python2.5/pickle.py", line 306, in save
> rv = reduce(self.proto)
> File "/usr/lib/python2.5/copy_reg.py", line 76, in _reduce_ex
> raise TypeError("a class that defines __slots__ without "
> TypeError: a class that defines __slots__ without defining
> __getstate__
> cannot be pickled
>
>
> Is this limitation really necessary?
>
>> a RowProxy has an active handle to the parent Result which in turn has
>> an active handle to the DBAPI cursor, and it's data representation is
>> that of the DBAPI's cursor row, which itself is only a "dict like
>> object" in the general case. The actual data isn't pulled across
>> from the DBAPI row until requested - hence the name "Proxy".
>
My use case is quite simple; I always call .fetchall from a ResulProxy,
so all data is in memory.
I don't see any reasons why a RowProxy should not be pickleable in this
case.
I have tried with SQLAlchemy 0.4.2p3 (the version I'm using in
production, and I get this traceback:
http://paste.pocoo.org/show/144372/
I have to say that I don't understand the error.
> [...]
If there is no simple method to pickle a RowProxy, then I should create
a custom driver where the BufferedColumnRow is used.
I have not checked the sources, is it possible to create a custom
database driver as an external plugin?
Note that I need to use pickle only in a testing environment, for a web
application.
The reason is that I have a resource "rendering" function that, in a
testing environment, pickle the content of the Mako context dictionary
and return it from a WSGI application; then this data is unpickled so
that a test case can easily test the application.
Thanks Manlio Perillo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkrR9iUACgkQscQJ24LbaUQRbACgk8d2JLvDpPjWxTXe+WtauJMa
iBwAn1CgrjxyKZ9JpwosNYAxf2kfdyCx
=Y7g9
-----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---