I have a 2 classes.
One looks like this:
class Feed(db.Model):
bid = db.StringProperty()
title = db.StringProperty()
url = db.StringProperty()
datecreated = db.DateProperty(auto_now_add=True)
voice = db.StringProperty()
lastchecked = db.DateProperty(auto_now=True)
language = db.StringProperty()
active = db.BooleanProperty()
posts = db.ListProperty(db.Key)
The other looks like this:
class Post(db.Model):
title = db.StringProperty()
postdate = db.DateTimeProperty()
author = db.StringProperty()
body = db.TextProperty()
link = db.LinkProperty()
hasmp3 = db.BooleanProperty()
mp3location = db.StringProperty()
processed = db.BooleanProperty()
voice = db.StringProperty()
length = db.FloatProperty()
inprocess = db.BooleanProperty()
haspict = db.BooleanProperty()
pictures = db.ListProperty(db.Key)
I am trying to update a Feed by appending a Post like this:
blogid = cgi.escape(self.request.get('bid'))
postid = cgi.escape(self.request.get('pid'))
blog = Feed.get_by_key_name(blogid)
post = Post.get_by_key_name(postid)
if post.key() not in blog.posts:
blog.posts.append(post.key())
blog.put()
When I attempt to 'put' the blog with the post information, python doesn't like it and tells me
AttributeError: 'Feed' object has no attribute 'posts'
The reason I am so confused is because I have nearly the exact logic in adding a 'Feed' to a 'UserClass' where the 'UserClass' has 'Feeds' designated as a ListProperty in the same way that a 'Feed' has a 'Post' designated as a ListProperty.
This is an example of what I mean:
class UserClass(db.Model):
synccode = db.StringProperty()
firstname = db.StringProperty()
lastname = db.StringProperty()
address = db.StringProperty()
address2 = db.StringProperty()
city = db.StringProperty()
state = db.StringProperty()
zipcode = db.StringProperty()
emailaddress = db.StringProperty()
password = db.StringProperty()
mobile = db.StringProperty()
is_authenticated = db.BooleanProperty()
groupid = db.StringProperty()
mobilesynched = db.BooleanProperty()
devicemodel = db.StringProperty()
isatmoscast = db.BooleanProperty()
registerdate = db.DateProperty(auto_now_add=True)
pack = db.StringProperty()
personalcontact = db.BooleanProperty()
lastlogin = db.DateProperty(auto_now_add=True)
isactive = db.BooleanProperty()
feeds = db.ListProperty(db.Key)
This works fine:
if blog.key() not in user.feeds:
user.feeds.append(blog.key())
user.put()
This throws the error:
if post.key() not in blog.posts:
blog.posts.append(post.key())
blog.put()
Any help would be appreciated.