[Zope-dev] [IDEA] ZopeRoot and SiteRoot

Lennart Regebro lennart@regebro.nu
Mon, 17 Dec 2001 17:48:12 +0100


From: "Casey Duncan" <c.duncan@nlada.org>
> Now unless something has been done about this that I'm not aware of, this
is
> still true. Assuming that here is my idea: Add a method to the Root
Folder,
> ZopeRoot, which returns the Root Folder. This would work:
>
> def ZopeRoot(self):
>     """Return Thyself"""
>     return self
>
> This would go along with ZopeTime and always be available in the general
> namespace for folks to use.
>
> Another idea also struck me. That SiteRoot should also be a callable
object
> (if it exists) returning the Root folder of the sub-site. Now this may
> already be the case, but if not I thought it might be worthwhile.

Well, these things should be done together. What is needed is a complete set
of functions for getting the objects path, URL sitename and root, both with
and without SiteRoot/VHM. And the virtual functions should work by asking
the SiteRoot/VHM for the information, instead of as today getting the
information from the request, since you may want to find out the virtual
path of objects in another part of the site that has another virtual root
than the object you are calling from does.

For example, like this:
getPhysicalPath()    would return ('', 'site', 'folder', 'foo', 'bar')
getPhysicalURL()    would return '/site/folder/foo/bar/'  <Note the ending
slash>
getPhysicalHost()    would return 'http://real.domain.com' <Note the absence
of an ending slash>
getPhysicalRootObj()    Returns the object that is your root, in this case
the root.

getVirtualPath()    would return ('', 'folder', 'foo', 'bar')
getVirtualURL()    would return '/folder/foo/bar/'  <Note the ending slash>
getVirtualHost()    would return 'http://virtual.domain.com' <Note the
absence of an ending slash>
getVirtualRootObj()    Returns the object that is your root, in this case
the object called /site.