[Zope] Accessrule and site root folder "in the depth" of the zope tree
Danny William Adair
danny@adair.net
Tue, 16 Oct 2001 09:54:47 +1300
Hi Gilles!
The TraversalRequestNameStack is a list (handled like a stack) and holds the
object ids separately. If you access "myObject" in the subfolder
"mySubfolder" underneath the Zope root folder for example, the
TraversalRequestNameStack will look like this:
['myObject','mySubFolder']
(yes, in reverse order)
An object with the id 'somewhere/site2' does not exist, so you would have to
append two string to the list...
In your case, I would not "append" a single item to a list, but append a
whole list to a list, with single items being lists with one item:
servermap = {
'www.site1.com': ['site1'],
'www.site2.com': ['site2','somewhere']
}
machine = _.string.lower(_.string.split(context.REQUEST.HTTP_HOST, ':')[0])
if servermap.has_key(machine):
context.REQUEST.set('TraversalRequestNameStack',
context.REQUEST['TraversalRequestNameStack']+servermap[machine])
return
Again, keep in mind the reverse order inside your lists. Of course you could
make this a little more elegant, since you call
context.REQUEST['TraversalRequestNameStack'] twice.
hth,
Danny
On Saturday 13 October 2001 07:51, Gilles Lenfant wrote:
> Hi,
>
> As you can see in the nexts script (accessrule), I want all request to
> www.site2.com to start from the Zope folder "somewhere/site2" (2nd level of
> ZODB tree) but it does not work when it works for site1 (like all others at
> first level of ZODB tree).
> Is there something I missed (I'm sure I did but what... :)).
>
> Thanks in advance.
>
> --Gilles
>
> ================
> servermap = {
> 'www.site1.com': 'site1',
> 'www.site2.com': 'somewhere/site2'
> }
> machine = _.string.lower(_.string.split(context.REQUEST.HTTP_HOST, ':')[0])
> if servermap.has_key(machine):
> context.REQUEST['TraversalRequestNameStack'].append(servermap[machine])
> return
>
>
>
> _______________________________________________
> 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 )