[mod_python] Joining template objects

Dagur Páll Ammendrup dagurp at heimsnet.is
Mon Nov 8 05:53:25 EST 2004


I tried that but I get:

TypeError: cannot concatenate 'str' and 'instance' objects


Daniele Cruciani wrote:

> Hi,
>
> simply bottom-up way:
>
> people=''
> for p in peopledict:
>     # call psp.PSP for each person
>     dic={'name':p['name'],....}
>     people=people+ psp.PSP(req,'person.html',vars=dic)
>
> dic={'people':people}
> yourpage=psp.PSP(req,'people.html',vars=dic)
>
> and return it, or you can do it inside the people template or make a
> function which return parsed person-s, called people a call it from
> people.html template
>
> Daniele.
>
> On Sat, Nov 06, 2004 at 10:12:57PM +0000, Dagur Páll Ammendrup wrote:
>  
>
>> I have a complete beginners question for you.
>> Here's a stupid example but I hope it explains what I'm trying to do. 
>> Let's say I have this template
>>
>> people.html
>>
>> |<h2>
>>  Here is a list of people
>>  <%= people %>
>> </h2>|
>>
>> Then there's another template:
>>
>> person.html
>>
>> |<p>
>>  Name: <%= name %>
>>  Occupation: <%= job %>
>>  Email <%= email %>
>> </p>|
>>
>> Now let's say I want to use person.html on a list of several people 
>> and I use psp.PSP() to do it.
>> How can I join the objects together and put them into the single 
>> 'people' varible for the outer 'people.html' template so I get this?
>>
>>
>> |<h2>
>>  Here is a list of people
>>  |
>> |<p>
>>  Name: John
>>  Occupation: programmer
>>  Email john at microsoft.com
>> </p>||
>>
>> ||<p>
>>  Name: Steven
>>  Occupation: Student
>>  Email steven at fbi.com
>> </p>
>>
>> ..etc
>>
>> ||</h2>
>>
>> |
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>   
>
>
>  
>



More information about the Mod_python mailing list