[Tutor] weird error messge

Conrad Koziol arkamir at softhome.net
Sun Nov 2 15:42:16 EST 2003


Hey can anyone help me. Whenever i run this script i get an error i cant
make anything of. Can someone explain it to me??

import MySQLdb
import re
import compare
import numberofpages
import display

db = MySQLdb.connect(host='localhost', user='conrad',
passwd='mysql4conrad', db='cgi')

cursor = db.cursor()

def retrieve_posts(forum, thread, end_post):
	giventemplate = 'posttemplate'
	inputtemplate = open(giventemplate, 'r')
	posttemplate = inputtemplate.read()
	inputtemplate.close()
	start_post = end_post - 20
	cursor.execute('''select names, dates, subjects, posts, positions from
%s where threads = \'%s\' and positions > \'%s\' and positions <
\'%s\'''' % (forum, thread, start_post, end_post))
	postsinfo = cursor.fetchall()
	
	#if i do postsinfo.sort() or 	#postsinfo.sort(compare.compare)
 	# it makes postsinfo = none

	postsinfo = list(postsinfo)
	posts = posttemplate
	subsitutes = ['NAME', 'DATE', 'SUBJECT', 'POST']
	hello = []
	
	
	for post in postsinfo:
		posts = re.sub('<!--***INSERT NAME HERE***-->', post[1], posts)
		posts = re.sub('<!--***INSERT DATE HERE***-->', post[2], posts)
		posts = re.sub('<!--***INSERT SUBJECT HERE***-->', post[3], posts)
		posts = re.sub('<!--***INSERT POST HERE***-->', post[4], posts)
		hello.append(posts)
		posts = posttemplate

	print hello

the error message is:

traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "retrieveposts.py", line 32, in retrieve_posts
    posts = re.sub('<!--***INSERT NAME HERE***-->', post[1], posts)
  File "/usr/lib/python2.2/sre.py", line 143, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib/python2.2/sre.py", line 229, in _compile
    raise error, v # invalid expression
sre_constants.error: multiple repeat
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "retrieveposts.py", line 32, in retrieve_posts
    posts = re.sub('<!--***INSERT NAME HERE***-->', post[1], posts)
  File "/usr/lib/python2.2/sre.py", line 143, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib/python2.2/sre.py", line 229, in _compile
    raise error, v # invalid expression
sre_constants.error: multiple repeat

this is posttemplate:

'<div class="postholder">\n\t<div
class="name">\n\t\t\t\t\t<br>\n\t\t\t\t\t <!--***INSERT NAME
HERE***-->\n\t\t\t\t\t<br>\n\t\t\t\t\t<p>Posted on: <!--***INSERT DATE
HERE***--> </p>\n\t</div>\n\t<div class="subject">\n\t\t\t <!--***INSERT
SUBJECT HERE***--> \n\t</div>\n\t<div class="post"> <!--***INSERT POST
HERE***-->
\n\t\t\t<br>\t\n\t\t\t<br>\n\t\t\t\n\t\t\t<br>\n\t\t\t<br>\n\t\t\
t<br>\n\t\t\t<br>\n\t\t\t<br>\n\t\t\t<br>\t\n\t</div>\n</div>\n'

THanks a lot,
	Conrad Koziol

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	





More information about the Tutor mailing list