[Zope] ZCatalog + Virtual Hosting = Trouble

Chris McDonough chrism@digicool.com
Thu, 8 Feb 2001 13:58:56 -0500


Are you using 2.3.0?  It has fixes in it for this.

----- Original Message -----
From: "Edmund Goppelt" <goppelt@goppelt.net>
To: <zope@zope.org>
Sent: Thursday, February 08, 2001 1:23 PM
Subject: [Zope] ZCatalog + Virtual Hosting = Trouble


> It seems a well established fact that ZCatalog does not work properly
> with virtual hosting.  I've tried Evan Simpson's ZCatalog patch, but
> to no avail:
>
>
> ***DOES NOT WORK
>    def resolve_url(self, path, REQUEST):
>        """
>        Attempt to resolve a url into an object in the Zope
>        namespace. The url may be absolute (site-relative) or a catalog
path
>        style url. If no object is found, None is returned.
>        No exceptions are raised.
>        """
>        pparts = filter(None, string.split(path, '/'))
>        try:
>             obj = getattr(self.aq_parent, pparts.pop(0))
>             while pparts:
>                   obj = obj[pparts.pop(0)]
>             return obj
>        except:
>             return
>
>
> The following *does* seem to work.  Can someone tell me why?  Are
> there any nasty side effects I should know about, or is this a good
> way of getting ZCatalog to play nice with Virtual Hosting?
>
> ***WORKS
> def resolve_url(self, path, REQUEST):
>         """
>         Attempt to resolve a url into an object in the Zope
>         namespace. The url may be absolute or a catalog path
>         style url. If no object is found, None is returned.
>         No exceptions are raised.
>         """
>         pparts=filter(None, string.split(path, '/'))
>         try:
>             obj=getattr(self.aq_parent, pparts.pop(0))
>             while pparts:
>                 obj=getattr(obj, pparts.pop(0))
>             return obj
>         except:
>             return
>
> --
>
> Ed Goppelt
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>