Reputation: 23
I want to save a list in MemCache in AppEngine with Python and I am having the next error :
TypeError: new() takes exactly 4 arguments (1 given).
This is the link of the image with the error : https://i.sstatic.net/we3VU.png
And this is my code :
def get_r_post_relation(self, url, update = False) :
sufix = "r"
key = sufix + url
list_version = memcache.get(key)
if not list_version or update :
logging.error("LIST VERSION QUERY")
postobj = get_wiki_post(url)
list_version = WikiPostVersion.query().filter(WikiPostVersion.r_post == postobj.key)
memcache.set(key, list_version)
return list_version
Upvotes: 1
Views: 324
Reputation: 11360
You are not storing a list. You are storing a query object. To store a list, use .fetch()
:
list_version = WikiPostVersion.query().filter(WikiPostVersion.r_post == postobj.key).fetch()
You can store a simple query object, but when you add .order()
or .filter()
, you'll get a pickling error. Change to list, and you're all set.
Remember, a query object doesn't have any entities in it. It is simply a set of instructions that will go and retrieve the entities when used later with a .get()
or .fetch()
. So, you are trying to store a python command set, when your intention is to store the actual entity list.
Upvotes: 3