On Jul 11, 2013, at 11:43 AM, Amir Elaguizy <[email protected]> wrote:

> If I do a query like this:
> 
>         return PcpPostModel.query.filter_by(id=post_id).options(
>             FromCache("default")
>         )
> 
> and then later I do another query like this:
>     
>     PcpPostModel.query.options(FromCache("default")).all()
> 
> Any models that were returned by the first query are now of type: <class 
> 'dogpile.cache.api.CachedValue'>

CachedValue is a tuple-based container that contains the actual result you want 
to work with as well as the time that the value was placed in the cache.   Take 
a look at the contents of CachedValue.

> 
> So then when the second query runs it will except with:
> 
>   File "/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/copy_reg.py", 
> line 70, in _reduce_ex
>     raise TypeError, "can't pickle %s objects" % base.__name__
> TypeError: can't pickle function objects
> 
> Any idea what I can do about this?

something in your model class, or your mapping, or perhaps within some 
SQLAlchemy construct in use, is a callable function that isn't picklable.  
SQLAlchemy itself goes through a lot of trouble to not embed functions in 
mapped instances, however in some cases it's difficult to avoid.  You'd need to 
provide full detail on your classes/mappings, most preferably a fully 
contained, runnable example, in order to determine where this callable is 
present.   


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to