[Zope] An accessrule in python script

Gilles Lenfant glenfant@bigfoot.com
Tue, 2 Oct 2001 17:11:03 +0200


Hi,

I wanted to improve the speed of my sites translating the DTML method
accessrule into a python script.
But when the DTML method works, the equivalent (?) python script doesn't
(always show the default Zope page).

Any clue ?

Thanks in advance

--Gilles

========My DTML method========
<dtml-let domaine="_.string.split(_.string.lower(_.string.split(HTTP_HOST,
':')[0]), '.')[-3:]">
<dtml-if "_['domaine']==['www', 'site1', 'com']">
   <dtml-call "REQUEST.path.append('site1')">
<dtml-elif "_['domaine']==['www', 'site2', 'com']">
   <dtml-call "REQUEST.path.append('site2')">
</dtml-if>
</dtml-let>
========End DTML method========
========My Python script ========
machine = _.string.lower(context.REQUEST.HTTP_HOST)
servermap = {
  'www.site1.com': 'site1',
  'www.site2.com': 'site2'
  }
if servermap.has_key(machine):
    context.REQUEST.append(servermap[machine])
return