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 7497751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:13:01+00:00 2026-05-29T19:13:01+00:00

I want my ids to be < 999999999 but now trying to program that

  • 0

I want my ids to be < 999999999 but now trying to program that it seems to have the opposite effect, I’m only getting ids larger and when I try to allocate ids start > end ?

start, end = User.allocate_ids(max=999999999)
logging.info('start %d' % start)
logging.info('end %d' % end)
lower = start if start < end else end
key = User(id=lower).put()
logging.info('key: '+str(key))
user = key.get()
user.add_auth_id(email)

My log output show that the ID that gets allocated is wrong:

2012-02-13 03:19:07.396 start 98765439124
I 2012-02-13 03:19:07.396 end 98765439123

How can I fix this?

Update

The dirty workaround I end up using is making sort of an own ID system which I should not do but it was the only solution in this case and I do not think this will create conflicts or duplicates, it just might be slow if entities start filling up, but for now this seems like a solution that works acceptably towards the user though it might not look that good looking at the code:

    new_id = random.randint(1,999999999)
    logging.info('testing new id: %d' % new_id)
    while User.get_by_id(new_id) != None:
        new_id = random.randint(1,999999999)
    logging.info('creating new id: %d' % new_id)
    key = User(id=new_id).put()
  • 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-29T19:13:01+00:00Added an answer on May 29, 2026 at 7:13 pm

    As explained in NDB documentation: allocateIds(max=) will returns the first id that is available, in case you try to reserve IDs that have already been allocated.

    In your case all ids up to 999999999 already have been allocated before (maybe by other calls to allocate_ids), 98765439124 is the first id that is available, 98765439123 is the last one that have been allocated.

    See the following example:

    >>> Foo.allocate_ids(max=26740080011040)
    (26740080011031L, 26740080011040L)
    

    Allocate all ids up to 26740080011040

    >>> Foo.allocate_ids(max=26740080011040)
    (26740080011041L, 26740080011040L)
    

    All ids up to 26740080011040 already have been allocated, first available ids is 26740080011041, last allocated is 26740080011040

    >>> Foo.allocate_ids(max=26740080011050)
    (26740080011041L, 26740080011050L)
    

    Allocate all ids up to 26740080011050

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

Sidebar

Related Questions

I have an array of Ids that I want to pass to the entity
I have a comma delimited list of ids that I want to use to
I want to use jquery autocomplete in a foreach loop. When using ids, only
I have 2 Ids #totalcbm and #gross , i want to divide both these
Given an array of ids $galleries = array(1,2,5) I want to have a SQL
I have multiple comment ids I want to reset to a default value. Ex:
I have an array of category ids and want to retrieve articles from my
I'm currently coding a product which will have only one database but will host
Getting the above Error. I want the IDs of the Accordian to be unique
I have a table: id group data 1  a     10 2  a     20 3  b     10 4  b     20 I want to get ids

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.