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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:10:48+00:00 2026-06-02T16:10:48+00:00

I have a non-ndb entity that is created and a webapp2 User who owns

  • 0

I have a non-ndb entity that is created and a webapp2 User who owns this object. Is it possible to keep the key as an instance variable? I get an exception trying to do this:

'Ad' object has no attribute '_values'
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/data/home/apps/s~montaoproject/sessions.358423846858516313/authhandlers.py", line 21, in dispatch
    webapp2.RequestHandler.dispatch(self)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~montaoproject/sessions.358423846858516313/main.py", line 3004, in post
    ad.usr = self.current_user.key
  File "/base/data/home/apps/s~montaoproject/sessions.358423846858516313/ndb/model.py", line 1039, in __set__
    self._set_value(entity, value)
  File "/base/data/home/apps/s~montaoproject/sessions.358423846858516313/ndb/model.py", line 801, in _set_value
    self._store_value(entity, value)
  File "/base/data/home/apps/s~montaoproject/sessions.358423846858516313/ndb/model.py", line 785, in _store_value
    entity._values[self._name] = value
AttributeError: 'Ad' object has no attribute '_values'

The offending code

if self.current_user:
    logging.info('user:'+str(self.current_user))
    ad.usr = self.current_user.key
    ad.put

Model

class Ad(GeoModel, search.SearchableModel):

    primary_image = blobstore.BlobReferenceProperty()
    usr = ndb_model.KeyProperty()
    ...

Is there a recommended way to do what I’m trying to do?

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-06-02T16:10:49+00:00Added an answer on June 2, 2026 at 4:10 pm

    The Key types in NDB and db are different. You must convert the NDB Key (self.current_user.key) to a db.Key instance as follows:

    ad.usr = self.current_user.key.to_old_key()
    

    See https://developers.google.com/appengine/docs/python/ndb/keyclass#Key_to_old_key

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

Sidebar

Related Questions

I have non blocking UDP socket in perl created this way my $my_sock =
I have non-template class with a templatized constructor. This code compiles for me. But
I've been trying to deal with some delimited text files that have non standard
I have a non-.Net executable file that is included in my .net assembly as
We have a (non-web app) Spring application that throws a NoSuchBeanDefinitionException when running tests
I have an (non-virtualized) ItemsControl that binds its ItemsSource to a ObeservableCollection of ViewModel
The problem is the following. There are multiple rows that have non-unique identifiers: id
I would like to detect strings that have non-whitespace characters in them. Right now
Is it possible to define a control to have non-specified set of attributes? For
I have created a Static Class and used that in Reflection. But when 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.