如何导出Plone会话配置?

时间:2012-08-31 08:35:23

标签: session cookies plone zope

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

会话配置通过ZMI设置 - > acl-users - >会话 - >特性

我尝试过创建网站快照但无法在快照xml中找到会话配置...

1 个答案:

答案 0 :(得分:4)

实际上,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

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

您需要参考plugin source来了解您可以配置的内容,我担心。