4teamwork / ftw.tika

This product integrates Apache Tika for full text indexing with Plone.
4 stars 1 forks source link

Figure out how portal_transforms handles equally short transform paths and policies #6

Closed lukasgraf closed 11 years ago

lukasgraf commented 11 years ago

The portal_transforms tool is largely undocumented.

Currently I'm not 100% clear about how decides which transform to pick if more than one transform with a direct path from INPUT to OUTPUT exists, and how transform policies factor into pathfinding.

Figure out how all this works, and modfiy our installation and uninstallation functions in setuphandlers.py accordingly.

lukasgraf commented 11 years ago

When trying to install a policy for an output type that already has a policy, a TransformException is raised.

lukasgraf commented 11 years ago

Products.PortalTransforms.TransformEngine.TransformTool.convertTo:139

        ## fastpath
        # If orig_mt and target_mt are the same, we only allow
        # a one-hop transform, a.k.a. filter.
        # XXX disabled filtering for now
        if orig_mt == str(target_mt):
            data.setData(orig)
            md = data.getMetadata()
            md['mimetype'] = str(orig_mt)
            if object is not None:
                cache.setCache(str(target_mimetype), data)
            return data
lukasgraf commented 11 years ago

This is done by first looking for a subpath leading from INPUT to INPUT_OF_FIRST_TRANSFORM_IN_CHAIN. If such a path is found, TransformTool._findPath() is called recursively with the remaining transforms from the chain as requirements, working its way trough the chain.

So to summarize: If a policy exists, and one or more paths exists to satisfy the policy, the shortest path satisfying that policy is chosen. Choosing the shortest path from the candidates is done using the same logic that's used when no policies exist.

lukasgraf commented 11 years ago

=> Without a policy, which of two equally short paths will be selected is undetermined.

lukasgraf commented 11 years ago
lukasgraf commented 11 years ago

Conclusion: