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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:48:46+00:00 2026-05-15T14:48:46+00:00

I am asking because the way I have it right now seems really strange.

  • 0

I am asking because the way I have it right now seems really strange. Basically, I am saying, “If there is an exception thrown, do something. Else, do nothing.” Here is some sample code:

 try:
        db.get(db.Key(uid))
 except:
        newUser = User(key_name=str(uid)) 
        newUser.first_name = self.request.get("first")
        newUser.last_name = self.request.get("last")
        newUser.email = self.request.get("email") 
        newUser.phone = self.request.get("phone")
        db.put(newUser)

Thanks!

  • 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-15T14:48:46+00:00Added an answer on May 15, 2026 at 2:48 pm

    Use User.get_by_key_name(str(uid)) instead. It will return None if the entity doesn’t exist.

    See http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_key_name for details.

    User.get_or_insert(str(uid)) might also be a good fit for what you’re trying to do.

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

Sidebar

Related Questions

Does Bash have something like ||= ? I.e., is there a better way to
I feel silly asking this because I'm betting the answer is staring right at
I'm asking this question because I have gone through the tutorial posted here: Preventing
The reason I'm asking this is because there is a validation in OpenERP that
Is rjava the only way to connect R to Java? I am asking because
The reason I am asking this question is because I have landed my first
Asking for the best way to address this issue: in my controller I have
Not sure I'm asking the right question, but it's a start. I have a
Are all canvas tag dimensions in pixels? I am asking because I understood them
I'm asking this because I'm in the process of writing two such editors for

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.