带钩子的涡轮齿轮2精细定制可插拔注册应用

tgapp-registration的Python项目详细描述


https://badge.fury.io/py/tgapp-registration.svghttps://travis-ci.org/axant/tgapp-registration.svg?branch=masterhttps://coveralls.io/repos/github/axant/tgapp-registration/badge.svg?branch=master

关于TGApp注册

注册是TurboGears2的可插入注册应用程序。 默认情况下,它将使用快速启动涡轮齿轮用户模型 但提供了一堆挂钩,可以用来更改注册 形式和大部分注册方面。

注册当前同时支持SQLAlchemyMongoDB 用于数据库存储。

注册同时支持Turbomailtgext.mailer发送电子邮件。

安装

tgapp注册既可以从pypi安装,也可以从bitbucket安装:

pip install tgapp-registration

应该只对大多数用户有效

如果要使用turbomail作为发件人,请从pypi安装:

pip install turbomail

如果要使用tgext.mailer作为发件人,请从pypi或bitbucket安装它:

pip install tgext.mailer

插入注册

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

from tgext.pluggable import plug

然后在文件的结尾处调用带有注册的插件:

plug(base_config, 'registration')

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

plug(base_config, 'tgext.mailer')

您将可以在 http://localhost:8080/registration

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

  • registration.email_sender -> Outgoing mails sender address (like ^{tt6}$)

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

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

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

插件选项

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

  • registration.form -> Full python path of the form class to use for Registration form. By default registration.lib.forms.RegistrationForm is used.

可用挂钩

注册公开一些钩子来配置它的行为, 可与涡轮齿轮2寄存器挂钩一起使用的挂钩是:

  • registration.before_registration_form(arguments) -> Runs before rendering the form. Can be used to insert preconditions to limit the registration for example just to invited users. You can fill the form inserting data into arguments, you might want to put a json serialized dictionary into arguments[‘extra’] that is an HiddenField in the form
  • registration.before_registration(submitted_values) -> Runs after form submission. Can be used to change the values submitted by the form before they are used
  • registration.after_registration(registration, submitted_values) -> Runs after form submission. Can be used to store eventual data that the form sent and that the Registration model doesn’t support.
  • registration.on_complete(registration, email_data) -> Runs after registration completion before sending activation email, can be used to change outgoing email.
  • registration.before_activation(registration, user) -> Runs at activation before creating the user and setting the registration as active
  • registration.after_activation(registration, user) -> Runs after creating user, can be used to call redirect to redirect to a different page at registration completion.

公开模板

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

  • registration.templates.register
  • registration.templates.complete

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

推荐PyPI第三方库


热门话题
Java Hibernate@ManyToMany mapping只在一个方向上在数据库中添加记录   java将文件上载到tomcat服务器外部的文件夹   java将摄像头捕获的图像上传到服务器   java如何创建Rest API并为进程添加时间延迟?   springmodulesvalidation0中缺少java注释包。8a源文件   如何在java中打印SOAP头   Spring security中的java自定义消息,包括UserDetailsService实现和异常   java如何使用Htmlunit中的表单数据登录站点   web如何在WildFly上自动运行java文件   java如何从已经使用另一个方法传递的参数的方法中获取返回值?   java我在JFrame上有一个索引越界。setContentPane   java中的循环序列/系列打印   java maven 3 webapp没有要运行的测试吗?   java CORS不允许POST请求   java再次在派生类中的Jackson中添加字段,该字段在基类中被忽略   爪哇坑测试显示仆从由于超时而异常退出   java寻找第10001个素数   java jboss是否更改web应用程序上下文根?