TurboGears2的可插拔应用程序,允许更改用户密码或在丢失时重置密码,具有SQLA和Ming兼容性

tgapp-resetpassword的Python项目详细描述


关于重置密码

ResetPassword是TurboGears2的可插入应用程序 允许更改用户密码或在丢失时重置密码。

安装

resetpassword既可以从pypi安装,也可以从bitbucket安装:

pip install tgapp-resetpassword

应该只对大多数用户有效

插入重置密码

在应用程序中config/app_cfg.py导入plug

from tgext.pluggable import plug

然后在文件的结尾处使用resetpassword调用plug:

plug(base_config, 'resetpassword')

您可以在 http://localhost:8080/resetpassword

如果使用tgext.mailer则需要插入:

plug(base_config, 'tgext.mailer')

有些选项可以在^{tt1}上设置$ 应用程序的配置文件。 制作激活电子邮件至少需要一个选项 工作:

  • resetpassword.email_sender -> Outgoing mails sender

如果您正在使用tgext.mailer您需要设置一些配置,请在此处查看可用选项: https://github.com/amol--/tgext.mailer

如果不使用turbomailtgext.mailer更多配置 必须设置选项才能使激活电子邮件正常工作:

  • resetpassword.smtp_host -> SMTP server to use to send emails
  • resetpassword.smtp_port -> SMTP server port
  • resetpassword.smtp_login -> Login for authentication on SMTP server
  • resetpassword.smtp_passwd -> Password for authentication on SMTP server

插件选项

插入tgapp-resetpassword时,以下选项 可以传递到插头呼叫:

  • reset_password_form -> Full python path of the form class to use for Reset Password form. By default resetpassword.lib.forms.ResetPasswordForm is used.
  • new_password_form -> Full python path of the form class to use for New Password form. By default registration.lib.forms.NewPasswordForm is used.

因此,插头呼叫可能如下所示:

plug(
    base_config,
    'resetpassword',
    reset_password_form='myproject.lib.resetpassword_forms.ResetPasswordForm',
    new_password_form='myproject.lib.resetpassword_forms.NewPasswordForm',
)

可用挂钩

resetpassword提供了一些钩子 在某些操作期间调用以更改默认值 应用程序的行为:

  • resetpassword.on_request(user, email_data, reset_link)
  • resetpassword.before_render_change_password_template(user, deserialized_data)
  • resetpassword.before_redirect(redirect_url)

公开模板

resetpassword使用的模板,可替换为 tgext.pluggable.replace_template是:

  • resetpassword.templates.index -> Page with password reset request form
  • resetpassword.templates.change_password -> Page with change password request

示例用法(在plug调用之后):

from tgext.pluggable import replace_template
replace_template(base_config, 'resetpassword.templates.index', 'myproject.templates.reset_password')
replace_template(base_config, 'resetpassword.templates.change_password', 'myproject.templates.change_password')

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JPA。Eclipselink没有为mySQL提供密码,但它应该提供   我的Servlet和@FormDataParam存在java问题   java将什么作为上下文参数传递到文件I/O方法中?   如果两个值相同,java无法找到其中一个单选按钮   java在变量和方法名中使用下划线   JavaSpringMVC单线程安全?   klazz类的java Arraylist(反射Api)   java如何在数字字符串中查找最频繁的数字?   JavaAPI设计:使数据更易于阅读与强制更多API调用   JavaHadoopMapReduceforGoogleWebGraph   java无法启动gauge API:Runner意外退出   java如何在bluemix上使用ibm工作负载调度器?   拉取一年中某一周特定日期的所有日期   java为什么是我的角节点。js应用程序将图像上传到S3� 邮递员正确上传时的符号?   在不使用任何第三方jar的情况下将文件从本地传输到linux系统(java代码)   java将现有文件夹复制到Eclipse工作区中新创建的项目中   Java中的regex RegExp帮助   当使用“系统”外观时,Java组合框setSelectedItem会出现故障   JavaASM:在类的方法中获取局部变量名和值