将数据从 Plone 迁移到 Liferay,或者我如何从 Plone 的 Data.fs 检索信息
我需要将数据从基于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您掌握了 Plone 站点对象,您就可以执行目录查询来查找站点中的所有内容项:
这将返回一个“目录大脑”列表,每个列表都包含有关该项目的一些元数据。您可以从大脑中获取完整的项目:
假设您的 Plone 站点正在使用基于原型的内容,那么您可以迭代项目模式的字段并使用每个字段的访问器来检索其值:
由于 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:
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:
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:
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.