There are a couple of things in your code that stop me from testing this.
Where is *followers* defined, where does *me* come from? Should there be a
line with me = auth.user_id somewhere? Where is *name_of *defined ?
After guessing all these things I got it working and could not reproduce
your problem:
Controller:
@auth.requires_login()
def timeline():
me = db.post.posted_by.default = auth.user_id
db.post.posted_on.default = request.now
#create form with which the user can submit posts
crud.settings.formstyle = 'table2cols'
form = crud.create(db.post)
#determine who the user follows
my_followees = db(db.followers.follower==me)
me_and_my_followees = [me]+[row.followee for row in
my_followees.select(db.followers.followee)]
#Pull all posts to be displayed
postings =
db(db.post.posted_by.belongs(me_and_my_followees)).select(orderby=~db.post.posted_on,limitby=(0,100))
return locals()
Model:
db.define_table('followers',
Field('follower', 'reference auth_user'),
Field('followee', 'reference auth_user'),
)
db.define_table('post',
Field('body', 'text', requires=IS_LENGTH(280, 1),
label="What's going down?" ),
Field('posted_by', 'reference auth_user'),
Field('posted_on', 'datetime',
requires=IS_DATETIME('%d-%m-%Y %H:%M:%S'))
)
db.post.body.required = True
db.post.body.requires = IS_LENGTH(280, 1)
db.post.posted_on.required = True
db.post.posted_by.required = True
db.post.posted_on.default = request.now
db.post.posted_on.writable = db.post.posted_on.readable = False
db.post.posted_by.writable = db.post.posted_by.readable = False
def name_of(user_id):
return "%(first_name)s %(last_name)s" % db.auth_user[user_id]
View:
I'm using the one you provided verbatim
This works without any problem, so I'm not exactly sure if I am guessing
something wrong or if you have a weird bug.
As a final note, consider using auth.signature instead of having your own
posted_on and posted_by fields.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.