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

  • SEARCH
  • Home
  • 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 7443247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:18:06+00:00 2026-05-29T11:18:06+00:00

I am building an App Engine app that uses OAuth to get a user’s

  • 0

I am building an App Engine app that uses OAuth to get a user’s data from an external API. The user is assigned a numerical id by the external API. I was considering giving my User model an id field which would store a copy of the external user id. Then I remembered that DataStore records can be given keys with a manually assigned numerical id.

external_id = int(api_response['user']['id'])
handmade_key = db.Key.from_path('User', external_id)

By manually constructing the key before creating the record I would then be able to retrieve the record using this id alone.

user = User.get_by_id(external_id)

However, I understand that I would need to allocate the entire range of ids that the API might use.

allocate_ids(User, 10000)

My first question is; when should I call allocate_ids? Seems like I should only have to execute it once, but if it executes each time an instance of my app is spun up will that effect performance? If I never put User entities without a manually constructed Key do I still need to allocate_ids?

The second question is; am I mad!? Doing it the regular way isn’t much more troublesome

user = User.all().filter('external_id =', external_id)

Is it worth the hassle of allocating ids to avoid that DataStore query?

  • 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-29T11:18:06+00:00Added an answer on May 29, 2026 at 11:18 am

    You don’t need to allocate_ids if you always construct keys in the manner you describe. It’s only necessary when you expect to also allow the Datastore to create its own auto-incrementing numeric IDs.

    And yes, you are almost always better off with fewer fields and indices, so create the Key using the external unique ID value, as you describe.

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

Sidebar

Related Questions

I'm building an app that pulls data in from an excel .csv file and
So I'm building an app that uses win32's SendMessage as IPC. I'm using FindWindow
I'm building an application, that uses the Django templating engine / language to compile
I am building a web application on Google App Engine that requires users to
I'm building a Google App Engine web app, with a Java back end, that
I'm building a multiuser realtime application with Google App Engine (Python) that would look
I'm building an app on Google App Engine. I'm incredibly new to Python and
I'm building an app that authors would (hopefully) use to help them, uh.. author
We're building an app that stores hours of operation for various businesses. What is
I am building an app that talks to an Access database via OleDB/Jet. There

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.