将数据从 Plone 迁移到 Liferay,或者我如何从 Plone 的 Data.fs 检索信息

发布于 2024-08-24 07:13:34 字数 1049 浏览 9 评论 0原文

我需要将数据从基于 Plone 的门户迁移到 Liferay。有人知道如何做吗?

不管怎样,我试图从 Data.fs 检索数据并将其存储在更容易工作的表示形式中,例如 JSON。为此,我需要知道应该从 Plone 的 Data.fs 中获取哪些对象。我已经从 Data.fs 获取了 Products.CMFPlone.Portal.PloneSite 实例,但我无法从中获取任何内容。我想获取 PloneSite 实例并执行如下操作:

>>> import ZODB
>>> from ZODB import FileStorage, DB
>>> path = r"C:\Arquivos de programas\Plone\var\filestorage\Data.fs"
>>> storage = FileStorage.FileStorage(path)
>>> db = DB(storage)
>>> conn = db.open()
>>> root = conn.root()
>>> app = root['Application']
>>> plone_site = app.getChildNodes()[13] # 13 would be index of PloneSite object
>>> a = plone_site.get_articles()
>>> for article in a:
...    print "Title:", a.title
...    print "Content:", a.content
Title: <some title>
Conent: <some content>
Title: <some title>
Conent: <some content>

当然,它不需要如此简单。我只想要一些有关 PloneSite 结构以及如何恢复其数据的信息。有人有什么想法吗?

先感谢您!

I need to migrate data from a Plone-based portal to Liferay. Has anyone some idea on how to do it?

Anyway, I am trying to retrieve data from Data.fs and store it in a representation easier to work, such as JSON. To do it, I need to know which objects I should get from Plone's Data.fs. I already got the Products.CMFPlone.Portal.PloneSite instance from the Data.fs, but I cannot get anything from it. I would like to get the PloneSite instance and do something like this:

>>> import ZODB
>>> from ZODB import FileStorage, DB
>>> path = r"C:\Arquivos de programas\Plone\var\filestorage\Data.fs"
>>> storage = FileStorage.FileStorage(path)
>>> db = DB(storage)
>>> conn = db.open()
>>> root = conn.root()
>>> app = root['Application']
>>> plone_site = app.getChildNodes()[13] # 13 would be index of PloneSite object
>>> a = plone_site.get_articles()
>>> for article in a:
...    print "Title:", a.title
...    print "Content:", a.content
Title: <some title>
Conent: <some content>
Title: <some title>
Conent: <some content>

Of course, it did not need to be so straightforward. I just want some information about the structure of PloneSite and how to recover its data. Has anyone some idea?

Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黎歌 2024-08-31 07:13:34

一旦您掌握了 Plone 站点对象,您就可以执行目录查询来查找站点中的所有内容项:

 >>> brains = site.portal_catalog.unrestrictedSearchResults()

这将返回一个“目录大脑”列表,每个列表都包含有关该项目的一些元数据。您可以从大脑中获取完整的项目:

 >>> for b in brains:
 ...     obj = b.getObject()

假设您的 Plone 站点正在使用基于原型的内容,那么您可以迭代项目模式的字段并使用每个字段的访问器来检索其值:

 >>> for field in obj.Schema().fields():
 ...     field_id = field.__name__
 ...     field_value = field.getAccessor(obj)()

由于 ZODB 是一个对象数据库,存储 pickled Python 对象,您需要在 Python 环境中存在正确版本的 Archetypes,以及定义您尝试检索的对象的类的包。

Once you've got ahold of the Plone site object, you can do a catalog query to find all content items in the site:

 >>> brains = site.portal_catalog.unrestrictedSearchResults()

This returns a list of "catalog brains", each of which contains some metadata about the item. You can get the full item from the brain:

 >>> for b in brains:
 ...     obj = b.getObject()

Assuming your Plone site is using Archetypes-based content, you can then iterate through the fields of the item's schema and use each field's accessor to retrieve its value:

 >>> for field in obj.Schema().fields():
 ...     field_id = field.__name__
 ...     field_value = field.getAccessor(obj)()

Since the ZODB is an object database that stores pickled Python objects, you will need to have the correct version of Archetypes present in your Python environment, as well as the package that defines the class of the objects you're trying to retrieve.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文