def main(): """Parse the args and run the server""" if len(sys.argv) == 2 and sys.argv[1].isdigit(): port = sys.argv[1] else: port = 8888 try: run(server="gevent", host="0.0.0.0", port=port, debug=(VERSION != "production")) except: pass finally: print "[MSG] Please wait neo4j to shutdown!" db.shutdown()
def main(): """Parse the args and run the server""" if len(sys.argv) == 2 and sys.argv[1].isdigit(): port = sys.argv[1] else: port = 8888 try: run(server='gevent', host='0.0.0.0', port=port, debug=(VERSION != 'production')) except KeyError: pass finally: print '[MSG] Please wait neo4j to shutdown!' db.shutdown()
def add(username, password, password_confirm, invitation): """ Add a user to neo4j database :rtype: true or false indicates the result of add action Note: Before add there needs a check! """ if not username or not password or not password_confirm: return False, 'The username/password should not be empty!' if password != password_confirm: return False, 'The password you input twice is not the same!' if invitation != INVITATION_CODE: return False, 'The invitation code is invalid!' user_node = user_idx['username'][username].single if user_node: return False, 'The username %s has been used!' % username with db.transaction: user_node = db.node() user_node['name'] = username user_node['username'] = username user_node['password'] = password user_node['gender'] = '' user_node['hometown'] = '' user_idx['username'][username] = user_node user = User.get(username) return True, user
def add(username, text, created_at): """ Add a tweet to neo4j database :rtype: true or false indicates the result of add action Note: Before add there needs a check! """ user_node = user_idx['username'][username].single if not user_node: return False, 'User not found!' if text: with db.transaction: tweet_node = db.node() tweet_node['text'] = text tweet_node['created_at'] = created_at tweet_node.SEND(user_node) tid = tweet_ref['tot_tweet'] tweet_node['tid'] = tid tweet_ref['tot_tweet'] = tweet_ref['tot_tweet'] + 1 tweet_idx['tid'][tid] = tweet_node return True, '' else: return False, 'Tweet should not be empty!'
def add(username, password, password_confirm, invitation): """ Add a user to neo4j database :rtype: true or false indicates the result of add action Note: Before add there needs a check! """ if not username: return False, "The username should not be empty!" if not password: return False, "The password should not be empty!" if not password_confirm: return False, "The password for confirmation should not be empty!" if password != password_confirm: return False, "The password you input twice is not the same!" if invitation != INVITATION_CODE: return False, "The invitation code is invalid!" user_node = user_idx["username"][username].single if user_node: return False, "The username %s has been used!" % username user = User(username, password) with db.transaction: user_node = db.node() user_node["username"] = user.username user_node["password"] = user.password user_node["avatar"] = user.avatar user_idx["username"][username] = user_node return True, ""
def add(username, text, created_at): """ Add a tweet to neo4j database :rtype: true or false indicates the result of add action Note: Before add there needs a check! """ # NOTE(huxuan): If tid is needed we should manually generate it if text: with db.transaction: tweet_node = db.node() tweet_node["username"] = username tweet_node["text"] = text tweet_node["created_at"] = created_at user_node = user_idx["username"][username].single tweet_node.SEND(user_node) return True, "" else: return False, "Tweet should not be empty!"
def add(username, text, created_at): """ Add a tweet to neo4j database :rtype: true or false indicates the result of add action Note: Before add there needs a check! """ # NOTE(huxuan): If tid is needed we should manually generate it if text: with db.transaction: tweet_node = db.node() tweet_node['username'] = username tweet_node['text'] = text tweet_node['created_at'] = created_at user_node = user_idx['username'][username].single tweet_node.SEND(user_node) return True, '' else: return False, 'Tweet should not be empty!'