本文整理汇总了Python中micropsi_server.bottle.template函数的典型用法代码示例。如果您正苦于以下问题:Python template函数的具体用法?Python template怎么用?Python template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: login_submit
def login_submit():
params = dict((key, request.forms.getunicode(key)) for key in request.forms)
user_id = params['userid']
password = params['password']
# log in new user
token = usermanager.start_session(user_id, password, params.get("keep_logged_in"))
if token:
response.set_cookie("token", token)
# redirect to start page
return dict(redirect="/")
else:
# login failed, retry
if user_id in usermanager.users:
return template("login", version=VERSION, userid=user_id, password=password,
title="Log in to the %s server" % APPTITLE,
password_error="Re-enter the password",
login_error="User name and password do not match",
cookie_warning=(token is None),
permissions=usermanager.get_permissions_for_session_token(token))
else:
return template("login", version=VERSION, userid=user_id, password=password,
title="Log in to the %s server" % APPTITLE,
userid_error="Re-enter the user name",
login_error="User unknown",
cookie_warning=(token is None),
permissions=usermanager.get_permissions_for_session_token(token))
开发者ID:joschabach,项目名称:micropsi2,代码行数:26,代码来源:micropsi_app.py
示例2: _add_world_list
def _add_world_list(template_name, **params):
worlds = runtime.get_available_worlds()
if request.query.get('select_world') and request.query.get('select_world') in worlds:
current_world = request.query.get('select_world')
response.set_cookie('selected_world', current_world)
else:
current_world = request.get_cookie('selected_world')
world_type = ""
world_assets = {}
world_template = ""
if current_world:
world_obj = runtime.load_world(current_world)
world_type = world_obj.__class__.__name__
if hasattr(world_obj, 'assets'):
world_assets = world_obj.assets
if 'template' in world_assets:
import inspect
basedir = os.path.dirname(inspect.getfile(world_obj.__class__))
with open(os.path.join(basedir, world_assets['template'])) as fp:
world_template = template(fp.read(), world_assets=world_assets)
return template(template_name, current=current_world,
mine=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].get('owner') == params['user_id']),
others=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].get('owner') != params['user_id']),
world_type=world_type,
world_assets=world_assets,
world_template=world_template,
**params)
开发者ID:Doik,项目名称:micropsi2,代码行数:27,代码来源:micropsi_app.py
示例3: user_mgt
def user_mgt():
user_id, permissions, token = get_request_data()
if "manage users" in permissions:
return template("user_mgt", version=VERSION, permissions=permissions,
user_id=user_id,
userlist=usermanager.list_users())
return template("error", msg="Insufficient rights to access user console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例4: set_password
def set_password(userid):
user_id, permissions, token = get_request_data()
if "manage users" in permissions:
return template("set_password", version=VERSION, permissions=permissions,
title="Change Password",
user_id=user_id,
userid=userid)
return template("error", msg="Insufficient rights to access user console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:8,代码来源:micropsi_app.py
示例5: login_as_user
def login_as_user(userid):
user_id, permissions, token = get_request_data()
if "manage users" in permissions:
if userid in usermanager.users:
if usermanager.switch_user_for_session_token(userid, token):
# redirect to start page
redirect("/")
return template("error", msg="Could not log in as new user")
return template("error", msg="User does not exist")
return template("error", msg="Insufficient rights to access user console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:10,代码来源:micropsi_app.py
示例6: login
def login():
if not usermanager.users: # create first user
return template("signup", version=VERSION, first_user=True, userid="admin",
title="Create the administrator for the %s server" % APPTITLE)
return template("login",
title="Log in to the %s server" % APPTITLE,
version=VERSION,
user_id=usermanager.get_user_id_for_session_token(None),
permissions=usermanager.get_permissions_for_session_token(None))
开发者ID:joschabach,项目名称:micropsi2,代码行数:10,代码来源:micropsi_app.py
示例7: nodenet_mgt
def nodenet_mgt():
user_id, permissions, token = get_request_data()
if "manage nodenets" in permissions:
notification = None
if request.get_cookie('notification'):
notification = json.loads(request.get_cookie('notification'))
response.set_cookie('notification', '', path='/')
return template("nodenet_mgt", version=VERSION, permissions=permissions,
user_id=user_id,
nodenet_list=runtime.get_available_nodenets(), notification=notification)
return template("error", msg="Insufficient rights to access nodenet console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:11,代码来源:micropsi_app.py
示例8: signup
def signup():
if request.get_cookie("token"):
token = request.get_cookie("token")
else:
token = None
if not usermanager.users: # create first user
return template("signup", version=VERSION,
title="Create the administrator for the %s server" % APPTITLE,
first_user=True, cookie_warning=(token is None))
return template("signup", version=VERSION,
title="Create a new user for the %s server" % APPTITLE,
permissions=usermanager.get_permissions_for_session_token(token),
cookie_warning=(token is None))
开发者ID:hyperdrive,项目名称:micropsi2,代码行数:15,代码来源:micropsi_app.py
示例9: edit_runner_properties
def edit_runner_properties():
user_id, permissions, token = get_request_data()
if len(request.params) > 0:
runtime.set_runner_properties(int(request.params['timestep']), int(request.params['factor']))
return dict(status="success", msg="Settings saved")
else:
return template("runner_form", action="/config/runner", value=runtime.get_runner_properties())
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例10: create_user_submit
def create_user_submit():
params = dict((key, request.forms.getunicode(key)) for key in request.forms)
user_id, permissions, token = get_request_data()
userid = params['userid']
password = params['password']
role = params.get('permissions')
(success, result) = micropsi_core.tools.check_for_url_proof_id(userid, existing_ids=usermanager.users.keys())
if success:
# check if permissions in form are consistent with internal permissions
if ((role == "Administrator" and ("create admin" in permissions or not usermanager.users)) or
(role == "Full" and "create full" in permissions) or
(role == "Restricted" and "create restricted" in permissions)):
if usermanager.create_user(userid, password, role, uid=micropsi_core.tools.generate_uid()):
if request.is_xhr:
return dict(status="OK", redirect='/user_mgt')
else:
redirect('/user_mgt')
else:
return dict(status="error", msg="User creation failed for an obscure internal reason.")
else:
return dict(status="error", msg="Permission inconsistency during user creation.")
else:
# something wrong with the user id, retry
return template("create_user", version=VERSION, user_id=user_id,
title="Create a user for the %s server" % APPTITLE,
permissions=permissions, userid_error=result)
return dict(status="error", msg="Insufficient rights to access user console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:28,代码来源:micropsi_app.py
示例11: merge_nodenet_form
def merge_nodenet_form(nodenet_uid):
token = request.get_cookie("token")
return template("upload.tpl", title='Merge Nodenet', message='Select a file to upload and use for merging',
action='/nodenet/merge/%s' % nodenet_uid,
version=VERSION,
userid=usermanager.get_user_id_for_session_token(token),
permissions=usermanager.get_permissions_for_session_token(token))
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例12: select_nodenet_from_console
def select_nodenet_from_console(nodenet_uid):
user_id, permissions, token = get_request_data()
result, uid = runtime.load_nodenet(nodenet_uid)
if not result:
return template("error", msg="Could not select nodenet")
response.set_cookie("selected_nodenet", nodenet_uid + "/", path="/")
redirect("/")
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例13: delete_user
def delete_user(userid):
user_id, permissions, token = get_request_data()
if "manage users" in permissions:
if userid in usermanager.users:
usermanager.delete_user(userid)
redirect("/user_mgt")
return template("error", msg="Insufficient rights to access user console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例14: delete_nodenet_from_console
def delete_nodenet_from_console(nodenet_uid):
user_id, permissions, token = get_request_data()
if "manage nodenets" in permissions:
runtime.delete_nodenet(nodenet_uid)
response.set_cookie('notification', '{"msg":"Nodenet deleted", "status":"success"}', path='/')
redirect('/nodenet_mgt')
return template("error", msg="Insufficient rights to access nodenet console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例15: set_permissions
def set_permissions(user_key, role):
user_id, permissions, token = get_request_data()
if "manage users" in permissions:
if user_key in usermanager.users and role in usermanagement.USER_ROLES:
usermanager.set_user_role(user_key, role)
redirect('/user_mgt')
return template("error", msg="Insufficient rights to access user console")
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例16: nodenet_list
def nodenet_list(current_nodenet=None):
user_id, permissions, token = get_request_data()
nodenets = runtime.get_available_nodenets()
return template("nodenet_list", type="nodenet", user_id=user_id,
current=current_nodenet,
mine=dict((uid, nodenets[uid]) for uid in nodenets if nodenets[uid].owner == user_id),
others=dict((uid, nodenets[uid]) for uid in nodenets if nodenets[uid].owner != user_id))
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例17: import_world_form
def import_world_form():
token = request.get_cookie("token")
return template("upload.tpl", title='World import', message='Select a file to upload and use for importing',
action='/world/import',
version=VERSION,
user_id=usermanager.get_user_id_for_session_token(token),
permissions=usermanager.get_permissions_for_session_token(token))
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例18: edit_worldrunner
def edit_worldrunner():
user_id, permissions, token = get_request_data()
if len(request.params) > 0:
runtime.set_worldrunner_timestep(int(request.params['runner_timestep']))
return dict(status="success", msg="Timestep saved")
else:
return template("runner_form", mode="world", action="/config/world/runner", value=runtime.get_worldrunner_timestep())
开发者ID:conorshankey,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
示例19: signup_submit
def signup_submit():
params = dict((key, request.forms.getunicode(key)) for key in request.forms)
user_id, permissions, token = get_request_data()
userid = params['userid']
password = params['password']
role = params.get('permissions')
firstuser = not usermanager.users
(success, result) = micropsi_core.tools.check_for_url_proof_id(userid, existing_ids=usermanager.users.keys())
if success:
# check if permissions in form are consistent with internal permissions
if ((role == "Administrator" and ("create admin" in permissions or not usermanager.users)) or
(role == "Full" and "create full" in permissions) or
(role == "Restricted" and "create restricted" in permissions)):
if usermanager.create_user(userid, password, role, uid=micropsi_core.tools.generate_uid()):
# log in new user
token = usermanager.start_session(userid, password, params.get("keep_logged_in"))
response.set_cookie("token", token)
# redirect to start page
return dict(redirect='/')
else:
return dict(status="error", msg="User creation failed for an obscure internal reason.")
else:
return dict(status="error", msg="Permission inconsistency during user creation.")
else:
# something wrong with the user id, retry
return template("signup", version=VERSION, userid=userid, password=password, userid_error=result,
title="Create a new user for the %s server" % APPTITLE, first_user=firstuser,
user_id=user_id, permissions=permissions, cookie_warning=(token is None))
开发者ID:joschabach,项目名称:micropsi2,代码行数:28,代码来源:micropsi_app.py
示例20: world_list
def world_list(current_world=None):
user_id, permissions, token = get_request_data()
worlds = runtime.get_available_worlds()
return template("nodenet_list", type="world", user_id=user_id,
current=current_world,
mine=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].owner == user_id),
others=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].owner != user_id))
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py
注:本文中的micropsi_server.bottle.template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论