Re: [Zope3-Users] login/logout with z3c.pagelet?
Hi, Are there any login/logout/redirect templates for z3c.pagelet? I could reuse the templates from zope.app.authentication, but they obviously contain some macros that need some registrations I don't have, such as @@standard_macros. And my layout template does not contain any macro. Maybe there is some package with a layer that does this job? How are you doing? I simply created a simple z3c.form based form that looks like this: class LoginPage(ActionForm): Login logic and page template = ViewPageTemplateFile('pt/login.pt') fields = form.field.Fields(IFYMUser).select('login', 'password') prefix = login_data unsuccessfulLogin = False def __call__(self): request = self.request if (not IUnauthenticatedPrincipal.providedBy(request.principal) and 'login_data.widgets.login' in request): # Login succeeded! camefrom = request.get('camefrom', '.') request.response.redirect(camefrom) else: if 'login_data.widgets.login' in request: # Something went wrong with the authentication self.unsuccessfulLogin = True return super(LoginPage, self).__call__() @form.button.buttonAndHandler(_('Anmelden'), name='login') def handleLogin(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return if self.unsuccessfulLogin: raise ActionExecutionError(Invalid( _(uUngültige Login/Passwort-Kombination!))) @form.button.buttonAndHandler(_(u'Abbrechen'), name='abbrechen') def handle_abbrechen(self, action): self.request.response.redirect('index.html') class LogoutPage(BrowserPagelet): Logout logic and page template = ViewPageTemplateFile('pt/logout.pt') def update(self, nextURL=None): if not IUnauthenticatedPrincipal.providedBy(self.request.principal): auth = getUtility(IAuthentication) ILogout(auth).logout(self.request) site_path = absoluteURL(getSite(), self.request) return self.request.response.redirect(site_path + '/logout.html') My templates looks like this: - login h2 i18n:translate= Anmelden /h2 p/ span tal:replace=structure view/errorstatus / input tal:replace=structure view/widgets/login/snippets/div / input tal:replace=structure view/widgets/password/snippets/div / div class=buttons input tal:repeat=action view/actions/values tal:replace=structure action/render / /div logout h2 i18n:translate=Abmelden/h2 p i18n:translate= Sie sind nun vom System abgemeldet. /p Moreover, I have a link in my menu that points to the login/logout page, (only logout if logged in and reverse). However, I still have the problem that I don't know how to make Zope3 point to my login page in case unauthorized content is requested. Zope3 displays some Unauthorized - a sever error has occured page I don't know where it comes from. Best Regards, Hermann P.S.: Ah yes, the ActionForm is a simple form inheriting from form.Form that ignores the context. And the input fields in the template rely on my z3c.formsnippets package, which you can easily replace with your TAL code. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] login/logout with z3c.pagelet?
Hi Christophe, I looked at some of my projects using z3c.pagelet and found that it had taken a fair amount of work to get the login/logout views setup with pagelets. I think it would be great if someone could contribute a package that makes setting this up easier. Any volunteers? - Paul On Feb 11, 2008 8:20 AM, Christophe Combelles [EMAIL PROTECTED] wrote: Christophe Combelles a écrit : Hi, Are there any login/logout/redirect templates for z3c.pagelet? I could reuse the templates from zope.app.authentication, but they obviously contain some macros that need some registrations I don't have, such as @@standard_macros. And my layout template does not contain any macro. Maybe there is some package with a layer that does this job? How are you doing? Actually I haven't seen any other solution than registering standard_macros and some views of zope.app.security and zope.app.authentication in my layer (login.html, logout.html, loginForm.html, @@login_logout), and adding the 'page' macro and the 'headers' and body slots in my pagelet based layout template. It finally works, and it avoids some copy-pasting of these templates in my project, but I wondered whether a full pagelet solution existed? Christophe thanks, Christophe ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] login/logout with z3c.pagelet?
Christophe Combelles a écrit : Hi, Are there any login/logout/redirect templates for z3c.pagelet? I could reuse the templates from zope.app.authentication, but they obviously contain some macros that need some registrations I don't have, such as @@standard_macros. And my layout template does not contain any macro. Maybe there is some package with a layer that does this job? How are you doing? Actually I haven't seen any other solution than registering standard_macros and some views of zope.app.security and zope.app.authentication in my layer (login.html, logout.html, loginForm.html, @@login_logout), and adding the 'page' macro and the 'headers' and body slots in my pagelet based layout template. It finally works, and it avoids some copy-pasting of these templates in my project, but I wondered whether a full pagelet solution existed? Christophe thanks, Christophe ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] login/logout with z3c.pagelet?
Hi, Are there any login/logout/redirect templates for z3c.pagelet? I could reuse the templates from zope.app.authentication, but they obviously contain some macros that need some registrations I don't have, such as @@standard_macros. And my layout template does not contain any macro. Maybe there is some package with a layer that does this job? How are you doing? thanks, Christophe ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users