本文整理汇总了Python中WebTemplates.WebTemplates.commonInfo方法的典型用法代码示例。如果您正苦于以下问题:Python WebTemplates.commonInfo方法的具体用法?Python WebTemplates.commonInfo怎么用?Python WebTemplates.commonInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebTemplates.WebTemplates
的用法示例。
在下文中一共展示了WebTemplates.commonInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WebRoot
# 需要导入模块: from WebTemplates import WebTemplates [as 别名]
# 或者: from WebTemplates.WebTemplates import commonInfo [as 别名]
class WebRoot(Resource):
#def __init__(self, users, openRooms, shouldBeOpenRooms):
def __init__(self, server):
Resource.__init__(self)
self.db = DBConnect()
self.template = WebTemplates()
self.putChild("roominfo", WebRoomInfo(server))
self.putChild("userinfo", WebUserInfo())
self.putChild("login", WebLogin())
self.putChild("logout", WebLogout())
self.putChild("static", static.File("./htdocs/"))
self.putChild("board_archive", static.File("./archive/"))
self.putChild("content", WebContent())
self.putChild("calendar", static.File("./calendar/"))
self.putChild("subjects", WebSubjects())
self.putChild("settings", WebSettings())
self.putChild("subject_admin", WebSubjectAdmin())
self.putChild("schedules", WebSchedules())
self.putChild("admin", WebAdmin())
self.putChild("archive", WebArchive())
self.putChild("list", WebListUsers())
self.putChild("tutor", WebTutor())
self.putChild("tutor_info", WebTutorInfo())
self.putChild("tutor_data", WebTutorData())
self.putChild("tutor_sessions", WebTutorSessions())
self.putChild("client", WebClient())
self.putChild("report", WebClientReport())
self.putChild("mail", WebSendMail())
self.putChild("my_pupils", WebMyPupils())
self.putChild("my_pupils_info", WebMyPupilsInfo())
self.putChild("pupil_edit", WebPupilEdit())
self.putChild("new_pupil", WebPupilInsert())
self.putChild("pc_arrange", WebPCArrangeRoot())
self.putChild("editadmin", WebEditAdmin())
def getChild(self, path, request):
if path in ('', 'index.html', 'index'):
return self
else:
return static.File.childNotFound
def render_GET(self, request):
#verifico el parametro get por si hay que borrar una clase.
keys = request.args.keys()
if "del" in keys:
d = defer.maybeDeferred(lambda: None)
alumno = request.getSession().userId
erase = DBDelete(self.db)
clase = int(request.args['del'][0])
d.addCallback(lambda a: erase.deletePA(clase, alumno)) #borramos la cosa.
#falta imprimir mensaje de operacion correcta
#como llego a la funcion de internacionalizacion?
#d.addCallback(lambda a: request.write('<div class="message">' + \
# _('La clase se ha cancelado correctamente') \
# + '</div>'))
d = defer.maybeDeferred(getTranslatorFromSession, request)
d.addCallback(self.writeWelcomeMessage, request)
return server.NOT_DONE_YET
def writeWelcomeMessage(self, trans, request):
_ = trans
session = request.getSession()
request.write(self.template.startPage(session, \
_('Beppo - Sistema de educacion a distancia')))
d = defer.maybeDeferred(lambda: None)
if hasattr(session, 'username'):
d.addCallback(lambda a: self.template.homePageContent(session))
d.addCallback(request.write)
d.addCallback(lambda a: self.template.commonInfo(trans))
d.addCallback(request.write)
else:
d.addCallback(lambda a: request.write('<h1>' + _('Bienvenido!') \
+ '</h1> <p>' + \
_('Aqui podra conocer todas las ventajas de utilizar el sistema Beppo, y lo intentaremos convencer de que lo compre.') + '</p>'))
d.addCallback(lambda a: request.write(self.template.finishPage(session)))
d.addCallback(lambda a: request.finish())
return d
示例2: WebLogin
# 需要导入模块: from WebTemplates import WebTemplates [as 别名]
# 或者: from WebTemplates.WebTemplates import commonInfo [as 别名]
class WebLogin(Resource):
def __init__(self):
self.db = DBConnect()
self.template = WebTemplates()
self.render_POST = self.render_GET
Resource.__init__(self)
def getChild(self, path, request):
if path == "":
return self
else:
return static.File.childNotFound
def render_GET(self, request):
session = request.getSession()
_ = getTranslatorFromSession(request)
d = defer.maybeDeferred(lambda: None)
if hasattr(session, 'username'):
request.write(self.template.startPage(session, _('Iniciar Sesion')))
request.write('<div class="message">' + \
_('La sesion ya estaba iniciada') + '</div>')
elif "username" in request.args.keys() and "pwd" in request.args.keys():
query = "select username, id, kind, first_name, \
last_name from person where username = %s and password = %s"
username = QuotedString(request.args['username'][0])
pwd = sha.new(request.args['pwd'][0]).hexdigest() #hashing sent plain-password in sha-1
d = self.db.db.runQuery(query, (username, pwd))
d.addCallback(self.authenticateUser, request)
else:
request.write(self.template.startPage(session))
request.write("""<h2>""" + _('Inicio de Sesion') + """</h2> \
<form action="" method="post"><div>""" + _('Nombre de Usuario') \
+ """: <label for="username"><input type="text" size="5" name="username" \
id="username" value="Root"/></label><br/>""" + _('Contrasena') \
+ """: <label for="pwd"><input type="password" size="5" name="pwd" \
id="pwd" value="lala"/></label><br/><input id="submit" type="submit" value=\"""" + \
_('Entrar!') + """\"/></div></form>""")
d.addCallback(lambda a:request.write(self.template.finishPage(session)))
d.addCallback(lambda a:request.finish())
d.addErrback(log.err)
return server.NOT_DONE_YET
def authenticateUser(self, rows, request):
session = request.getSession()
_ = session._ # Ya sabemos que está
if len(rows) == 1:
row = rows[0]
session.username = row[0]
session.userId = row[1]
session.kind = row[2]
session.name = row[3]
session.lastname = row[4]
d = defer.maybeDeferred(getTranslatorFromSession, request, refresh=True)
d.addCallback(self.welcomeMessage, request, row[3], row[4])
return d
elif len(rows) == 0:
request.write(self.template.startPage(session))
request.write('<div class="warning"><h2>' + \
_('Nombre de Usuario o Contrasena incorrecta') + '</h2>' + \
_('Por favor verifique su nombre de usuario y contrasena.') + '<br/>' + \
_('Recuerde que su nombre de usuario y contrasena son sensibles a mayusculas y minusculas!') + '</div>')
else:
request.write(self.template.startPage(session))
request.write('<div class="error">' + \
_('Existen varios usuarios en el sistema con las mismas credenciales. Por favor notifique al administrador del sistema') + '</div>')
return
def welcomeMessage(self, trans, request, first, last):
session = request.getSession()
_ = trans
d = defer.maybeDeferred(lambda: None)
d.addCallback(lambda a: request.write(self.template.startPage(session)))
d.addCallback(lambda a: request.write('<div class="message">' + \
_('Bienvenido') + ', %s %s</div>' % (first, last)))
d.addCallback(lambda a: self.template.homePageContent(session))
d.addCallback(request.write)
d.addCallback(lambda a: self.template.commonInfo(trans))
d.addCallback(request.write)
return d