just to conclude this: I inserted the controller code in the view instead 
which solved the problem: 

<h4><i class="icon-user"></i> me (from sidebar.html):</h4>
{{query=db.about.id>0}}
{{ab=db(query).select()}}
{{dict(ab=ab)}}
{{for pre in ab:}}
  {{for pr in pre.presentation.split():}}
  <dl class="dl">
  <dd><i class="icon-check"></i> {{=pr}}</dd>
  </dl>
  {{pass}}
  <h5><i class="icon-arrow-right"></i> Contact: {{=pre.contact}}</h5>
{{pass}}

but it would have been better to return the ab dict from the sidebar.py 
controller instead.  

On Saturday, December 22, 2012 11:24:11 PM UTC, jonas wrote:
>
> ok. thanks, that clarified the a few things. 
>
> On Saturday, December 22, 2012 10:48:35 PM UTC, Anthony wrote:
>>
>> On Saturday, December 22, 2012 5:00:52 PM UTC-5, jonas wrote:
>>
>>> Ok, I have a {{include}} statement in the beginning of the layout.html 
>>> file that cals index.html and the corresponding index.py controller. And 
>>> that one returns variables. So there is no way to call sidebar.py with tve 
>>> corresponding view to get the variables?
>>>
>>
>> That's not quite how it works. Views do not call controllers. Rather, 
>> when a URL is requested, web2py routes the request to a particular 
>> controller. Once the controller returns, then the view is executed. So, 
>> your browser calls /myapp/default/index. web2py receives that request, and 
>> after executing your model files, it runs the index() function in the 
>> default.py controller. After the index() function returns, it then executes 
>> the /views/default/index.html view (with the keys/values of the dict 
>> returned by the index() function being available as variables within the 
>> view). Your index.html view then extends the layout.html view, which means 
>> its code gets inserted in place of the {{include}} within layout.html. So, 
>> the {{include}} in layout.html is not calling index.html, and index.html is 
>> not calling the index() function -- the order is the exact opposite -- the 
>> index() function is called first, then the index.html view is executed, and 
>> finally the index.html view extends layout.html.
>>
>> Anthony
>>
>

-- 



Reply via email to