On Oct 11, 2009, at 8:06 AM, Manlio Perillo wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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".
So RowProxy as it stands, regardless of __slots__, could not be
pickled unless it were made to work in an essentially non-proxied way
on the other side of the pickle. I don't think adding conditionals
to every RowProxy method is really worth it here. There is a subclass
called BufferedColumnRow which pre-fetches the whole row into a plain
array - its used by the Oracle dialect to pre-buffer cx_oracle.LOB
objects which can't be fetched after the next batch of rows has been
read. But I don't favor the overhead of BCR as a default behavior
(i.e. fetches and processes all columns regardless of them actually
being called upon).
>
>
>
> Thanks Manlio Perillo
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkrRylEACgkQscQJ24LbaUR5YwCbBF1KjQTWVpVU6P6I7X9taouv
> vS8AoIRfmoyfF/hKt5vf+tBJ6ZqtBA3C
> =BMbb
> -----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
-~----------~----~----~----~------~----~------~--~---