本文整理汇总了Python中dao.Dao.create_region方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.create_region方法的具体用法?Python Dao.create_region怎么用?Python Dao.create_region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.create_region方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import create_region [as 别名]
def put(self):
dao = Dao(None, mongo_client=mongo_client)
if not dao:
return 'Dao not found', 404
user = get_user_from_request(request, dao)
if not user:
return 'Permission denied', 403
#if not is_user_admin_for_region(user, region='*'):
# return 'Permission denied', 403
args = admin_functions_parser.parse_args()
function_type = args['function_type']
if function_type == 'region':
region_name = args['new_region']
#Execute region addition
config = Config()
if dao.create_region(region_name):
print("region created:" + region_name)
elif function_type == 'user':
uname = args['new_user_name']
upass = args['new_user_pass']
uperm = args['new_user_permissions']
uregions = args['new_user_regions']
#Execute user addition
dao = Dao(None, mongo_client)
if dao.create_user(uname, upass, uregions):
print("user created:" + uname)
示例2: len
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import create_region [as 别名]
import os
import sys
from pymongo import MongoClient
# add root directory to python path
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/../'))
from config.config import Config
from dao import Dao
# script to create new user in db
if __name__ == "__main__":
if len(sys.argv) < 2:
print "incorrect number of arguments!"
print "usage: python create_region.py region_name"
sys.exit()
region_name = sys.argv[1]
config = Config()
mongo_client = MongoClient(host=config.get_mongo_url())
dao = Dao(None, mongo_client)
if dao.create_region(region_name):
print "region created:", region_name