old_contents: from app import db
  from hashlib import md5
  
  class User(db.Model):
  	id = db.Column(db.Integer, primary_key=True)
  	nickname = db.Column(db.String(64), index=True, unique=True)
  	email = db.Column(db.String(120), index=True, unique=True)
  	posts = db.relationship('Post', backref='author', lazy='dynamic')
  	about_me = db.Column(db.String(140))
  	last_seen = db.Column(db.DateTime)
  
  	@property
  	def is_authenticated(self):
  		return True
  
  	@property
  	def is_active(self):
  		return True
  
  	@property
  	def is_annoymous(self):
  		return False
  
  	def get_id(self):
  		try:
  			return unicode(self.id)
  		except NameError:
  			return str(self.id)
  
  	def avatar(self, size):
  		'''This method returns the URL of the user's avatar image'''
  		return 'http://gravatar.com/avatar/%s?d=mm&s=%d' % \
  			   (md5(self.email.encode('utf-8')).hexdigest(), size)
  
  	def __repr__(self):
  		'''This method tells Python how to print objects of
  		this class.
  		'''
  		return '<User %r>' % (self.nickname)
  
  class Post(db.Model):
  	id = db.Column(db.Integer, primary_key=True)
  	body = db.Column(db.String(140))
  	timestamp = db.Column(db.DateTime)
  	user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
  			
  	def __repr__(self):
  		return '<Post %r>' % (self.body)
new_contents: from app import db
  from hashlib import md5
  
  class User(db.Model):
  	id = db.Column(db.Integer, primary_key=True)
  	nickname = db.Column(db.String(64), index=True, unique=True)
  	email = db.Column(db.String(120), index=True, unique=True)
  	posts = db.relationship('Post', backref='author', lazy='dynamic')
  	about_me = db.Column(db.String(140))
  	last_seen = db.Column(db.DateTime)
  
  	@property
  	def is_authenticated(self):
  		return True
  
  	@property
  	def is_active(self):
  		return True
  
  	@property
  	def is_annoymous(self):
  		return False
  
  	def get_id(self):
  		try:
  			return unicode(self.id)
  		except NameError:
  			return str(self.id)
  
  	def avatar(self, size):
  		'''This method returns the URL of the user's avatar image'''
  		return 'https://gravatar.com/avatar/%s?d=mm&s=%d' % \
  			   (md5(self.email.encode('utf-8')).hexdigest(), size)
  
  	def __repr__(self):
  		'''This method tells Python how to print objects of
  		this class.
  		'''
  		return '<User %r>' % (self.nickname)
  
  	#: staticmethod don't work on instances.
  	@staticmethod
  	def make_unique_nickname(nickname):
  		if User.query.filter_by(nickname=nickname).first() is None:
  			return nickname
  		version = 2
  		while True:
  			new_nickname = nickname + str(version)
  			if User.query.filter_by(nickname=new_nickname).first() is None:
  				break
  			version += 1
  		return new_nickname
  
  class Post(db.Model):
  	id = db.Column(db.Integer, primary_key=True)
  	body = db.Column(db.String(140))
  	timestamp = db.Column(db.DateTime)
  	user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
  			
  	def __repr__(self):
  		return '<Post %r>' % (self.body)
subject: update models