Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6377953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:56:30+00:00 2026-05-25T01:56:30+00:00

After fetching an entity from the datastore, I’d like to save its key into

  • 0

After fetching an entity from the datastore, I’d like to save its key into memcache and also pass it as part of a url parameter for a task for referencing it later.

However, since Key is a composite item, you can’t forward it as is and when I try to re-construct the key, the values aren’t identical.

What’s the best approach for passing of a key to reference the entity at a later time?

entity_key = feed_entity.key()   
logging.info(entity_key) # produces a string like key value

# would like to save a way to reference the key later
memcache.set(entity_key.id_or_name(), some_piece_of_data);

# Will produce the error:
# Key must be a string instance, received datastore_types.Key.from_path
# (u'FeedEntity', u'My_Entity_Name', u'FeedEntity', 2L, _app=u'dev~test_app')

reconstructed_key = Key.from_path('FeedEntity', 'My_Entity_Name', 'FeedEntity', entity_key.id_or_name());
logging.info(reconstructed_key)
# Not the same value as entity_key

params = {"key": entity_key_string_value} # this would be ideal
task = taskqueue.Task(url='/feed_entity/list', params=params).add(queue_name="feed-gopher")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:56:30+00:00Added an answer on May 25, 2026 at 1:56 am

    See http://code.google.com/appengine/docs/python/datastore/keyclass.html#Key

    A key can be encoded to a string by passing the Key object to str() (or calling the object’s __str__() method). A string-encoded key is an opaque value using characters safe for including in URLs. The string-encoded key can be converted back to a Key object by passing it to the Key constructor (the encoded argument).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After adding a boolean attribute to an object, fetching that object from the datastore
I can't get nl2br function to work after fetching data from my database: $result
I have mysql table with collumns like 'operation.date', 'operation.name' and etc. After fetching that
Part of my MVC view page gets refreshed every 30 seconds after fetching some
I am creating a table at run time after fetching the result from the
Let say i have 100k records in table, after fetching that records from table
i am making iPad application, in which i am fetching data from Url, after
I just recently switched out our repository and context from Linq-to-SQL to Entity Framework
I am fetching my data with id which is Integer primary key or integer.
Hi i am getting the following exception while fetching the image from server. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.