There are two classes: User and Question
A user may have many questions, and it also contains a question_count
to record the the count of questions belong to him.
So, when I add a new question, I want update the question_count of the
user. At first, I do as:
question = Question(title='aaa',
, then update the associated user. If I write
'before_insert()' on user, it won't have chance to be invoked.
On 9月6日, 上午2时05分, Michael Bayer mike...@zzzcomputing.com wrote:
On Sep 5, 2010, at 1:27 PM, Freewind wrote:
There are two classes: User and Question
A user may have many
, then update the associated user. If I write
'before_insert()' on user, it won't have chance to be invoked.
On 9月6日, 上午2时05分, Michael Bayer mike...@zzzcomputing.com wrote:
On Sep 5, 2010, at 1:27 PM, Freewind wrote:
There are two classes: User and Question
A user may have many
Thank you, Mike!
Your answer is really what I want to know, many thanks to you!
On Sep 6, 5:17 am, Michael Bayer mike...@zzzcomputing.com wrote:
On Sep 5, 2010, at 2:23 PM, Freewind wrote:
I post the detail class here:
Session = scoped_session(sessionmaker())
Base = declarative_base
I'm use sqlalchemy 0.6.4.
I have 2 classes: Question and Tag, they are many-to-many.
{{{
class Question(Base):
__tablename__ = questions
id = Column(Integer, primary_key=True)
deleted = Column(Boolean)
...
tags = relationship('Tag', secondary=r_questions_tags)
class
I've two classes: Question and Answer. A question may have 0 or many
answers.
class Question(Base):
__tablename__ = questions
answers = relationship('Answer', backref='question',
primaryjoin=Question.id==Answer.question_id)
class Answer(Base):
__tablename__ = answers
Now I want to
I'm new to python(sqlalchemy), and I'm learning to build web site with
pylons and sqlalchemy.
I have a problem when I declare the relationship between models. I've
tried it several hours, but failed. But I think it should be a basic
question.
I have two classes: User and Article, user can create