如何在plone中按需更新单个原型对象的模式?

时间:2022-12-30 07:23:08

I have hundreds of thousands of objects based on plone archetypes (plone 2.5.X) that need their archetypes schema updated to the latest. The archetype schema migration tool is great for a small/medium number objects but is bringing my server to its knees trying to migrate them all, to the point where I always end up killign the script. I would like to be able to update the schema of one object at a time, potentially as the object as retrieved - is that possible? If not, any other approaches to updating archetype schemas in large plone sites?

我有成千上万个基于plone archetypes(plone 2.5.X)的对象需要将他们的原型模式更新到最新版本。原型架构迁移工具非常适合中小型号的对象,但是让我的服务器试图将它们全部迁移到我总是最终杀死脚本的程度。我希望能够一次更新一个对象的模式,可能是检索到的对象 - 这可能吗?如果没有,在大型plone站点中更新原型架构的任何其他方法?

Thanks in advance!

提前致谢!

2 个解决方案

#1


after digging through the 2.5 catalog code, I've finally found the answer to a lazy schema update:

在深入研究2.5目录代码后,我终于找到了延迟架构更新的答案:

if not self._isSchemaCurrent():
    logging.debug("updating schema for %s"%self.absolute_url())
        try:
            import transaction
            transaction.begin()
            self._updateSchema()
            transaction.commit()
        except Exception, e:
            logging.error('Error updating schema at %s: %s'%(self.absolute_url(), e))
            return False
else:
    logging.debug("schema for %s is up to date"%self.absolute_url())
    return True

Note that this is Plone 2.5.3 and from what I was digging through plone 3 looks slightly different. For some objects where I have already customized processForm, I perform the upgrade there so that the form can display the new field and it will get processed. For others just in the at_post_edit_script hook since those usually don't have mega important schema upgrades. Additionally form processing is the slowest part of the site anyways so the user experience isn't affected so much.

请注意,这是Plone 2.5.3并且从我通过plone 3挖掘的内容看起来略有不同。对于我已经定制过processForm的一些对象,我在那里执行升级,以便表单可以显示新字段并进行处理。对于其他只是在at_post_edit_script钩子,因为那些通常没有大型重要的架构升级。此外,表单处理是网站中最慢的部分,因此用户体验不会受到太大影响。

Its hacky but it causes no I/O splurges and it works with all versions of objects. I'll take it!

它的hacky但它​​不会导致I / O挥霍,它适用于所有版本的对象。我要买它!

#2


Although you don't explain what "bringing to it's knees" means, I'm going to guess that you run out of memory. If so, that's probably a question of the script not committing changes to disk. Adding a transaction.commit() in the loop (preferably with a test to only doing every 100th or 1000th time) should fix that.

虽然你没有解释“带来它的膝盖”的意思,但我猜你的内存已经不足了。如果是这样,那可能是脚本没有提交更改到磁盘的问题。在循环中添加transaction.commit()(最好只有每100或1000次测试)应该解决这个问题。

Edit: So I was wrong, it wasn't a memory problem. It seems the archetypes updater does the correct thing.

编辑:所以我错了,这不是内存问题。似乎原型更新器做了正确的事情。

#1


after digging through the 2.5 catalog code, I've finally found the answer to a lazy schema update:

在深入研究2.5目录代码后,我终于找到了延迟架构更新的答案:

if not self._isSchemaCurrent():
    logging.debug("updating schema for %s"%self.absolute_url())
        try:
            import transaction
            transaction.begin()
            self._updateSchema()
            transaction.commit()
        except Exception, e:
            logging.error('Error updating schema at %s: %s'%(self.absolute_url(), e))
            return False
else:
    logging.debug("schema for %s is up to date"%self.absolute_url())
    return True

Note that this is Plone 2.5.3 and from what I was digging through plone 3 looks slightly different. For some objects where I have already customized processForm, I perform the upgrade there so that the form can display the new field and it will get processed. For others just in the at_post_edit_script hook since those usually don't have mega important schema upgrades. Additionally form processing is the slowest part of the site anyways so the user experience isn't affected so much.

请注意,这是Plone 2.5.3并且从我通过plone 3挖掘的内容看起来略有不同。对于我已经定制过processForm的一些对象,我在那里执行升级,以便表单可以显示新字段并进行处理。对于其他只是在at_post_edit_script钩子,因为那些通常没有大型重要的架构升级。此外,表单处理是网站中最慢的部分,因此用户体验不会受到太大影响。

Its hacky but it causes no I/O splurges and it works with all versions of objects. I'll take it!

它的hacky但它​​不会导致I / O挥霍,它适用于所有版本的对象。我要买它!

#2


Although you don't explain what "bringing to it's knees" means, I'm going to guess that you run out of memory. If so, that's probably a question of the script not committing changes to disk. Adding a transaction.commit() in the loop (preferably with a test to only doing every 100th or 1000th time) should fix that.

虽然你没有解释“带来它的膝盖”的意思,但我猜你的内存已经不足了。如果是这样,那可能是脚本没有提交更改到磁盘的问题。在循环中添加transaction.commit()(最好只有每100或1000次测试)应该解决这个问题。

Edit: So I was wrong, it wasn't a memory problem. It seems the archetypes updater does the correct thing.

编辑:所以我错了,这不是内存问题。似乎原型更新器做了正确的事情。