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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:41:19+00:00 2026-06-01T13:41:19+00:00

I’m trying to migrate my application from the old App Engine db to ndb.

  • 0

I’m trying to migrate my application from the old App Engine db to ndb. Things were going well until I started getting weird errors associated with my custom Decimal property. In the old db, I used Nick Johnson’s code (http://goo.gl/fpKNs). I made a few changes as far as the function names to be compatible with ndb, but the majority remains. Here’s my modified version:

class DecimalProperty(db.Property):
    def _validate(self, value):
        if not isinstance(value, (Decimal, str)):
            raise datastore_errors.BadValueError('Expected decimal or string, got %r' % (value,))

        return Decimal(value)

    def _db_set_value(self, v, unused_p, value):
        if not isinstance(value, (str, Decimal)):
            raise TypeError('DecimalProperty %s can only be set to string values; received %r' % (self._name, value))
        v.set_stringvalue(str(value))

    def _db_get_value(self, v, unused_p):
        if not v.has_stringvalue():
            try:
                return Decimal(v)
            except ValueError:
                return None

        return Decimal(v.stringvalue())

And here’s one example traceback:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1536, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "U:\Hefner\Dropbox\Public\Projects\GHI\dev\rpc.py", line 68, in get
    result = func(*args)
  File "U:\Hefner\Dropbox\Public\Projects\GHI\dev\rpc.py", line 278, in getDonations
    response = utilities.getAllDonations(self, settings_key, query_cursor)
  File "U:\Hefner\Dropbox\Public\Projects\GHI\dev\GlobalUtilities.py", line 361, in getAllDonations
    query = models.Donation.gql("WHERE settings_key = :s ORDER BY time_created DESC", s=settings_key)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\model.py", line 2885, in _gql
    *args, **kwds)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\query.py", line 1318, in gql
    qry = _gql(query_string)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\utils.py", line 136, in positional_wrapper
    return wrapped(*args, **kwds)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\query.py", line 1366, in _gql
    if prop._name != name:
AttributeError: 'str' object has no attribute '_name'

I may be wrong, but it seems like the Decimal Property is returning a string instead of an instance of the property and I have no idea what to do about that. When I comment out the amount_donated = DecimalProperty() in my model class, everything works perfectly.

  • 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-01T13:41:21+00:00Added an answer on June 1, 2026 at 1:41 pm

    Looks like you pasted in the ld db code…

    Anyway, see these docs: https://developers.google.com/appengine/docs/python/ndb/subclassprop

    You want to use _to_base_type() and _from_base_type().

    Good luck!

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

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.