开发者

How can I update a plone page via a script?

开发者 https://www.devze.com 2023-04-02 08:35 出处:网络
I have a large amount of automatically generated html files that I would like to push to my Plone website with a script. I currently generate the files, log into Plone, click edit on each individual p

I have a large amount of automatically generated html files that I would like to push to my Plone website with a script. I currently generate the files, log into Plone, click edit on each individual page and copy and paste the html into the editor. I'd like to automate this. It would be nice to retain the plone versioning, have a auto generated comment for the edit, and come from a sp开发者_C百科ecific user.

I've read and tried Webdav with little luck at getting it working consistently and know that there is a way to connect to plone via ftp, but haven't tried it. I'm not sure if these are the methods that I need.

My google searches aren't leading me to anything useful. Any ideas on where to start looking for a solution to this? Or any tips on implementing it?


You can script anything in Plone via the following methods:

  • Through-the-web via API calls (e.g. XML-RPC, wsapi, etc.)
  • The bin/instance run script provided by plone.recipe.zope2instance (See charm for an example of this).

You can also use a migration framework like:

  • collective.transmogrifier

which allows you to write migration code, and trigger it via GenericSetup or Browser view. Additionally, there are applications written on top of Transmogrifier aimed roughly at what you are describing, the most popular of which is:

  • funnelweb

I would recommend that you consider using or writing a Transmogrifier "blueprint(s)" to do your import, and execute the pipeline with a tool that makes that easy:

  • mr.migrator

You can find blueprints by searching PyPI for "transmogrify". One popular set of blueprints is:

  • quintagroup.transmogrifier

One of the main attractions to the Transmogrifier approach, aside from getting the job done, is the ability to share useful blueprints with others.


I think transmogrifier is the best tool for this job, but this will definitely be a programming task no matter how you do it. It's used for many such migration jobs such as migrating from drupal.


There's an add-on, wsapi4plone.core that pumazi at WebLion started that provides web services for portals which you can then hook into. You can create, modify, delete content via XML-RPC calls. The only caveat is that it doesn't yet work with Collections (criteria specifically).

project: http://pypi.python.org/pypi/wsapi4plone.core docs: http://packages.python.org/wsapi4plone.core/

You can also do it programmatically by hooking into the ZODB via Python (zopepy or some other method).

These should get you started:

http://plone.org/documentation/kb/manipulating-plone-objects-programmatically/reading-and-writing-field-values - you should be able to get an understanding of accessors and mutators (setters and getters), in your case you are going to be more than likely working with obj.Text (getter) and obj.setText (setter).

https://weblion.psu.edu/trac/weblion/wiki/AutomatingObjectCreation - lots of examples (slightly outdated but still relevant)


http://plone.org/documentation/faq/upload-images-files

Try to enable Webdav or ftp in Plone, then you can access Plone via webdav or ftp clients, pushing the html files. Plone (Zope) will recognises the html files as Pages.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号