@Anand I did what you said, which effectively is also what @Andrei said,
however the CPU time does not improve, look at the profiling output:

+++

took 0.402858018875 seconds
         71906 function calls (41723 primitive calls) in 0.403 CPU seconds

   Ordered by: internal time, call count
   List reduced from 437 to 40 due to restriction <40>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 5703/342    0.041    0.000    0.239    0.001 transformer.py:1060(com_binary)
   8597/4    0.036    0.000    0.277    0.069 transformer.py:787(com_node)
 6484/677    0.033    0.000    0.033    0.000 transformer.py:73(extractLineNo)
   2447/2    0.030    0.000    0.048    0.024 template.py:1115(visit)
      709    0.020    0.000    0.022    0.000 transformer.py:751(decode_literal)
     8806    0.017    0.000    0.017    0.000 transformer.py:784(lookup_node)
 1074/678    0.009    0.000    0.148    0.000 transformer.py:699(factor)
   1018/2    0.008    0.000    0.278    0.139 transformer.py:1072(com_stmt)
 1074/678    0.008    0.000    0.142    0.000 transformer.py:712(power)
        2    0.007    0.004    0.285    0.143 transformer.py:121(transform)
      709    0.007    0.000    0.030    0.000 transformer.py:762(atom_string)
        2    0.007    0.003    0.375    0.188 template.py:862(compile_template)
        2    0.006    0.003    0.291    0.146 transformer.py:127(parsesuite)
      455    0.006    0.000    0.008    0.000 application.py:605(check)
  342/336    0.006    0.000    0.112    0.000
transformer.py:1209(com_call_function)
 1074/678    0.006    0.000    0.155    0.000 transformer.py:681(term)
 1072/676    0.006    0.000    0.227    0.000 transformer.py:579(test)
 1074/678    0.005    0.000    0.161    0.000 transformer.py:669(arith_expr)
 1074/678    0.005    0.000    0.167    0.000 transformer.py:656(shift_expr)
    676/2    0.005    0.000    0.278    0.139
transformer.py:1079(com_append_stmt)
 1072/676    0.005    0.000    0.221    0.000 transformer.py:593(or_test)
 1074/677    0.005    0.000    0.203    0.000 transformer.py:604(not_test)
 1073/677    0.005    0.000    0.198    0.000 transformer.py:611(comparison)
 1072/676    0.004    0.000    0.212    0.000 transformer.py:600(and_test)
     2447    0.004    0.000    0.004    0.000 template.py:1117(classname)
 1074/678    0.004    0.000    0.176    0.000 transformer.py:652(and_expr)
 1074/678    0.004    0.000    0.184    0.000 transformer.py:648(xor_expr)
1074/1071    0.004    0.000    0.038    0.000 transformer.py:725(atom)
 1074/678    0.004    0.000    0.192    0.000 transformer.py:644(expr)
   1018/2    0.004    0.000    0.278    0.139 transformer.py:305(stmt)
      334    0.004    0.000    0.266    0.001 transformer.py:312(simple_stmt)
      698    0.004    0.000    0.006    0.000 ast.py:18(flatten_nodes)
      334    0.003    0.000    0.011    0.000 template.py:167(readline)
  703/698    0.003    0.000    0.003    0.000 ast.py:7(flatten)
      334    0.003    0.000    0.243    0.001 transformer.py:410(yield_expr)
      334    0.002    0.000    0.248    0.001 transformer.py:406(yield_stmt)
  341/312    0.002    0.000    0.017    0.000 template.py:86(read_section)
      361    0.002    0.000    0.003    0.000 transformer.py:768(atom_name)
  378/377    0.002    0.000    0.004    0.000 utils.py:217(safeunicode)
      334    0.002    0.000    0.003    0.000 template.py:558(emit)

+++

As you can see most of the time is spent in transformer.py which I believe
has a lot to do with the compilation process, so even when the render is
declared just after the url paths declaration it seems to be compiling. 0,4s
per page rendering is absolutely not acceptable since, making *very rough*
calculations it would mean that I can serve 2,5 users per seconds per core,
If I have 2 cores I would be able to serve 5 users per second, once I have
more than 5 concurrent users per second I would start to build up a queue.

P.D.: @Greg Milby, indeed cookies for languages is just a quick solution
which I will probably change in a near future. I am not that worried about
their volatility, my main concern is that search engines will not index
languages other than english since the robots will not be using any cookie
when visiting the site. I think the best is to actually have something in
the path that reveals the language, either something like /en/rest_of_path
or something like en.domain.com.

Thanks for all the replies being received.

2010/6/15 Anand Chitipothu <[email protected]>

> 2010/6/15 Emiliano Martinez Contreras <[email protected]>:
> > Hi Anand,
> >
> > Thanks for the quick reply. In my main sitemanager app what I do is use a
> > cookie to find out the language of the visitor, according to that cookie
> a
> > locale template path is chosen, so what I have is a hook which I then add
> as
> > a preprocessor:
> >
> > +++
> >
> > def render_hook():
> >     cookies = web.cookies(lang="en")
> >     lang = cookies.lang
> >
> >     if lang in settings.VALID_LANGS:
> >         locales_path = os.path.join(settings.TEMPLATES_PATH,
> "%s/"%(lang))
> >
> >     else:
> >         locales_path = os.path.join(settings.TEMPLATES_PATH,"en/")
> >
> >     web.ctx.render = web.template.render(locales_path,
> globals={'session':
> > web.ctx.session})
>
> Try changing it to:
>
> def render_hook():
>    cookies = web.cookies(lang="en")
>    lang = cookies.lang
>     if lang not in settings.VALID_LANGS:
>        lang = "en"
>    web.ctx.render = getattr(render, lang)
>
> render = web.template.render(settings.TEMPLATES_PATH)
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected] <webpy%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to