My web app has a MessengerInfo class with the following fields:
id,unit_number,owner_name

I'm fetching many messages from a pop mail server and putting them
into the database using a MessageInfo class with the following fields:
id,unit_number,latitude,longitude

Then in my app I display the messages using a messages.kid template,
using a table with the same columns as in the MessageInfo class.  The
issue is that this list is not very friendly. It would be better to
show the owner's name rather than the unit_number of his instrument.
I'm wondering what is the best way to fetch that information?

Do I need to create a join? If so, what type of join - SingleJoin?
RelatedJoin?  Or can I do something with a search in the template
itself?  I'm confused!

Here's part of my template:

 <tr py:for="msg in messages">
<td>${msg.id}</td><td>${msg.unit_number}</td><td>${owner}</td><td>$
{msg.latitude}</td><td>${msg.longitude}</td>

The issue is how to get the value for owner.   I'd like to just add
something like the following in side the 'for' loop in my template:
<?python
m = MessengerInfo.select(MessengerInfo.q.unit_number==msg.unit_number)
owner = m[0].unit_number  #there should be only record in the search
result
?>

But it doesn't seem possible to do databases from inside the template.
Or is it?  And even if it is, is that the best way to get the info I
want?

Thanks for any suggestions.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to