Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 42 lines (29 sloc) 1.211 kB
from datetime import datetime
from stdnet import odm
class Post(odm.StdModel):
def __init__(self, data = ''):
self.dt = = data
class User(odm.StdModel):
'''A model for holding information about users'''
username = odm.AtomField(unique=True)
password = odm.AtomField()
updates = odm.ListField()
def __unicode__(self):
return self.username
def newupdate(self, data):
p = Post(data = data).save()
return p
def follow(self, user):
'''Follow a user'''
if user is not self and user not in self.following():
return UserFollower(user = user, follower = self).save()
def following(self):
return set(f.user for f in self.following_set.all())
def followers(self):
return set(f.user for f in self.followers_set.all())
class UserFollower(odm.StdModel):
user = odm.ForeignKey(User, related_name = 'followers_set')
follower = odm.ForeignKey(User, related_name = 'following_set')
Jump to Line
Something went wrong with that request. Please try again.