<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Permissions depend on your site.zcml (etc/site.zcml.in and later parts/etc/site.zcml). By default, paster adds the following line to those files which grants zope.View and not zope.Public to anonymous users:<br><br>&lt;grant permission="zope.View"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; principal="zope.Everybody" /&gt;<br></div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Mats &lt;mats@ronin-group.org&gt;<br><b><span style="font-weight: bold;">To:</span></b> Danilo G B &lt;danilogbotelho@yahoo.com&gt;<br><b><span style="font-weight: bold;">Cc:</span></b>
 grok-dev@zope.org<br><b><span style="font-weight: bold;">Sent:</span></b> Wed, May 25, 2011 9:51:17 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Grok-dev] megrok.login<br></font><br>
That worked wonders.&nbsp; Thanks a million.<br><br>Could you tell me why it doesn't work when I remove<br>grok.require('zope.Public')?&nbsp; Isn't all views public when no require<br>statement is specified?<br><br>Thanks again,<br><br>Mats<br><br>&gt; The magic of the megrok.login authentication is performed by the code in<br>&gt; <a target="_blank" href="http://loginform.py">loginform.py</a> ( check the LoginForm class' __call__ method).<br>&gt; In my code I dropped the self.index() in the last line and used a<br>&gt; grok.View.__call__(self) instead (you should use Page.__call__).<br>&gt;<br>&gt; class Login(grok.View):<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; grok.context(Interface)<br>&gt; &nbsp;&nbsp;&nbsp; grok.require('zope.Public')<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; def __call__(self):<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request = self.request<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; principal =
 request.principal<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unauthenticated = IUnauthenticatedPrincipal.providedBy(principal)<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.unauthenticated = unauthenticated<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; camefrom = request.get('camefrom')<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if isinstance(camefrom, list):<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # this can happen on python2.6, as it changed the<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # behaviour of cgi.FieldStorage a bit.<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; camefrom = camefrom[0]<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.camefrom = camefrom<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (not unauthenticated) and ('SUBMIT' in request):<br>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # authenticated by submitting<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.response.redirect(camefrom or '.')<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ''<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return grok.View.__call__(self)<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; def update(self, camefrom=None, SUBMIT=None):<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.camefrom = camefrom<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if SUBMIT is not None and camefrom is not None:<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # The credentials were entered. Go back. If the entered<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # credentials are not valid, another redirect will happen<br>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # to this view.<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.redirect(camefrom)<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.baseurl = self.url(self.context)<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return<br>&gt;<br>&gt; _______________________________________________<br>&gt; Grok-dev mailing list<br>&gt; <a ymailto="mailto:Grok-dev@zope.org" href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>&gt; <a href="https://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">https://mail.zope.org/mailman/listinfo/grok-dev</a><br>&gt;<br>&gt;<br></div></div>



</div></body></html>