本文整理汇总了Python中tg.controllers.redirect函数的典型用法代码示例。如果您正苦于以下问题:Python redirect函数的具体用法?Python redirect怎么用?Python redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redirect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self, residence, member_uid, mac):
residence_dn = Residences.get_dn_by_name(self.user, residence)
# Récupération du membre et de la machine
# Note : on cherche la machine seulement sur le membre (member.dn)
member = Member.get_by_uid(self.user, residence_dn, member_uid)
if member is None:
raise Exception("membre inconnu")
# end if
machine = Machine.get_dhcp_by_mac(self.user, member.dn, mac)
if machine is None:
raise Exception("machine inconnue")
# end if
machine_membre_tag = "machine_membre" # FIXME move to config
machine_membre_disabled = machine_membre_tag + "_disabled" # FIXME move to config
if machine.uid.first() == machine_membre_disabled:
machine.uid.replace(machine_membre_disabled, machine_membre_tag)
self.user.ldap_bind.save(machine)
# end if
BrieLogging.get().info("enable member " + member_uid + " machine " + mac + " by " + self.user.attrs.dn)
# On redirige sur la page d'édition du membre
redirect("/edit/member/" + residence + "/" + member_uid)
开发者ID:Rbeuque74,项目名称:brie-aurore,代码行数:27,代码来源:edit.py
示例2: mac
def mac(self, residence, mac):
residence_dn = Residences.get_dn_by_name(self.user, residence)
machine = Machine.get_dhcp_by_mac(self.user, residence_dn, mac)
if machine is None:
return self.error_no_entry()
machine = machine.dn.split(',')
i = 0
member_dn = ""
for sub in machine:
if i >= 3:
if member_dn != "":
member_dn += ","
#end if
member_dn += sub
#end if
i += 1
#end for
member = Member.get_by_dn(self.user, member_dn)
if member is None:
return self.error_no_entry()
#end if
redirect("/show/member/"+ residence +"/" + member.uid.first())
开发者ID:Rbeuque74,项目名称:brie-aurore,代码行数:28,代码来源:search.py
示例3: edit
def edit(self, track_id, **kw):
user = handler.user.get_user_in_session(request)
if track_id is not None:
if not checker.can_edit_track(user, track_id):
flash("You haven't the right to edit any tracks which is not yours", 'error')
raise redirect('/tracks')
widget = form.EditTrack(action=url('/tracks/edit/%s' % track_id)).req()
track = DBSession.query(Track).filter(Track.id == track_id).first()
d = {}
d['name'] = track.name
if track.parameters is None or not 'color' in track.parameters:
cc = constants.default_track_color
else:
cc = track.parameters['color']
d['track_id'] = track_id
d['color'] = cc
if 'pid' in kw:
d['pid'] = kw['pid']
widget.value = d
if request.method == 'GET':
return dict(title='Edit track', page='track', widget=widget, color=cc)
if request.method == 'POST':
try:
widget.validate(kw)
except twc.ValidationError as e:
return dict(title='Edit track', page='track', widget=e.widget, color=cc)
handler.track.edit(track=track, name=kw.get('name', None), color=kw.get('color', None))
raise redirect('/tracks', {'pid': kw.get('pid', None)})
开发者ID:bbcf,项目名称:pygdv,代码行数:32,代码来源:track.py
示例4: https
def https(remainder, params):
"""Ensure that the decorated method is always called with https."""
from tg.controllers import redirect
if request.scheme.lower() == 'https': return
if request.method.upper() == 'GET':
redirect('https' + request.url[len(request.scheme):])
raise HTTPMethodNotAllowed(headers=dict(Allow='GET')).exception
开发者ID:chiehwen,项目名称:tg2,代码行数:7,代码来源:decorators.py
示例5: edit
def edit(self, *args, **kw):
user = handler.user.get_user_in_session(request)
if request.method == 'GET':
project_id = args[0]
else:
project_id = kw.get('pid')
debug("check permission", 1)
if not checker.check_permission(user=user, project_id=project_id, right_id=constants.right_upload_id) and not checker.is_admin(user=user):
flash('You must have %s permission to edit the project.' % constants.right_upload, 'error')
raise redirect('/tracks/', {'pid': project_id})
#if checker.is_admin(user=user):
#user = DBSession.query(User).join(Project).filter(Project.id == project_id).first()
widget = form.EditProject(action=url('/projects/edit/%s' % project_id)).req()
widget.value = {'pid': project_id}
project = DBSession.query(Project).filter(Project.id == project_id).first()
# prendre les user tracks du meme sequence id
tracks = DBSession.query(Track).join(User.tracks).filter(
and_(User.id == user.id, Track.sequence_id == project.sequence_id,
not_(Track.id.in_([t.id for t in project.tracks])))
).all()
# prendre les sared tracks du meme sequence id
shared_tracks = handler.user.shared_tracks(user.id, constants.rights['download']['id'])
shared_tracks = [t for t in shared_tracks if (t.sequence_id == project.sequence_id and t.id not in [tr.id for tr in project.tracks])]
tracks.extend(shared_tracks)
if request.method == 'GET':
debug("GET", 2)
widget.child.children[1].value = project.name
widget.child.children[2].options = [('', '')] + [(t.id, t.name) for t in tracks] + [(t.id, t.name, {'selected': True}) for t in project.tracks]
return dict(page='tracks', widget=widget, project_id=project_id)
debug("POST", 2)
try:
debug("validate post", 2)
widget.validate(kw)
except twc.ValidationError as e:
debug("error", 2)
w = e.widget
w.child.children[1].value = project.name
w.child.children[2].options = [(t.id, t.name) for t in tracks] + [(t.id, t.name, {'selected': True}) for t in project.tracks]
return dict(page='tracks', widget=w, project_id=project_id)
debug("validation passed")
track_ids = kw.get('tracks', [])
if not track_ids:
track_ids = []
if not isinstance(track_ids, list):
track_ids = [track_ids]
if len(track_ids) > 0 and '' in track_ids:
track_ids.remove('')
# if the project is shared, some track cannot be removed
for t in project.tracks:
if not checker.user_own_track(user.id, track=t) and t.id not in track_ids and t.id in [s.id for s in shared_tracks]:
track_ids.append(t.id)
handler.project.e(project_id=project_id, name=kw.get('name'), track_ids=track_ids)
raise redirect('/tracks/', {'pid': project_id})
开发者ID:bbcf,项目名称:pygdv,代码行数:60,代码来源:project.py
示例6: post
def post(self, residence, member_uid):
residence_dn = Residences.get_dn_by_name(self.user, residence)
member = Member.get_by_uid(self.user, residence_dn, member_uid)
if member is None:
raise Exception("invalid member uid")
wifi = WifiModel.get_by_member_dn(self.user, member.dn)
password = Passwords.generate_password_admin()
if wifi is None:
wifi_dn = "cn=wifi," + member.dn
wifi_attr = WifiModel.entry_attr(password)
self.user.ldap_bind.add_entry(wifi_dn, wifi_attr)
else:
wifi.userPassword.replace(wifi.userPassword.first(), password)
self.user.ldap_bind.save(wifi)
#end
# Envoi du mail
from_address = [u'Fédération Aurore', '[email protected]']
recipient = [member.cn.first(), member.mail.first()]
subject = u'['+ residence +'] votre mot de passe WiFi'
text = u'Bonjour,\n\nVous venez de vous inscrire au sein d\'une résidence de la fédération Aurore\nUn mot de passe pour utiliser la connexion WiFi de la résidence vous a été assigné.\n\nUtilisateur: '+ member_uid +'\nMot de passe: '+ password +u'\n\nCordialement,\nla fédération Aurore'
SmtpHelper.send_email(from_address, recipient, subject, text)
redirect("/show/member/" + residence + "/" + member_uid)
开发者ID:Rbeuque74,项目名称:brie-aurore,代码行数:28,代码来源:controller.py
示例7: with_trailing_slash
def with_trailing_slash(remainder, params):
"""This decorator allows you to ensure that the URL ends in "/".
The decorator accomplish this by redirecting to the correct URL.
:Usage:
You use this decorator as follows::
class MyController(object):
@with_trailing_slash
@expose()
def sample(self, *args):
return "found sample"
In the above example http://localhost:8080/sample redirects to http://localhost:8080/sample/
In addition, the URL http://localhost:8080/sample/1 redirects to http://localhost:8080/sample/1/
"""
if (request.method == 'GET'
and not(request.path.endswith('/'))
and not(request.response_type)
and len(request.params)==0):
from tg.controllers import redirect
redirect(request.url+'/')
开发者ID:chiehwen,项目名称:tg2,代码行数:26,代码来源:decorators.py
示例8: new
def new(self, id_fase, method='', **kw):
"""Metodo que trae el formulario para crear un item nuevo"""
identity = request.environ.get('repoze.who.identity')
if identity is not None:
user = identity.get('user')
idi = user.id_usuario
rol_lider = DBSession.query(RolUsuario).filter(RolUsuario.id_usuario==idi).\
filter(Rol.group_name=="lider").filter(Rol.id_rol == RolUsuario.id_rol).all()
if(len(rol_lider)==0):
crear = DBSession.query(Usperfa).filter(Usperfa.id_fase==id_fase).\
filter(Permiso.permission_name=="crear_item").\
filter(Usperfa.id_permiso==Permiso.id_permiso).\
filter(RolUsuario.id_usuario==idi).all()
if len(crear)==0:
flash("No posee los permisos para crear item en la fase",'error')
redirect("/desarrollo/item/error")
else:
new_item_form.tipo_item.id_fase = id_fase
tmpl_context.widget = new_item_form
else:
new_item_form.tipo_item.id_fase = id_fase
tmpl_context.widget = new_item_form
return dict(id_fase = id_fase, value=kw)
开发者ID:majito,项目名称:is2grupo06,代码行数:25,代码来源:item.py
示例9: list
def list(self, id_fase):
"""Metodo invocado para listar los items de una fase especificada"""
self.id_fase = id_fase
identity = request.environ.get('repoze.who.identity')
if identity is not None:
user = identity.get('user')
idi = user.id_usuario
fase = DBSession.query(Fase).get(id_fase)
id_proy = fase.id_proyecto
proyecto = DBSession.query(Proyecto).get(id_proy)
rol_lider = DBSession.query(RolUsuario).filter(RolUsuario.id_usuario==idi).\
filter(Rol.group_name=="lider").filter(Rol.id_rol == RolUsuario.id_rol).all()
if(len(rol_lider)==0):
list = DBSession.query(Roperpro).filter(Roperpro.id_proyecto==id_proy).\
filter(Permiso.permission_name=="ver_fase").\
filter(Roperpro.id_permiso==Permiso.id_permiso).\
filter(RolUsuario.id_usuario==idi).\
filter(Roperpro.id_rol==RolUsuario.id_rol).all()
if len(list)==0:
flash("No posee el permiso para ver los items de la fase",'error')
redirect("/desarrollo/item/error")
else:
fase = DBSession.query(Fase).get(id_fase)
tmpl_context.widget = list_item
value = list_item_filler.get_value(id_fase=id_fase)
else:
fase = DBSession.query(Fase).get(id_fase)
tmpl_context.widget = list_item
value = list_item_filler.get_value(id_fase=id_fase)
return dict(fase=fase, proyecto = proyecto, value=value)
开发者ID:majito,项目名称:is2grupo06,代码行数:34,代码来源:item.py
示例10: post
def post(self, residence, username, password):
anon_user = current.get_anon_user()
residence_dn = Residences.get_dn_by_name(anon_user, residence)
residences = Residences.get_residences(anon_user)
if residence_dn is None:
return dict(
residences = residences,
login = username,
residence = residence,
error = u"erreur de résidence"
)
#end if
success = current.login(residence_dn, username, password)
if success:
redirect("/")
#end if
return dict(
residences = residences,
login = username,
residence = residence,
error = "erreur de connexion"
)
开发者ID:Rbeuque74,项目名称:brie-aurore,代码行数:28,代码来源:auth.py
示例11: new
def new(self, id_fase, method='', **kw):
identity = request.environ.get('repoze.who.identity')
if identity is not None:
user = identity.get('user')
idi = user.id_usuario
rol_lider = DBSession.query(RolUsuario).filter(RolUsuario.id_usuario==idi).\
filter(Rol.group_name=="lider").filter(Rol.id_rol == RolUsuario.id_rol).all()
if(len(rol_lider)==0):
crear = DBSession.query(Usperfa).filter(Usperfa.id_fase==id_fase).\
filter(Permiso.permission_name=="crear_linea_base").\
filter(Usperfa.id_permiso==Permiso.id_permiso).\
filter(RolUsuario.id_usuario==idi).all()
if len(crear)==0:
flash("No posee los permisos para crear linea base",'error')
redirect("/configuracion/linea_base/error")
else:
ItemsFieldSelect.id_fase = id_fase
new_lineabase_form = NewLineaBaseForm(DBSession)#new_lineabase_form
tmpl_context.widget = new_lineabase_form
else:
ItemsFieldSelect.id_fase = id_fase
new_lineabase_form = NewLineaBaseForm(DBSession)#new_lineabase_form
tmpl_context.widget = new_lineabase_form
return dict(value=kw)
开发者ID:majito,项目名称:is2grupo06,代码行数:27,代码来源:linea_base.py
示例12: get_user_or_redirect
def get_user_or_redirect(self):
maybe_user = self.get_user()
if maybe_user is None:
redirect("/auth/login/") # TODO from config
#end if
return maybe_user
开发者ID:Rbeuque74,项目名称:brie-aurore,代码行数:7,代码来源:auth.py
示例13: index
def index(self):
'''
Redirect user on tequila page in order to log him
'''
u = resolve_relative_url(url(), request.environ)
res = tequila.create_request(u+'/login/auth','tequila.epfl.ch')
redirect('https://tequila.epfl.ch/cgi-bin/tequila/requestauth?request'+res)
开发者ID:bbcf,项目名称:turbotequila,代码行数:7,代码来源:login.py
示例14: list
def list(self, id_fase):
identity = request.environ.get('repoze.who.identity')
if identity is not None:
user = identity.get('user')
idi = user.id_usuario
rol_lider = DBSession.query(RolUsuario).filter(RolUsuario.id_usuario==idi).\
filter(Rol.group_name=="lider").filter(Rol.id_rol == RolUsuario.id_rol).all()
if(len(rol_lider)==0):
listar = DBSession.query(Usperfa).filter(Usperfa.id_fase==id_fase).\
filter(Permiso.permission_name=="ver_linea_base").\
filter(Usperfa.id_permiso==Permiso.id_permiso).\
filter(RolUsuario.id_usuario==idi).all()
if (len(listar)==0):
flash("No posee los permisos para ver las lineas bases",'error')
redirect("/configuracion/linea_base/error")
else:
self.id_fase = id_fase
fase = DBSession.query(Fase).get(id_fase)
tmpl_context.widget = list_lineabase
value = list_lineabase_filler.get_value(id_fase=id_fase)
else:
self.id_fase = id_fase
fase = DBSession.query(Fase).get(id_fase)
tmpl_context.widget = list_lineabase
value = list_lineabase_filler.get_value(id_fase=id_fase)
return dict(fase=fase, value=value)
开发者ID:majito,项目名称:is2grupo06,代码行数:29,代码来源:linea_base.py
示例15: put
def put(self, id='', **kw):
del kw['sprox_id']
detalletipoitem = DBSession.query(DetalleTipoItem).get(int(id))
detalletipoitem.nombre_atributo = kw['nombre_atributo']
detalletipoitem.tipo_dato = kw['tipo_dato']
DBSession.merge(detalletipoitem)
flash('Detalle de Tipo de item modificado')
redirect("/desarrollo/detalle_tipo_item/list")
开发者ID:majito,项目名称:is2grupo06,代码行数:8,代码来源:detalle_tipo_item.py
示例16: put
def put(self, id='', **kw):
del kw['sprox_id']
relacion = DBSession.query(Relacion).get(int(id))
relacion.descripcion = kw['descripcion']
relacion.tiporelacion = kw['tiporelacion']
DBSession.merge(relacion)
flash('Relacion modificada')
redirect("/desarrollo/relacion/list")
开发者ID:majito,项目名称:is2grupo06,代码行数:8,代码来源:relacion.py
示例17: put
def put(self, _method='', id=0, **kw):
del kw['sprox_id']
tipoitem = DBSession.query(TipoItem).get(int(id))
tipoitem.nombre_tipoitem = kw['nombre_tipoitem']
tipoitem.descripcion = kw['descripcion']
DBSession.merge(tipoitem)
flash('Tipo de Item modificado')
redirect("/desarrollo/tipo_item/list")
开发者ID:majito,项目名称:is2grupo06,代码行数:8,代码来源:tipo_item.py
示例18: delete
def delete(self, circle_id, *args, **kw):
user = handler.user.get_user_in_session(request)
if not checker.user_own_circle(user.id, circle_id):
flash('you have no right to delete this circle: you are not the creator of it')
raise redirect('/circles')
circle = DBSession.query(Circle).filter(Circle.id == circle_id).first()
DBSession.delete(circle)
DBSession.flush()
raise redirect('/circles/')
开发者ID:bbcf,项目名称:pygdv,代码行数:9,代码来源:circle.py
示例19: out
def out(self):
'''
Logout the user.
'''
environ = request.environ
authentication_plugins = environ['repoze.who.plugins']
identifier = authentication_plugins['ticket']
cookiename = identifier.cookie_name
response.delete_cookie(cookiename)
redirect('/')
开发者ID:bbcf,项目名称:turbotequila,代码行数:10,代码来源:login.py
示例20: post_delete
def post_delete(self, *args, **kw):
for id in args :
permission = DBSession.query(Permission).filter(Permission.id == id).first()
if permission.id == constants.permission_admin_name:
flash('Cannot delete admin permission', 'error')
redirect('/permissions')
if permission.name == constants.permissions_read_name:
flash('Cannot delete read permission', 'error')
redirect('/permissions')
return CrudRestController.post_delete(self, *args, **kw)
开发者ID:bbcf,项目名称:turbotequila,代码行数:10,代码来源:permission.py
注:本文中的tg.controllers.redirect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论