contained2pathadapter.py
2008-01-11 19:14...
### -*- coding: utf-8 -*- #############################################
#######################################################################
"""Product class for the Zope 3 based product package
$Id: product.py 12897 2007-11-10 15:32:08Z cray $
"""
__author__ = "Yegor Shershnev"
__license__ = "GPL"
__version__ = "$Revision: 12897 $"
from zope.interface import implements, implementedBy
from zope.app.container.interfaces import IContained
from interfaces import IPath
from zope.component import adapts
class Contained2PathAdapter(object) :
implements(IPath)
adapts(IContained)
def __init__(self, ob) :
self.context = ob
@property
def path(self) :
ob = self.context
lp = []
while IContained.providedBy(ob) and IContained(ob).__parent__ :
lp.append(IContained(ob).__name__)
ob = IContained(ob).__parent__
lp.reverse()
return "/".join(lp)



