I have a self-reference table,

class member:
    id ....
    upline_id = Column(Integer, ForeignKey('member.id'))
    status ....

    downlines = relationship('member',
backref=backref('upline',                         remote_side=id))

    def setUpline(self, upline_id)

          session = DBSession()

          self.upline_id = upline_id

          session.add(self)
          session.flush()

          self.upline.status = '....'

So in the code, I use
member = member()
member.setUpline(uplin_id) to set the member's upline information, is
it safe to use
session.add(self)
session.flush()
like above? Coz I need to flush to the session to have the current
user object to be set, then I can update upline information.





-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to