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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:05:54+00:00 2026-05-11T17:05:54+00:00

Assume I have a Model class called Bird and a instance of Bird called

  • 0

Assume I have a Model class called Bird and a instance of Bird called pigeon. I know I can get all the Properties of Pigeon (or bird) using

properties = pigeon.properties() #Note, Bird.properties() would also work

This returns me a dictionary where the keys are strings that match the name I gave said properties in birds, and the value are actual Property objects. My question is, how do I get or set the value using said property objects. I wish to do this because I want to allow a client to dynamically specify as strings:

1) the key to a Model object

2) a property of said Model object

3) and a value that the afformentioned Property of said Model object might take on

So clearly, I need to first get the Model object, then determine whether said Property exist, and finally get or set it somehow? Is this possible? Thank you.

  • 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-11T17:05:54+00:00Added an answer on May 11, 2026 at 5:05 pm

    I played around with App Engine Console, which is great for testing and experimenting. It looks to me like you want to use __set__, with the first argument being your model instance, and the second being the new value. Next you need to put() the instance as usual.

    Here is the console session to make it clearer. (Have I mentioned how App Engine Console is awesome?)

    >>> from google.appengine.ext import db
    >>> class Bird(db.Model):
    ...   name = db.StringProperty()
    ...   can_fly = db.BooleanProperty()
    ... 
    >>> def summarize():
    ...   for name in ('Pesto', 'Bobby'):
    ...     count = Bird.all().filter('name =', name).count()
    ...     print 'I found %d birds named %s' % (count, name)
    ...
    >>> summarize()
    I found 0 birds named Pesto
    I found 0 birds named Bobby
    >>> pigeon = Bird(name='Pesto', can_fly=True)
    >>> pigeon.put()
    datastore_types.Key.from_path('Bird', 41015L, _app=u'con')
    >>> summarize()
    I found 1 birds named Pesto
    I found 0 birds named Bobby
    >>> props = pigeon.properties()
    >>> props
    {'can_fly': <google.appengine.ext.db.BooleanProperty object at 0x46ddd1cc3ddb2268>, 'name': <google.appengine.ext.db.StringProperty object at 0x46ddd1cc3ddb2fe8>}
    >>> prop = props['name']
    >>> prop
    <google.appengine.ext.db.StringProperty object at 0x46ddd1cc3ddb2a68>
    >>> prop.__set__(pigeon, 'Bobby')
    >>> pigeon.name
    'Bobby'
    >>> pigeon.put()
    datastore_types.Key.from_path('Bird', 41015L, _app=u'con')
    >>> summarize()
    I found 0 birds named Pesto
    I found 1 birds named Bobby
    >>> bobby = Bird.all().filter('name =', 'Bobby').fetch(1)[0]
    >>> bobby.name
    u'Bobby'
    

    If you try the online console demo yourself, be sure to delete my old instances first, as we all share the same data store.

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

Sidebar

Related Questions

Let's assume I have a model called product. Let's assume that product has three
Assume I have a class called Customer . Now I need to render the
I have a model class Action that get's extended by several other classes. I
Assume I have a class foo, and wish to use a std::map to store
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Assume you have some objects which have several fields they can be compared by:
Assume I have 10 Methods and 10 Properties. Is there a way to add
Assume I have a form class SampleClass(forms.Form): name = forms.CharField(max_length=30) age = forms.IntegerField() django_hacker
Assume you have five products, and all of them use one or more of
I have a model called Kase each Case is assigned to a contact person

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.