If you want to have a persistent class that you can add arbitrary
vales to, try db.Expando.  It will let you do:

class Event(db.Model) :
         owner = db.UserProperty()
         title = db.StringProperty()
         content = db.StringProperty(multiline = True)

e = Event()
e.color = "Green"

  Color will then be stored along with the static properties owner,
title and content.  You check the presence or absence of those
"dynamic" properties (the ones that are not defined in the class)
like:

  hasattr(e, 'color')

  However, you could have also declared color and status as normal
string properties and just left them unassigned.  They would get put
in the datastore as None.


On Mar 3, 8:32 pm, disorderdev <[email protected]> wrote:
> Hi, I'm a newbie here, both python and app engine. a few questions:
>  I store some fields in DB, but when show message on Web, I need more
> fields, most of them are calculated according to fields in DB, For now
> I don't want to do the calculating on web, but when I add some fields
> to the DB model class, the web dose not recognize them, all values are
> None, what should I do?
>
> For example, I have a class
> class Event(db.Model) :
>         owner = db.UserProperty()
>         title = db.StringProperty()
>         content = db.StringProperty(multiline = True)
>         status = None
>         color = None
>
> when showing events on web, I want 'color' and 'status', so after
> retrieve the data from DB, I do the following:
>
>                 for event in events :
>                         logger.info(event.status)
>                         logger.info(event.color);
>                         event.create_time = datetime.now()
>                         event.status = "Finished"
>                         event.color = "green"
>
> but on web, they are still None.
>
> BTW: I have to add status and color in class, or these fields are not
> recognized.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to