【问题标题】:How to export Plone session configuration?如何导出 Plone 会话配置?
【发布时间】:2012-08-31 08:35:22
【问题描述】:

我想将我的 Plone 会话配置导出到我的门户产品。

会话配置是通过 ZMI -> acl-users -> 会话 -> 属性设置的

我已尝试创建站点快照,但在快照 xml 中找不到会话配置...

【问题讨论】:

    标签: session cookies plone zope


    【解决方案1】:

    确实,plone.session 中没有包含 GenericSetup 配置支持;目前没有任何东西可以为您导出它,也没有任何东西可以导入设置。

    您必须为它编写一个设置步骤,并通过它手动配置会话插件。

    configure.zcml 配置文件中添加导入步骤:

    <?xml version="1.0"?>
    <configure
        xmlns="http://namespaces.zope.org/zope"
        xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    
    <genericsetup:importStep
        name="yourpackage.a_unique_id_for_your_step"
        title="Configures the plone.session plugin"
        description="Perhaps an optional description"
        handler="your.package.setuphandlers.setupPloneSession"
        />
    
    </configure>
    

    并将一个空的 'sentinel' 文本文件添加到名为 youpackage.setup-plonesession.txt 的同一配置文件目录中

    然后将setuphandlers.py 模块添加到您的包中(handler 在上面的示例中指向的内容):

    def setupPloneSession(context):
        if context.readDataFile('youpackage.setup-plonesession.txt') is None:
            return
    
        portal = context.getSite()
        plugin = portal.acl_users.session
    
        # Configure the plugin manually
        plugin.path = '/'
        plugin.cookie_name = '__ac'
        plugin.cookie_domain = ''
    
        # Set up a shared auth_tkt secret
        plugin._shared_secret = 'YourSharedSecretKey'
        plugin.mod_auth_tkt = True
    

    请注意,我们首先测试哨兵文件是否存在;如果你在其他地方重复使用你的包设置,如果你不这样做,设置步骤可能会运行多次。

    恐怕您需要参考plugin source 来了解您可以配置的内容。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 2016-11-29
    • 2022-10-12
    • 2014-10-20
    • 2014-01-18
    相关资源
    最近更新 更多