Wed Development - Dynamically Generated News Index

2005-12-17 Thread infidel02
Hi to all,

I am somewhat somewhat new to Python, but apart from this I am just not
seeing lots of resources on what I am trying to do.  I have seen them
in other languages like PHP and ASP.

I am building a simple MySQL news database,  which would contain, a
headline, a date, main story(body) and a graphic associated with each
story.  I would like to generate an index of the pages in this database
( ie a news index with links to the articles) an to have a news
administrator upload and delete stories graphic etc.

I have read many articles on Python CGI programming and I have Googled
extensively, but have not seen any kind of examples of how this can be
done in Python.

I would be grateful for any assistance or pointers.

Sincerely,

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wed Development - Dynamically Generated News Index

2005-12-18 Thread infidel02
Hi Jean-Paul,

I am a bit lost in you code.  Is it possible for you to step through
it?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wed Development - Dynamically Generated News Index

2005-12-20 Thread infidel02
Hi Jean-Paul,

The truth of the matter is that I was hoping that this could be
accomplished using pure CGI.

I am considering wether I need to learn these new frameworks, but I am
in somewhat of a hurry.

Also I have this problem with this simple test script that I have
written.  It pulls the infromation from the database correctly, but is
printing out the html tags in the browser, not sure what is wrong:

Script

#!/usr/bin/python

# import MySQL module
import MySQLdb, cgi

# connect
db = MySQLdb.connect(host="localhost", user="nancy",
passwd="intentions",
db="ardDB")

# create a cursor
cursor = db.cursor()

# execute SQL statement
cursor.execute("SELECT * FROM news where storyDATE < '2005-10-1';")

# get the resultset as a tuple
result = cursor.fetchall()

db.close()

print """ Content-Type: text/html\n\n
  
  

  DB Test

  

  

  """

# iterate through resultset
for record in result:

print """%s

 %s

 %s

   """ %(record[1],record[2],record[3])




print   """

  

  

  """


Results:



  

  DB Test

  

  


Heading 4

 Body 4

 2005-09-01


Heading 5

 Body 5

 2005-09-10


Heading 6

 Body 6

 2005-09-12




  
  
  

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wed Development - Dynamically Generated News Index

2005-12-20 Thread infidel02
Hi Jean-Paul,

The truth of the matter is that I was hoping that this could be
accomplished using pure CGI.

I am considering wether I need to learn these new frameworks, but I am
in somewhat of a hurry.

Also I have this problem with this simple test script that I have
written.  It pulls the infromation from the database correctly, but is
printing out the html tags in the browser, not sure what is wrong:

Script

#!/usr/bin/python

# import MySQL module
import MySQLdb, cgi

# connect
db = MySQLdb.connect(host="localhost", user="nancy",
passwd="intentions",
db="ardDB")

# create a cursor
cursor = db.cursor()

# execute SQL statement
cursor.execute("SELECT * FROM news where storyDATE < '2005-10-1';")

# get the resultset as a tuple
result = cursor.fetchall()

db.close()

print """ Content-Type: text/html\n\n
  
  

  DB Test

  

  

  """

# iterate through resultset
for record in result:

print """%s

 %s

 %s

   """ %(record[1],record[2],record[3])




print   """

  

  

  """


Results:



  

  DB Test

  

  


Heading 4

 Body 4

 2005-09-01


Heading 5

 Body 5

 2005-09-10


Heading 6

 Body 6

 2005-09-12




  
  
  

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wed Development - Dynamically Generated News Index

2005-12-20 Thread infidel02
Thank Steve this worked!

-- 
http://mail.python.org/mailman/listinfo/python-list