This qualifies as: Yet another idea that I'm not sure deserves a fishbowl proposal yet, or is big enough to even need one. In making some recent changes to the Application.py module in Zope which houses the class for the Zope Root Folder, it occurred to me that I could solve an issue that has bugged me for a while: You have to use the silly REQUEST.PARENTS[-1] to get the darn Root Folder inside Zope. 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. Thoughts? /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
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.
getPhysicalRoot already exists, and returns the top-level app object when called from any Zope object. ----- Original Message ----- From: "Lennart Regebro" <lennart@regebro.nu> To: "Casey Duncan" <c.duncan@nlada.org>; <zope-dev@zope.org> Sent: Monday, December 17, 2001 11:48 AM Subject: Re: [Zope-dev] [IDEA] ZopeRoot and SiteRoot
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.
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
On Monday 17 December 2001 12:20 pm, Chris McDonough allegedly wrote:
getPhysicalRoot already exists, and returns the top-level app object when called from any Zope object.
You know I had a sneaking suspicion that this existed somewhere, which is why I didn't go ahead and fishify it. Thanks for pointing that out. Is there a comparable all to get the site root? /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
Hmm... no, I dont think there's a call to get the virtual root. Although I imagine it would be pretty simple to add. ----- Original Message ----- From: "Casey Duncan" <c.duncan@nlada.org> To: "Chris McDonough" <chrism@zope.com>; "Lennart Regebro" <lennart@regebro.nu>; <zope-dev@zope.org> Sent: Monday, December 17, 2001 12:45 PM Subject: Re: [Zope-dev] [IDEA] ZopeRoot and SiteRoot
On Monday 17 December 2001 12:20 pm, Chris McDonough allegedly wrote:
getPhysicalRoot already exists, and returns the top-level app object when called from any Zope object.
You know I had a sneaking suspicion that this existed somewhere, which is why I didn't go ahead and fishify it. Thanks for pointing that out.
Is there a comparable all to get the site root?
/---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
From: "Chris McDonough" <chrism@zope.com>
Hmm... no, I dont think there's a call to get the virtual root. Although I imagine it would be pretty simple to add.
Yes it is. This works with SiteAccessEnhanced (where EASY_VHM has to be the name if the host monster) security.declarePublic('getVirtualRootPath') def getVirtualRootPath(self): req = self.REQUEST rpp = req.get('VirtualRootPhysicalPath', None) if rpp is None: vhm = getattr(self, EASY_VHM, None) if vhm is None: return ('',) else: rules = vhm.display_rules() physical_path = self.getPhysicalPath() best_match = ('',) for domain,path in rules: match_path = path = split(path,'/') if len(path)<=len(physical_path): index = 0 for pid in path: if physical_path[index]!=pid: match_path = None break index = index + 1 if match_path != None: if len(match_path) > len(best_match): best_match = match_path return tuple(best_match) return rpp And when you have the path you can get the object.
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.
FYI most of what you're proposing already exists in CMF (using portal_url), it's only a matter of time before it's folded back into Zope (Zope 3 :-). Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 10 http://nuxeo.com mailto:fg@nuxeo.com
On Monday 17 December 2001 12:45 pm, Florent Guillaume allegedly wrote:
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.
FYI most of what you're proposing already exists in CMF (using portal_url), it's only a matter of time before it's folded back into Zope (Zope 3 :-).
Florent
That's the general idea. Except that somebody has to actually do it. 8^) /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
On Mon, 17 Dec 2001 10:16:09 -0500, Casey Duncan <c.duncan@nlada.org> wrote:
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.
That makes sense for the simple virtual-hosting scenario of one-folder-per-virtual-hosts, however what you suggest cant be achieved in the general case. Given an arbitrarily complicated set of rewrite rules, the concept of 'Site Root' is not well defined. Its called VirtualHost*Monster* for a reason ;-) Toby Dickenson tdickenson@geminidataloggers.com
participants (5)
-
Casey Duncan -
Chris McDonough -
Florent Guillaume -
Lennart Regebro -
Toby Dickenson