[cpif] r170 - in trunk/frontend-web: . skins/default

svn at argo.es svn at argo.es
Wed Jun 20 18:39:51 CEST 2007


Author: alvaro
Date: Wed Jun 20 18:39:49 2007
New Revision: 170

Log:
Bug que mostraba el login cuando no era exitoso.

Corregidos otros errores.


Added:
   trunk/frontend-web/skins/default/form_login_err.html
      - copied, changed from r169, /trunk/frontend-web/skins/default/form_login.html
Modified:
   trunk/frontend-web/skins.py
   trunk/frontend-web/url_LOGIN.py
   trunk/frontend-web/url_login.py

Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py	(original)
+++ trunk/frontend-web/skins.py	Wed Jun 20 18:39:49 2007
@@ -30,6 +30,7 @@
     'group_date':     'body_threadlist_group.html',
     'link_logout':    'link_logout.html',
     'link_login':     'link_login.html',
+    'form_login_err': 'form_login_err.html',
     'form_login':     'form_login.html',
     'footer':         'footer.html'
     }
@@ -39,8 +40,9 @@
     '/indice':              ['group_date', 'threads', 'threads'],
     '/hilo':                ['thread_entries'],
     '/nuevo_usuario':       ['new_user'],
+    '/login_err':           ['login_err'],
     '/login':               ['login'],
-    '/LOGIN':               ['login'],
+#    '/LOGIN':               ['login'],
     '/error':               [],
     '/stop':                [],
     '/nuevo_usuario_POST':  []
@@ -85,7 +87,8 @@
     if self._user:
       self._dict["auth"] = available_skins[self._skin]["link_logout"] % { "link_auth": "/logout", "user": self._user }
     else:
-      self._dict["auth"] = available_skins[self._skin]["link_login"] % { "link_auth": "/login/%s" % "/".join(self._path) if self._path else "/login" }
+      tmp = self._path[1:] if self._path[0] == "login" or self._path[0] == "login_err" else self._path
+      self._dict["auth"] = available_skins[self._skin]["link_login"] % { "link_auth": "/login/%s" % "/".join(tmp) if self._path else "/login" }
 
   def set_skin(self,skin):
     if skin in available_skins:
@@ -211,6 +214,9 @@
         aux = available_skins[self._skin]['body_thread_anonymous']
     elif "login" in urls[self._url]:
       aux = available_skins[self._skin]['generic'] % { "body": available_skins[self._skin]['form_login']}
+      self._dict["link_form_login"] = "/LOGIN/%s" % "/".join(self._path[1:])
+    elif "login_err" in urls[self._url]:
+      aux = available_skins[self._skin]['generic'] % { "body": available_skins[self._skin]['form_login_err']}
       self._dict["link_form_login"] = "/LOGIN/%s" % "/".join(self._path[1:])
     elif "new_user" in urls[self._url]:
       aux = available_skins[self._skin]['generic'] % { "body": available_skins[self._skin]['new_user']}

Copied: trunk/frontend-web/skins/default/form_login_err.html (from r169, /trunk/frontend-web/skins/default/form_login.html)
==============================================================================
--- /trunk/frontend-web/skins/default/form_login.html	(original)
+++ trunk/frontend-web/skins/default/form_login_err.html	Wed Jun 20 18:39:49 2007
@@ -1,3 +1,4 @@
+<h2>Error, nombre de usuario y/o contrase&ntilde;a inv&aacute;lidos</h2>
 <div id="form">
   <form action="%(link_form_login)s" method="post" enctype="multipart/form-data"> 
     <label for="usuario">Usuario: </td><td><input type="text" name="usuario" size="25" value="" /></label><br /> 

Modified: trunk/frontend-web/url_LOGIN.py
==============================================================================
--- trunk/frontend-web/url_LOGIN.py	(original)
+++ trunk/frontend-web/url_LOGIN.py	Wed Jun 20 18:39:49 2007
@@ -3,24 +3,28 @@
 from globales import monitor
 
 def gestiona_url(handler,path,usuario) :
-  if path[0]=="LOGIN" :
+  if path[0]=="LOGIN":
     import cgi,database
     path.pop(0)
-    ctype,pdict=cgi.parse_header(handler.headers.getheader('content-type'))
-    cuerpo=cgi.FieldStorage(fp=handler.rfile,headers=handler.headers,environ={'REQUEST_METHOD':'POST'},keep_blank_values=1)
-    usuario=cuerpo.getfirst("usuario")
-    clave=cuerpo.getfirst("clave")
-    if usuario and clave :
+    try:
+      ctype,pdict=cgi.parse_header(handler.headers.getheader('content-type'))
+      cuerpo=cgi.FieldStorage(fp=handler.rfile,headers=handler.headers,environ={'REQUEST_METHOD':'POST'},keep_blank_values=1)
+    except:
+      return (302,{"Location":"/404"},"")
+    usuario_form=cuerpo.getfirst("usuario")
+    clave_form=cuerpo.getfirst("clave")
+    if usuario_form and clave_form :
       @monitor
       def login(conn,usuario,clave) :
         return database.usuario_verifica(conn,nick=usuario,clave=clave)
-      resultado=login(usuario,clave)
+      resultado=login(usuario_form,clave_form)
       if resultado :
         nick,cookie=resultado
         if cookie :
           cookie="cpif_auth=%s; path=/;" %cookie
         return (302,{"Set-Cookie":cookie,"Location":"/"+"/".join(path)},"")
 
+  # Si no hemos salido antes, hay un error...
   import skins
-  pagina = skins.Skin(["login"] + path,usuario)
+  pagina = skins.Skin(["login_err"] + path,usuario)
   return (pagina.web())

Modified: trunk/frontend-web/url_login.py
==============================================================================
--- trunk/frontend-web/url_login.py	(original)
+++ trunk/frontend-web/url_login.py	Wed Jun 20 18:39:49 2007
@@ -12,6 +12,5 @@
          }
   else:
     d = {"page_title": "cpif - LOGIN"}
-  
   pagina.load_dict(d)
   return(pagina.web())



More information about the cpif mailing list