Fix undefined locals.

This commit is contained in:
Georg Brandl 2010-07-20 10:03:20 +01:00
parent 19042aaf94
commit a2b3fd4bbe

View File

@ -12,16 +12,17 @@ Session = sessionmaker()
db_prefix = 'sphinx_' db_prefix = 'sphinx_'
class Node(Base): class Node(Base):
"""Data about a Node in a doctree.""" """Data about a Node in a doctree."""
__tablename__ = db_prefix + 'nodes' __tablename__ = db_prefix + 'nodes'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
document = Column(String(256), nullable=False) document = Column(String(256), nullable=False)
line = Column(Integer) line = Column(Integer)
source = Column(Text, nullable=False) source = Column(Text, nullable=False)
treeloc = Column(String(32), nullable=False) treeloc = Column(String(32), nullable=False)
def __init__(self, document, line, source, treeloc): def __init__(self, document, line, source, treeloc):
self.document = document self.document = document
self.line = line self.line = line
@ -44,7 +45,7 @@ class Comment(Base):
parent_id = Column(Integer, ForeignKey(db_prefix + 'comments.id')) parent_id = Column(Integer, ForeignKey(db_prefix + 'comments.id'))
parent = relation('Comment', backref='children', remote_side=[id]) parent = relation('Comment', backref='children', remote_side=[id])
def __init__(self, text, displayed, username, rating, time, def __init__(self, text, displayed, username, rating, time,
node=None, parent=None): node=None, parent=None):
self.text = text self.text = text
self.displayed = displayed self.displayed = displayed
@ -84,7 +85,7 @@ class Comment(Base):
'vote': vote or 0, 'vote': vote or 0,
'node': self.node.id if self.node else None, 'node': self.node.id if self.node else None,
'parent': self.parent.id if self.parent else None, 'parent': self.parent.id if self.parent else None,
'children': [child.serializable(user_id) 'children': [child.serializable(user_id)
for child in self.children]} for child in self.children]}
def pretty_delta(self, delta): def pretty_delta(self, delta):
@ -99,7 +100,7 @@ class Comment(Base):
dt = (days, 'day') dt = (days, 'day')
return '%s %s ago' % dt if dt[0] == 1 else '%s %ss ago' % dt return '%s %s ago' % dt if dt[0] == 1 else '%s %ss ago' % dt
class CommentVote(Base): class CommentVote(Base):
__tablename__ = db_prefix + 'commentvote' __tablename__ = db_prefix + 'commentvote'
@ -136,7 +137,7 @@ class Proposal(Base):
self.rating = rating self.rating = rating
self.time = time self.time = time
self.node = node self.node = node
class ProposalVote(Base): class ProposalVote(Base):
__tablename__ = db_prefix + 'proposalvote' __tablename__ = db_prefix + 'proposalvote'