Exemplo n.º 1
0
def read_status(sid):
	status = Status.query.filter_by(sid=sid).first()
	if status is None:
		status = Status(sid=sid)
		db.session.add(status)
		db.session.commit()
	res = wclient.get('statuses/show', id=sid)
	status.update(res)

	if res['retweeted_status']:
		retweeted_sid = res['retweeted_status']['idstr']
		retweeted = Status.query.filter_by(sid=retweeted_sid).first()
		if retweeted is None:
			retweeted = Status(sid=retweeted_sid)
			db.session.add(retweeted)
			db.session.commit()
		retweeted.update(res['retweeted_status'])
	return jsonify(res)
Exemplo n.º 2
0
def create_comment(sid):
	comment = 'test111'
	res = wclient.post('comments/create', comment=comment, id=sid, comment_ori=0)
	status = Status.query.filter_by(sid=sid).first()
	if status is None:
		status = Status(sid=sid)
		db.session.add(status)
		db.session.commit()
	status.update(res['status'])

	if res['status']['retweeted_status']:
		retweeted_sid = res['status']['retweeted_status']['idstr']
		retweeted = Status.query.filter_by(sid=retweeted_sid).first()
		if retweeted is None:
			retweeted = Status(sid=retweeted_sid)
			db.session.add(retweeted)
			db.session.commit()
		retweeted.update(res['status']['retweeted_status'])
	return jsonify(res)