Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Most basic way to display Data from Database in a HTML table row-by-row
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
SMERSH009  
View profile  
 More options Jul 3 2007, 3:49 am
From: SMERSH009 <SMERSH0...@gmail.com>
Date: Tue, 03 Jul 2007 07:49:11 -0000
Local: Tues, Jul 3 2007 3:49 am
Subject: Most basic way to display Data from Database in a HTML table row-by-row
Hi All,
I am trying to display Data from a database table to display in a
Table format.
Right now the results are just being bunched up together. For example,
when displayed in the web browser the ${ids} returns 1922  instead of
19
22
Now I know that this seems like a basic question, but I looked all
over the tutorials, and they seem to concentrate on displaying ALL the
data at once, and not to display one row at a time.

model.py contains:

class WebAppPages(SQLObject):
    class sqlmeta:
        style=Style(longID=True)
        idName='pageID'

    pageName= UnicodeCol()
    url = UnicodeCol(notNone=True)
    post = BoolCol(default=False)

controllers.py contains. And I am sure this is wrong...:

class Root(controllers.RootController):
    @expose(template="formstutorial.templates.index")
    def index(self):
        result= WebAppPages.select()
        names = map(lambda x: x.pageName ,list(result))
        urls = map(lambda x: x.url , list(result))
        ids = map(lambda x: x.id , list(result))
        return dict(names=names,urls=urls,ids=ids)

index.kid contains:

<html>
<head><title>Webapptests</title></head>
<body>

${urls}
${names}
${ids}
</body>
</html>

Thank you!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alex bodnaru  
View profile  
 More options Jul 3 2007, 4:09 am
From: alex bodnaru <alexb...@012.net.il>
Date: Tue, 03 Jul 2007 11:09:09 +0300
Local: Tues, Jul 3 2007 4:09 am
Subject: Re: [TurboGears] Most basic way to display Data from Database in a HTML table row-by-row
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi,

i'm about to finish a small piece of code that will display all rows in
a table of your choice, with the option to also add, delete and update
rows through ajax.

hope to publish this today or tomorrow.

alex

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRooEJdpwN1sq38njAQL7OwP6A9wBXY4ILqZicxBX+9e3vGO/JsdKVOhS
lJHkE9iMizci6lPEbNczpYNqLLRw1sPB7R46UwWq3xKccfwX/PbITc3nHJred3bB
KK32cuBVezweeScm9Qc367/8EaCEy2Sswo6yW0pG5+Oje0qvIzxBjKE7zfC0DoCF
/CcEmP6SxIM=
=cvPo
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johnny Blonde  
View profile  
 More options Jul 3 2007, 7:12 am
From: Johnny Blonde <frank.wagner.1...@googlemail.com>
Date: Tue, 03 Jul 2007 11:12:47 -0000
Local: Tues, Jul 3 2007 7:12 am
Subject: Re: Most basic way to display Data from Database in a HTML table row-by-row
controller:
-------------------------------------
results = TableToDisplay.select()
return dict(results=results)

template
------------------------------------------
<html>
<head><title>Webapptests</title></head>
<body>

<table>
  <tr py:for="row in result">
    <td py:content="row['name']">
    <td py:content="row['url']">
    <td py:content="row['id']">
  </tr>
</table>

</body>
</html>
---------------------------------------------
doesn´t this work?

On 3 Jul., 09:49, SMERSH009 <SMERSH0...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SMERSH009  
View profile  
 More options Jul 3 2007, 12:33 pm
From: SMERSH009 <SMERSH0...@gmail.com>
Date: Tue, 03 Jul 2007 16:33:27 -0000
Local: Tues, Jul 3 2007 12:33 pm
Subject: Re: Most basic way to display Data from Database in a HTML table row-by-row
Hi Johnny, your code was close, but is returning an error in the .kid
file
<tr py:for="row in result">     This line returns: the prefix "py" for
attribute "py:for" associated with an element type tr
is not bound

 Alex, since having to edit these rows was going to be the next step
