<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><grant permission="zope.View"<br> principal="zope.Everybody" /><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 <mats@ronin-group.org><br><b><span style="font-weight: bold;">To:</span></b> Danilo G B <danilogbotelho@yahoo.com><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. Thanks a million.<br><br>Could you tell me why it doesn't work when I remove<br>grok.require('zope.Public')? Isn't all views public when no require<br>statement is specified?<br><br>Thanks again,<br><br>Mats<br><br>> The magic of the megrok.login authentication is performed by the code in<br>> <a target="_blank" href="http://loginform.py">loginform.py</a> ( check the LoginForm class' __call__ method).<br>> In my code I dropped the self.index() in the last line and used a<br>> grok.View.__call__(self) instead (you should use Page.__call__).<br>><br>> class Login(grok.View):<br>><br>> grok.context(Interface)<br>> grok.require('zope.Public')<br>><br>> def __call__(self):<br>> request = self.request<br>> principal =
request.principal<br>><br>> unauthenticated = IUnauthenticatedPrincipal.providedBy(principal)<br>> self.unauthenticated = unauthenticated<br>><br>> camefrom = request.get('camefrom')<br>> if isinstance(camefrom, list):<br>> # this can happen on python2.6, as it changed the<br>> # behaviour of cgi.FieldStorage a bit.<br>> camefrom = camefrom[0]<br>> self.camefrom = camefrom<br>><br>> if (not unauthenticated) and ('SUBMIT' in request):<br>>
# authenticated by submitting<br>> request.response.redirect(camefrom or '.')<br>> return ''<br>><br>> return grok.View.__call__(self)<br>><br>> def update(self, camefrom=None, SUBMIT=None):<br>> self.camefrom = camefrom<br>> if SUBMIT is not None and camefrom is not None:<br>> # The credentials were entered. Go back. If the entered<br>> # credentials are not valid, another redirect will happen<br>>
# to this view.<br>> self.redirect(camefrom)<br>> self.baseurl = self.url(self.context)<br>> return<br>><br>> _______________________________________________<br>> Grok-dev mailing list<br>> <a ymailto="mailto:Grok-dev@zope.org" href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>> <a href="https://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">https://mail.zope.org/mailman/listinfo/grok-dev</a><br>><br>><br></div></div>
</div></body></html>