Archive for the ‘XML’ Category

Publishing XML with Plone

Integrating Plone with external systems always seems to cost more effort than it really should. In the past I have integrated Plone with ERP systems using CSV exports, IBM DB2 databases with text dumps, VCARD import’s from a CRM system and also some relational databases. Fortunately the story for relation databases is improving. Of course this only works with databases you can access directly.

Because writing synchronisation scripts is not only very tedious but also very error prone I wanted to fix this once and for all. One of the lessons I learned from previous experiences is not to try to sync everything in one step. Converting the data to an intermediate format you understand and is under your own control gives a lot of advantages.

This post is not going to go on with complaining about all the troubles with external systems. The reason is I made something which should solve it (or solves it for me). You can take a look at the code in the collective. What enables you to do is create a simple piece of content in Plone. In this content you can specify a location on the filesystem you want to publish. When you traverse the piece of content it reads the XML with the same name from the filesystem and wrap it in a proxy. This proxy is then decorated with a view ready for publishing. And the nice thing is it can publish any piece of XML you can think of.

Well that is not completely true, there has to be one little thing in there. The XML must have declare an interface. This interface is an identifier for an Zope 3 interface. It is this interface that is used when looking up views etc.

Another nice thing is that the proxy can also delegate calls it does not understand. This allows it to play nice with the ZCatalog by diverting all queries for Title etc. to a specific adapter.

One word of caution is order before you get to excited, this code is not used in production. It is not finished yet and last but not least there is a problem running all tests simultaniosly. This has to do with a hack I stuck in to make PloneTestCase work with Zope 2.9 and pythonproducts. They should work without failing if you run them one at a time.

Comments on the architecture, system as a whole etc. are greatly appreciated. I hope some more people will find a use for this (or tell me why I am going at it the wrong way). Oh, before I forget it, tips for a better name are also welcome (it is called xmlcontent for now).

Advertisements