Changeset 72

Show
Ignore:
Timestamp:
07/19/05 01:51:31 (3 years ago)
Author:
athomas
Message:

DiscussionPlugin:

  • Cleaned up some of the SQL queries.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • discussionplugin/trunk/discussion/core.py

    r67 r72  
    105105    def get_message(self, cursor, id, req): 
    106106        columns = ('id', 'forum', 'topic', 'replyto', 'time', 'body', 'author') 
    107         cursor.execute('SELECT %s FROM message WHERE id=%s' % (', '.join(columns), id)
     107        cursor.execute('SELECT id, forum, topic, replyto, time, body, author FROM message WHERE id=%i', id
    108108        row = cursor.fetchone() 
    109109        if not row: return None 
     
    114114    def get_topic(self, cursor, id, req): 
    115115        columns = ('id', 'forum', 'time', 'subject', 'body', 'author') 
    116         cursor.execute('SELECT %s FROM topic WHERE id=%s' % (', '.join(columns), id)
     116        cursor.execute('SELECT id, forum, time, subject, body, author FROM topic WHERE id=%s', id
    117117        row = cursor.fetchone() 
    118118        if not row: return None 
     
    123123    def get_forum(self, cursor, id, req): 
    124124        columns = ('name', 'moderators', 'id', 'time', 'subject', 'description') 
    125         cursor.execute('SELECT %s FROM forum WHERE name=\'%s\'' % (', '.join(columns), id)
     125        cursor.execute('SELECT name, moderators, id, time, subject, description FROM forum WHERE name=%s', id
    126126        row = cursor.fetchone() 
    127127        if not row: return None 
     
    144144    def get_topics(self, cursor, forum, req): 
    145145        columns = ('id', 'forum', 'time', 'subject', 'body', 'author', 'replies') 
    146         cursor.execute('SELECT id, forum, time, subject, body, author, (SELECT COUNT(id) FROM message m WHERE m.topic = topic.id) FROM topic WHERE forum = %s ORDER BY time' % forum
     146        cursor.execute('SELECT id, forum, time, subject, body, author, (SELECT COUNT(id) FROM message m WHERE m.topic = topic.id) FROM topic WHERE forum = %i ORDER BY time', int(forum)
    147147        topics = [] 
    148148        for row in cursor.fetchall(): 
     
    154154    def get_messages(self, cursor, topic, req): 
    155155        columns = ('id', 'replyto', 'time', 'body', 'author') 
    156         cursor.execute('SELECT %s FROM message WHERE topic=%s ORDER BY time' % (', '.join(columns), topic)
     156        cursor.execute('SELECT id, replyto, time, body, author FROM message WHERE topic=%s ORDER BY time', topic
    157157 
    158158        messagemap = {} 
  • discussionplugin/trunk/discussion/wiki.py

    r66 r72  
    2626        cursor = db.cursor() 
    2727        if ns == 'forum': 
    28             cursor.execute('SELECT subject FROM forum WHERE name=\'%s\'' % id) 
     28            cursor.execute('SELECT subject FROM forum WHERE name=%s', id) 
    2929            row = cursor.fetchone() 
    3030            if row: 
     
    3434                return '<a href="%s/%s" class="missing">%s?</a>' % (self.env.href.discussion(), id, label) 
    3535        elif ns == 'topic': 
    36             cursor.execute('SELECT forum, (SELECT subject FROM forum WHERE id=topic.forum), subject FROM topic WHERE id=%i' % id) 
     36            cursor.execute('SELECT (SELECT name FROM forum WHERE id=topic.forum), (SELECT subject FROM forum WHERE id=topic.forum), subject FROM topic WHERE id=%i', id) 
    3737            row = cursor.fetchone() 
    3838            if row: 
     
    4040                return '<a href="%s/%s/%s" title="%s: %s">%s</a>' % (self.env.href.discussion(), forum, id, forum_subject, subject, label) 
    4141        elif ns == 'message': 
    42             cursor.execute('SELECT forum, topic, (SELECT subject FROM forum WHERE id=message.forum), (SELECT subject FROM topic WHERE id=message.topic) FROM message WHERE id=%i' % id) 
     42            cursor.execute('SELECT (SELECT name FROM forum WHERE id=message.forum), topic, (SELECT subject FROM forum WHERE id=message.forum), (SELECT subject FROM topic WHERE id=message.topic) FROM message WHERE id=%i', id) 
    4343            row = cursor.fetchone() 
    4444            if row: