Mirrowing Folder

1 Introduction

Sometimes you have a Web application in several variants. A prominent example is the same application for different languages. In such a case, you will want to separate the common parts out and maintain them just once. Nevertheless, the variant parts should be able to reference the common parts as if they had not been factored out.

This situation is the main use case for Mirrowing Folder. A mirrowing folder is a folder that is able to map one subfolder into each of its other subfolders. Under the assumption that all subfolders have essentially the same structure, the subfolders of the mirrowed folder are recursively mapped during traversal onto the corresponding subfolders in the folder selected by the request URL. Content there can access the mirrowed objects (almost) as if they were physically located beside them.

Mirrowing Folder is similar to Transparent Folder but what becomes visible depends on the request URL. Therefore, name clashes are less of a problem.

2 Description

Mirrowing folder allows to mirror one subfolder M to be seen (through acquisition) in the other subfolders.

More precisely: If the request traverses an attribute A of the mirrowing folder along a subpath P leading to object oa, then the object om obtained by traversing along a maximal prefix of P starting in M is available in oa through acquisition.

Example:

   'M/registration' is mirrowed in 'en/registration'

   'M/subscribe/news' is mirrowed in 'en/subscribe/news'.

2.1 Use Case

MFolder was developed to build a complex multilingual site.

Of course, you want to separate language dependent content from language independent logic (and maybe language independent content), because the language dependent parts exist in variants for each language while the language independent parts exist only once. Nevertheless, the independent parts should be easily accessible from the language dependent parts -- as if they were in the same folders as they themselves.

One possibility to achieve this would be to place all independent parts above the language folders. This would give an unstructured, difficult to understand and maintain folder containing all the logic.

We could use transparent folders to alleviate the problem somewhat, but they suffer from name clash problems. If several objects with the same name exist in different folders, it is unclear, which object wins.

With mirrowing folder, your language dependent folders (one for each language) and your logic folder all have the same structure. The mirrowing magic uses acquisition to map each subfolder of the logic folder onto the corresponding subfolder in the language folders. As usual with acquisition, the attributes of this mirrowed subfolder and its ancestors can be directly accessed. Other subfolders are not directly visible.

Of course, this technique can be used whenever common objects should be easily used by various variants.

2.2 Properties

MirrowId__

the id of the subfolder to be mirrowed

3 Installation

Download the MFolder TGZ archive and unpack it into your Zope Products folder. Restart Zope. You should then find a Mirrowing Folder entry in your add-list.

4 License

This product is covered by a Python-like open source license. For details, see the Copyright notice at the top of MFolder.py.

5 History

0.02
Zope 2.7 compatibility

Dieter Maurer
Last modified: Fri Jan 2 20:38:00 CET 2004