[Zope] An accessrule in python script

Danny William Adair danny@adair.net
Wed, 3 Oct 2001 10:07:38 +1200


Hi Gilles,

if your current script looks exactly like this:
----------------------------------------------------------------
from string import lower
request = container.REQUEST
machine = lower(request.HTTP_HOST)
servermap = {
  'www.site1.com': 'site1',
  'www.site2.com': 'site2'
  }
if servermap.has_key(machine):
    request['TraversalRequestNameStack'].append(servermap[machine])
----------------------------------------------------------------

and fails, then something odd is going on. I don't see any mistake.

Hold on...

If you're running Zope on a port other than 80,
machine = lower(split(request.HTTP_HOST, ':')[0])
should do the trick (to get rid of the :port)
I recognized you had used that in your DTML.

Did you "re"-set the access rule?

btw,
I haven't measured the impact of an "import", but have you tried _not_ to 
bind the namespace at all (unnecessary in this case)? Is it still slower?

hth,
Danny

On Wednesday 03 October 2001 09:43, Gilles Lenfant wrote:
> Danny,
>
> I made the changes you suggested with no success.
>
> Those test scripts gave me the same results after binding the namespace to
> "_", I got:
>
> == script 1 ==
> from string import lower
> return lower('SPAM')
> =========
>
> == script 2 ==
> return _.string.lower('SPAM')
> =========
>
> In addition, it seems that "importing" in an accessrule slows down the
> server.
>
> Cheers,
>
> --Gilles
>
>
>
> _______________________________________________
> 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 )