带钩子的涡轮齿轮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楼梯的最大高度   java Jackson从1.7.1更新到2.8.6 JsonTypeInfo子类型反序列化   Spring WebApp中的java JPA异常处理   java在SwingWorker(doInBackground)中从WorkerThread调用多个方法?   java Android Studio构建到jar   java是添加多个按钮组的更有效方法   java MySQL JDBC连接池最大大小   java如何防止元素<Integer>变成元素<Object>   Java:处理大型XML文件提取数据而不编写状态自动机?   SpringBoot和React Web应用程序中CAS的java重定向问题   需要java算法方面的帮助吗   java在JDK 16中使用PowerMock   java异常错误本机方法签名   在Java Android中将JSON映射到数组/对象   如何打开一个窗口。java程序中的dat文件   java应用程序引擎+Maven+热插拔   java Moxy的getValueByXPath为除根元素以外的所有元素返回null