import sys sys.path.append('/home/oem/dev/log_server') from publics import db, set_db from bson import ObjectId set_db('ldb') col_users_roles = db()['users_roles'] col_users_roles.drop() col_users_roles.insert_many([ { "_id": ObjectId("5e25ab698c90582c5785d291"), 'name': 'admin', 'module': 'users', 'permissions': { 'allow': ['get'], }, }, { 'name': 'user', 'module': 'profile', 'permissions': { 'allow': ['get', 'put'], 'get': { 'user_id': '$uid' }, 'put': { 'query': { 'user_id': '$uid' }, 'set': {} },
from publics import db, set_db set_db('rest') col_users_roles = db()['users_roles'] col_users_roles.drop() col_users_roles.insert_many([ { 'name': 'admin', 'module': 'users', 'permissions': { 'allow': ['get'], 'get': {} }, }, { 'name': 'user', 'module': 'profile', 'permissions': { 'allow': ['get', 'put'], 'get': { 'user_id': '$uid' }, 'put': { 'query': { 'user_id': '$uid' }, 'set': {} }, }, }, ])
import tornado.httpserver import tornado.options from urls import url_patterns from publics import set_db, consts import socket hostname = socket.gethostname() IPAddr = socket.gethostbyname(hostname) if __name__ == "__main__": tornado.options.parse_command_line() app = tornado.web.Application(url_patterns) if len(sys.argv) > 1: if sys.argv[1] == 'test': print( 'Application is running on Test mode on %s:%s database name is %s...' % (IPAddr, consts.TEST_SERVER_PORT, consts.TEST_DB_NAME)) consts.TEST_MODE = True set_db(consts.TEST_DB_NAME) app.listen(int(consts.TEST_SERVER_PORT)) else: print('Wrong input') exit() else: print('Application is running mode on %s:%s database name is %s...' % (IPAddr, consts.SERVER_PORT, consts.DB_NAME)) https_app = tornado.httpserver.HTTPServer(app) set_db(consts.DB_NAME) app.listen(int(consts.SERVER_PORT)) tornado.ioloop.IOLoop.current().start()
import sys sys.path.append('/home/oem/dev/wunderlist') sys.path.append('/root/dev/wunderlist') from publics import db, create_md5, set_db from bson import ObjectId set_db('wunderlist') def insert_users(): col_users = db()['users'] # col_users.drop() if col_users.count_documents({'mobile': 'admin'}) == 0: col_users.insert_one({ "_id": ObjectId("5e25ab698c90582c5785d291"), 'name': 'shahab', 'family': 'qazavi', 'mobile': 'admin', 'password': create_md5('1'), 'role': 'admin', 'confirmed': True }) def insert_messages(): col_server_messages = db()['server_messages'] col_server_messages.drop() col_server_messages.insert_many([ { 'group': 'user', 'name': 'token_not_received', 'code': 401,