带钩子的涡轮齿轮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错误。它可能已经死了。对于firefox navegator   java StartActivity突然停止启动另一个活动   java需要通过struts2中的操作名称获取操作url   在netbeansjframe中使用jList的java   inputstream从java文件输入文本   Java将Set<Set<String>>转换为List<List<String>>   java应用程序,cucumber找不到模块\features\stepdefinitions   java de.laures。cewolf IIOException:无法创建输出流   java如何进行正确的HQL连接   java自动选择JTable的其他行   java Hibernate 3.6.8+带注释的POJO+配置   PDF格式的java可滚动图像   如何提高java项目性能?   java FindByDate并在Spring Boot中仅显示具有有效日期的列表   单元测试中的java@Autowire似乎不起作用   试图从“主”Java程序中生成docker容器,并在主程序和从程序之间建立连接   java在编译JUnit测试时找不到符号错误