[Zope-dev] SiteAccess Newbie

Juan David Ibáñez Palomar palomar@sg.uji.es
Sat, 10 Feb 2001 10:18:29 +0100 (MET)


The HowTo is updated, perhaps you want to look at it. Let me
know if it's still slow. Remember that you can do profiling
in "/Control_Panel/DebugInfo/manage_profile".


> 
> Hi,
> 
> I just implemented virtual hosting on our web server combining multiple virtual 
> hosts and localization as described in the corresonding how-to. But it's very 
> (very) slow. How can I speed it up?
> 
> Following the External Python Method I used for the Access Rule:
> 
> import string
> 
> def get_language(self, REQUEST):
>   cookie = 'LANG'
>   if self.REQUEST.cookies.has_key(cookie):
>    lang = self.REQUEST.cookies[cookie]
>   else:
>    langs = string.split(self.REQUEST['HTTP_ACCEPT_LANGUAGE'], ',')
>   for lang in langs:
>    lang = string.strip(lang)
>    if lang:
>     lang = string.split(lang, ';')[0]
>     break
>   if not hasattr(self, lang):
>    if string.find(lang,'-')>=0:
>     lang = string.split(lang,'-')[0]
>    if not hasattr(self, lang):
>     lang = 'de'
>   return lang
> 
> def localize(self, REQUEST):
>   sitemap  = { ... }
>   hostname = 
> string.join(string.split(string.lower(string.split(self.REQUEST['HTTP_HOST'], 
> ':')[0]), '.')[-4:], '.')
>   lang     = self.get_language(self.REQUEST)
>   stack    = self.REQUEST['TraversalRequestNameStack']
> 
>   if stack and stack[-1]=='Z':
>    stack.pop()
>    self.REQUEST.setVirtualRoot('Z')
>   else:
>    if sitemap.has_key(hostname):
>     self.REQUEST.set('SiteRootPATH', '/')
>     self.REQUEST['TraversalRequestNameStack'].extend([lang, sitemap[hostname]])
>    else:
>     self.REQUEST.set('SiteRootPATH', '/')
> 
> 
> _______________________________________________
> 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 )
> 
>