[Checkins] SVN: Sandbox/luciano/kirbi/src/kirbi/app small changes to login process

Luciano Ramalho luciano at ramalho.org
Sat Aug 18 15:21:09 EDT 2007


Log message for revision 78969:
  small changes to login process
  

Changed:
  U   Sandbox/luciano/kirbi/src/kirbi/app.py
  U   Sandbox/luciano/kirbi/src/kirbi/app_templates/login.pt
  U   Sandbox/luciano/kirbi/src/kirbi/app_templates/master.pt

-=-
Modified: Sandbox/luciano/kirbi/src/kirbi/app.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/app.py	2007-08-18 18:20:12 UTC (rev 78968)
+++ Sandbox/luciano/kirbi/src/kirbi/app.py	2007-08-18 19:21:08 UTC (rev 78969)
@@ -7,6 +7,7 @@
 from zope.interface import Interface, implements
 from zope.component import getSiteManager
 from zope.traversing import browser
+from urllib import urlencode
 
 from zope.app.authentication import PluggableAuthentication
 from zope.app.authentication.principalfolder import PrincipalFolder
@@ -74,8 +75,6 @@
     isbn13 = index.Field()
     searchableText = index.Text()
 
-    #XXX: check whether this is working:
-    # the creatorSet book method was not being called
     creatorsSet = index.Set()
 
 class Master(grok.View):
@@ -86,7 +85,8 @@
 class Login(grok.View):
     grok.context(Interface)
 
-    def update(self, login_submit=None):
+    def update(self, login_submit=None, login=None):
+        # XXX: need to display some kind of feedback when the login fails
         if (not IUnauthenticatedPrincipal.providedBy(self.request.principal)
             and login_submit is not None):
             destination = self.request.get('camefrom')
@@ -128,19 +128,5 @@
         role_manager = IPrincipalRoleManager(self.context)
         role_manager.assignRoleToPrincipal('kirbi.Owner', 
                                principals.prefix + login)
-        self.redirect(self.url(login))
-
-class X(grok.View):
-    def render(self):
-        from zope.app.session.session import ISession
-        unp = IUnauthenticatedPrincipal
-        pri = self.request.principal
-        unauth = unp.providedBy(pri)
-        ses = ISession(self.request)
-        # import pdb; pdb.set_trace()
-        if hasattr(pri,'getLogin'):
-            login = pri.getLogin()
-        else:
-            login = 'N/A'
-        return 'unauth: [%s] id: [%s] login: [%s]' % (unauth, pri.id, login)
+        self.redirect(self.url('login')+'?'+urlencode({'login':login}))
  
\ No newline at end of file

Modified: Sandbox/luciano/kirbi/src/kirbi/app_templates/login.pt
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/app_templates/login.pt	2007-08-18 18:20:12 UTC (rev 78968)
+++ Sandbox/luciano/kirbi/src/kirbi/app_templates/login.pt	2007-08-18 19:21:08 UTC (rev 78969)
@@ -3,6 +3,7 @@
 
 
   <span metal:fill-slot="content_title">Login</span>
+  <span metal:fill-slot="content_search"></span>
 
   <div metal:fill-slot="content">
 
@@ -14,7 +15,8 @@
         <table>
            <tr><th>Login</th>
                <td>
-                    <input type="text" name="login" id="login" />
+                    <input type="text" name="login" id="login"
+                      tal:attributes="value request/login|nothing"/>
                 </td>
            </tr>
            <tr><th>Password</th>

Modified: Sandbox/luciano/kirbi/src/kirbi/app_templates/master.pt
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/app_templates/master.pt	2007-08-18 18:20:12 UTC (rev 78968)
+++ Sandbox/luciano/kirbi/src/kirbi/app_templates/master.pt	2007-08-18 19:21:08 UTC (rev 78969)
@@ -11,6 +11,8 @@
         tal:attributes="href static/favicon.ico" />
 
   <script metal:define-slot="setfocus" type="text/javascript">
+        /* XXX: should set focus to first field in form,
+           regardless of field name (see login.pt) */
         function setfocus() { document.forms[0].query.focus() }
   </script>
 
@@ -56,7 +58,7 @@
               login: <span tal:replace="view/request/principal/id" />
            </span>
         </span>
-        <span metal:define-slot="content_actions">
+        <span metal:define-slot="content_search">
           <form class="search" tal:attributes="action python:view.application_url('pac')">
               <input type="text" name="query">
               <input type="submit" name="submit" value="search">



More information about the Checkins mailing list