本文整理汇总了Python中tg.lurl函数的典型用法代码示例。如果您正苦于以下问题:Python lurl函数的具体用法?Python lurl怎么用?Python lurl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lurl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deleteProject
def deleteProject(self, came_from=lurl('/'), *args, **kw):
reload(sys).setdefaultencoding("utf-8");
self.success = True;
self.message = "success";
self.df = json.loads(request.body, encoding=request.charset);
self.idProject = self.df.get('id_question_project');
self.listQuestion = model.Question.getByProjectId(self.idProject);
self.listQuestionGroup = model.QuestionGroup.getByProject(self.idProject);
for questionGroup in self.listQuestionGroup:
#remove sur_map_question_group
model.MapQuestionGroup.deleteByQuestionGroup(questionGroup.id_question_group)
#remove question_group
model.QuestionGroup.delete(questionGroup)
del questionGroup
for self.question in self.listQuestion:
if(self.question):
self.idQuestion = self.question.id_question;
model.Question.deleteQuestoin(self.idQuestion);
model.QuestionProject.deleteById(self.idProject);
return dict(success=self.success, message = self.message);
示例2: post_login
def post_login(self, came_from=lurl('/')):
"""
Redirect the user to the initially requested page on successful
authentication or redirect her back to the login page if login failed.
"""
if not request.identity:
login_counter = request.environ.get('repoze.who.logins', 0) + 1
redirect('/login',
params=dict(came_from=came_from, __logins=login_counter))
userid = request.identity['repoze.who.userid']
flash(_('Welcome back, %s!') % userid)
if predicates.has_permission('manage'):
redirect(came_from)
else:
redirect(lurl('/graphs/'))
示例3: index
def index(self, id=0, ready="no", came_from=lurl("/")):
reload(sys).setdefaultencoding("utf8")
if not request.identity:
login_counter = request.environ.get("repoze.who.logins", 0) + 1
redirect("/login", params=dict(came_from=came_from, __logins=login_counter))
userid = request.identity["repoze.who.userid"]
log.info("preview id : " + str(id))
log.info("ready : " + str(ready))
self.header = ""
self.footer = ""
self.nextQuestion = ""
self.template = ""
self.questionOption = model.QuestionOption.getId(id)
if self.questionOption:
log.info("expire date : " + str(self.questionOption.expire_date))
log.info("current : " + str(datetime.now()))
if datetime.now() <= self.questionOption.expire_date:
log.info("not expire")
else:
log.info("expire")
if str(ready).lower() == "no":
# check have welcome page
if not self.utility.isEmpty(self.questionOption.welcome_message):
redirect(request.path_info + "/welcome?id=" + str(self.questionOption.id_question_option))
else:
self.template = self.questionOption.theme.template
override_template(PreviewController.index, self.template)
elif str(ready).lower() == "yes":
self.header = self.questionOption.header_message
self.footer = self.questionOption.footer_message
self.urlName = self.utility.spritValue(request.path_info, "/")
self.template = self.questionOption.theme.template
if len(self.urlName) >= 1:
self.nextQuestion = (
"/" + self.urlName[0] + "/saveQuestion" + "?id=" + str(self.questionOption.id_question_option)
)
if self.template is not None and len(self.template) > 0:
log.info("template used : %s", self.template)
override_template(PreviewController.index, self.template)
# print 'idproject : ', id;
return dict(
page="view",
header=self.header,
footer=self.footer,
action=self.nextQuestion,
template=self.template,
urldata=self.URL_GETDATAQUESTION.format(id),
idproject=id,
shownavigator=bool(self.questionOption.show_navigator),
idresp="",
)
示例4: post_logout
def post_logout(self, came_from=lurl('/')):
"""
Redirect the user to the initially requested page on logout and say
goodbye as well.
"""
flash(_('Successfully logged out. We hope to see you soon!'))
redirect(came_from)
示例5: index_old
def index_old(self, came_from=lurl('/')):
#print request.scheme + '://';
#hooks.notify('tgext.pylogservice.startup' )
#hooks.notify('tgext.pyutilservice.startup')
return dict(page='metronic')
示例6: post_logout
def post_logout(self, came_from=lurl('/'), *args, **kwargs):
"""
Redirect the user to the initially requested page on logout and say
goodbye as well.
"""
flash(_('We hope to see you soon!'))
return HTTPFound(location=str(came_from))
示例7: _default
def _default(self, came_from=lurl('/')):
id = came_from
station_details = self._s.getDetails(id)
#print "ID::" + str(station_details)
return dict(page='station',
d = station_details)
示例8: welcome
def welcome(self, id=0, came_from=lurl("/")):
reload(sys).setdefaultencoding("utf8")
if not request.identity:
login_counter = request.environ.get("repoze.who.logins", 0) + 1
redirect("/login", params=dict(came_from=came_from, __logins=login_counter))
userid = request.identity["repoze.who.userid"]
log.info("preview id : " + str(id))
self.welcome_message = ""
self.questionOption = model.QuestionOption.getId(id)
if self.questionOption:
if datetime.now() <= self.questionOption.expire_date:
log.info("not expire")
else:
log.info("expire")
self.welcome_message = self.questionOption.welcome_message
self.nextQuestion = ""
self.urlName = self.utility.spritValue(request.path_info, "/")
if len(self.urlName) >= 1:
self.nextQuestion = "/" + self.urlName[0] + "?id=" + str(self.questionOption.id_question_option)
return dict(page="view", ready="yes", welcome_message=self.welcome_message, nextQuestion=self.nextQuestion)
示例9: saveQuestion
def saveQuestion(self, id=0, came_from=lurl("/"), *args, **kw):
reload(sys).setdefaultencoding("utf-8")
if not request.identity:
login_counter = request.environ.get("repoze.who.logins", 0) + 1
redirect("/login", params=dict(came_from=came_from, __logins=login_counter))
userid = request.identity["repoze.who.userid"]
self.success = True
self.message = "success"
self.goodbye_message = ""
self.nextQuestion = ""
self.questionOption = model.QuestionOption.getId(id)
if self.questionOption:
self.goodbye_message = self.questionOption.end_message
self.urlRedirect = self.questionOption.redirect_url
return dict(
page="goodbye",
success=self.success,
message=self.message,
goodbye=self.goodbye_message,
nextQuestion=self.nextQuestion,
urlRedirect=self.urlRedirect,
)
示例10: put
def put(self, current_password, new_password1, new_password2):
if not tg.config.get('auth_is_internal'):
raise HTTPForbidden()
# FIXME - Allow only self password or operation for managers
current_user = tmpl_context.current_user
redirect_url = tg.lurl('/home')
if not current_password or not new_password1 or not new_password2:
tg.flash(_('Empty password is not allowed.'))
tg.redirect(redirect_url)
if current_user.validate_password(current_password) is False:
tg.flash(_('The current password you typed is wrong'))
tg.redirect(redirect_url)
if new_password1!=new_password2:
tg.flash(_('New passwords do not match.'))
tg.redirect(redirect_url)
current_user.password = new_password1
pm.DBSession.flush()
tg.flash(_('Your password has been changed'))
tg.redirect(redirect_url)
示例11: login
def login(self, came_from=lurl('/')):
"""Start the user login."""
login_counter = request.environ['repoze.who.logins']
if login_counter > 0:
flash(_('Wrong credentials'), 'warning')
return dict(page='login', login_counter=str(login_counter),
came_from=came_from)
示例12: index
def index(self, came_from=lurl('/'), **kw):
validation_status = request.validation
from formencode import validators
errors = validation_status['errors']
print errors
return dict(page='support', login_counter=str(1),came_from=came_from)
示例13: thankyou
def thankyou(self,key=0,came_from=lurl('/')):
reload(sys).setdefaultencoding("utf-8");
log.info('thankyou preview id : %s' %str(key));
self.isRedirect = True
self.goodbye = '';
self.nextQuestion = '';
self.urlRedirect = '';
self.showScore = False
self.respondents = model.Respondents.getByKey(keyGen=key);
if(self.respondents):
self.urlName = self.utility.spritValue(request.path_info,'/');
log.info( "path %s" %self.urlName)
self.questionOption = self.respondents.question_option
if self.questionOption :
self.goodbye= self.questionOption.end_message
self.showScore = self.utility.convertToBool(self.questionOption.show_score)
self.urlRedirect = self.questionOption.redirect_url
if self.utility.convertToBool(self.respondents.redirect_other_url):
self.urlRedirect = self.questionOption.redirect_other_url
self.isRedirect = False
self.projectType = self.respondents.question_project.id_question_project_type
del self.questionOption
if self.isRedirect :
log.error("find not found respondent with key %s " % str(key));
redirect(self.urlUtility.URL_EXPIRED) ;
return dict(page='goodbye', ready = 'yes',goodbye = Markdown(self.goodbye).convert(),nextQuestion = self.nextQuestion ,urlRedirect= self.urlRedirect,
showScore = self.showScore ,projectType = self.projectType,imageId = self.respondents.id_respondents);
示例14: welcome
def welcome(self,key=0,came_from=lurl('/')):
reload(sys).setdefaultencoding("utf-8");
log.info('preview id : ' + str(key));
self.respondents = model.Respondents.getByKey(key);
#self.idProject,self.idPublic,self.idVoter,self.redirect = self.__checkExpire(id);
if (self.respondents):
self.welcome_message = '';
self.questionOption,self.redirect = self.__checkOptionExpired(self.respondents.id_question_option);
self.welcome_message= self.questionOption.welcome_message;
self.nextQuestion = '';
self.urlName = self.utility.spritValue(request.path_info,'/');
if(len(self.urlName) >= 1 ) :
#self.nextQuestion = '/' + self.urlName[0]+ '?id='+ str(self.questionOption.id_question_option);
#self.nextQuestion = '/' + 'ans/reply/'+ str(self.questionOption.id_question_option);
#self.nextQuestion = self.URL_REPLY.format(id)
self.nextQuestion = self.urlUtility.URL_REPLY_QUESTIONNAIRE.format(key=str(key));
else:
log.error("find not found respondent with key %s ", str(key));
redirect(self.urlUtility.URL_EXPIRED) ;
#self.welcome_message
return dict(page='view', ready = 'yes',welcome_message = Markdown(self.welcome_message).convert(), nextQuestion= self.nextQuestion);
示例15: welcome
def welcome(self,id=0,came_from=lurl('/')):
reload(sys).setdefaultencoding('utf8')
if not request.identity:
login_counter = request.environ.get('repoze.who.logins', 0) + 1
redirect('/login', params=dict(came_from=came_from, __logins=login_counter))
userid = request.identity['repoze.who.userid']
log.info('preview id : ' + str(id));
self.welcome_message = '';
self.questionOption = model.QuestionOption.getId(id);
if self.questionOption :
if datetime.now() <= self.questionOption.expire_date:
log.info('not expire');
else :
log.info('expire');
self.welcome_message= self.questionOption.welcome_message;
self.nextQuestion = '';
self.urlName = self.utility.spritValue(request.path_info,'/');
if(len(self.urlName) >= 1 ) :
self.nextQuestion = '/' + self.urlName[0]+ '?id='+ str(self.questionOption.id_question_option);
return dict(page='view', ready = 'yes',welcome_message = self.welcome_message, nextQuestion= self.nextQuestion);