in this difficult project (I am a newbie to Python), you are going to
be my lifesaver if your code will work. I will keep checking the
thread for your guys' updates.

On Jul 3, 4:12 am, Johnny Blonde <frank.wagner.1...@googlemail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim Steil  
View profile  
 More options Jul 3 2007, 2:42 pm
From: Jim Steil <st...@mailbag.com>
Date: Tue, 03 Jul 2007 13:42:32 -0500
Local: Tues, Jul 3 2007 2:42 pm
Subject: Re: [TurboGears] Re: Most basic way to display Data from Database in a HTML table row-by-row

In the sample below you'll need to change the 'result' to 'results' in
the html portion.  That is what is being returned in the dict.

    -Jim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SMERSH009  
View profile  
 More options Jul 3 2007, 4:33 pm
From: SMERSH009 <SMERSH0...@gmail.com>
Date: Tue, 03 Jul 2007 20:33:14 -0000
Local: Tues, Jul 3 2007 4:33 pm
Subject: Re: Most basic way to display Data from Database in a HTML table row-by-row
Sorry Jim, I should have specified that this error pops up whether or
not I have it set to 'result' or 'results.'
"the prefix "py" for attribute "py:for" associated with an element
type tr is not bound "

Turbogears1.0 Python v2.5.1c
Here is what the template file looks like in my code to match the
columns in my DB.
Thanks...

<html>
<head><title>Webapptests</title></head>
<body>

<tr py:for="row in results">
<td py:content="row['pageID']">
<td py:content="row['pageName']">
<td py:content="row['url']">
</tr>
</table>

</body>
</html>

On Jul 3, 11:42 am, Jim Steil <s...@mailbag.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alaa Salman  
View profile  
 More options Jul 3 2007, 5:41 pm
From: "Alaa Salman" <alaasal...@gmail.com>
Date: Wed, 4 Jul 2007 00:41:10 +0300
Local: Tues, Jul 3 2007 5:41 pm
Subject: Re: [TurboGears] Re: Most basic way to display Data from Database in a HTML table row-by-row

I believe that you need to specify the proper namespace in the kid template
and give it the "py" alias. Check the example in any quickstart application.

Regards,
Alaa Salman

On 7/3/07, SMERSH009 <SMERSH0...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim Steil  
View profile  
 More options Jul 3 2007, 5:47 pm
From: Jim Steil <st...@mailbag.com>
Date: Tue, 03 Jul 2007 16:47:37 -0500
Local: Tues, Jul 3 2007 5:47 pm
Subject: Re: [TurboGears] Re: Most basic way to display Data from Database in a HTML table row-by-row

In no way do I claim to understand why/how all of this works, but in all
of my page templates my html tag looks something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#"
    py:extends="'master.kid'">

    -Jim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SMERSH009  
View profile  
 More options Jul 3 2007, 9:00 pm
From: SMERSH009 <SMERSH0...@gmail.com>
Date: Wed, 04 Jul 2007 01:00:46 -0000
Local: Tues, Jul 3 2007 9:00 pm
Subject: Re: Most basic way to display Data from Database in a HTML table row-by-row
Ahh, I finally got it... with your guys' help of course :)
This was the way to display the Column value of a specific row:  <td
py:content="row.pageName"></td>
The format:            <td py:content="row['name']">   was throwing
errors for me.
The final product is below...
I am still eagerly awaiting for the kind of good stuff Alex has in
mind.

Happy 4th of July everyone!!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/
kid/ns#"
    py:extends="'master.kid'">
<head>

<title>Webapptests</title></head>
<body>

<table border="1">
<tr py:for="row in results">
<td py:content="row.id"></td>
<td py:content="row.pageName"></td>
<td py:content="row.url"></td>
</tr>
</table>

</body>
</html>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »