Wie geht das schöner (oder besser)
Verfasst: Samstag 18. Dezember 2004, 17:09
Hallo zusammen,
Ich arbeite wieder an meinem Forum und hab mir eure vorschläge aus
http://python.sandtner.org/viewtopic.php?t=1287
zu Herzen genommen
Jetzt hab ich hier eine Methode die mir nicht gefällt:
wie schreibe ich sowas ohne diese ständige Wiederholung?
Danke Andreas
Ich arbeite wieder an meinem Forum und hab mir eure vorschläge aus
http://python.sandtner.org/viewtopic.php?t=1287
zu Herzen genommen

Jetzt hab ich hier eine Methode die mir nicht gefällt:
Code: Alles auswählen
def SELECT_Topic_Tree(self, Root_Id):
try:
self._DB_Cursor.execute("""SELECT %s_forum1.titel, %s_forum1.node_id, %s_forum1.author, %s_forum1.datestamp,
IF ( %s_forum1.node_id = %s_forum1.root_id,
round( (%s_forum1.rgt - 2) / 2, 0),
round( ( (%s_forum1.rgt - %s_forum1.lft - 1) / 2), 0)
) AS children,
COUNT(*) AS level
FROM %s_forum AS %s_forum1,
%s_forum AS %s_forum2
WHERE %s_forum1.root_id = %s
AND %s_forum2.root_id = %s
AND %s_forum1.lft BETWEEN %s_forum2.lft AND %s_forum2.rgt
GROUP BY %s_forum1.LFT"""% (self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
Root_Id,
self.Forum_Id,
Root_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id,
self.Forum_Id) )
Result = self._DB_Cursor.fetchall()
return Result
except Error, Error_Var:
raise PyForumDBError(Error_Var)
Danke Andreas