After using Authkit with *form* authentication method for a while, I want to change sign-in form to have the same theme as other pages and also add project name to the form. Finally, I found this site http://jimmyg.org/2007/08/14/pylons-mako-templates-in-authkit/, which is (nearly) identical @sirn suggestion. They told me how to change this form so thank both of them.
However, I want to make a very simple modification first so I simplified the example. In development.ini, I just add “authkit.form.template.obj”.
authkit.setup.enable = true authkit.setup.method = form, cookie authkit.form.authenticate.user.type = basaasa.users.authkit_elixir_driver:UsersFromDatabase authkit.form.authenticate.user.data = basaasa.model authkit.cookie.secret = SomeSec authkit.cookie.signoutpath = /auth/signout authkit.form.template.obj = basaasa.lib.auth:make_template #I added this line
Then I added auth.py to /basaasa/lib.
def make_template(): return """ Signin <div> BasaAsa: Signin <table> <tr><td> Username: </td></tr> <tr><td> Password: </td></tr> </table> </div> """
def make_template() is required to return template, which is format string. Format string is just normal string with format specifier(s), for example: “xxx %s xxx”. For “def make_template()”, %s will be replace by an action, which is used as form action.
I do not plan to really use this example in BasaAsa but an example in the link in the paragraph above. However I hope this will remind me in the future how template work in Authkit and how to replace it.