Hi,

I'm trying to proxy a persistent content object with a non-persistent
object that intercepts calls to absolute_url.  The proxy object looks
like this::


class Proxy:

    def __init__(self, context, brain):
        self.context = context
        self.obj = obj

    def absolute_url(self):
        return munged_url_for_obj

    def _getLocal(self, key):
        if self.__dict__.has_key(key):
            return self.__dict__[key]

    def __getitem__(self, key):
        # Defer to the brain for most things.
        return self._getLocal(key) or self.obj[key]

    def __getattr__(self, name):
        # Defer to the brain for most things.
        return self._getLocal(name) or getattr(self.obj, name)


This proxy object gets used in a page template.  This works fine (i.e.
it returns `munged_url_for_obj') when I use an expression like
"python:proxy.absolute_url()".  However, when I use a normal path
expression, like "proxy/absolute_url", I get back the unmunged url (i.e.
obj.absolute_url()).

I'm a little confused as to what's going wrong for me.  My best guess is
that Products.PageTemplates.Expressions.restrictedTraverse (called
Products.PageTemplates.Expressions.SubPathExpr._eval) isn't designed to
like my proxy object.  But I'm not even sure of that much, and I can't
figure where to put a pdb.set_trace() as I can't put it in the obvious
place just before the "proxy/absolute_url".

Any ideas?


Tim

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to