Thank you, cd34! Your code works right!

On 14 abr, 03:40, cd34 <[email protected]> wrote:
> model:
>
> class cp_ticket(DeclarativeBase):
>     __tablename__ = 'cp_ticket'
>
>     ticket_id = Column(mysql.MSBigInteger(20, unsigned = True),
> primary_key=True, autoincrement = True)
>     subject = Column(Unicode(100), default = 'Trouble Report')
>
>     ticket_detail = relation('cp_ticket_detail', backref='cp_ticket',
> order_by='cp_ticket_detail.ticket_detail_id')
>
> class cp_ticket_detail(DeclarativeBase):
>     __tablename__ = 'cp_ticket_detail'
>
>     ticket_id = Column(mysql.MSBigInteger(20, unsigned = True),
> ForeignKey('cp_ticket.ticket_id'), default = '0')
>     ticket_detail_id = Column(mysql.MSBigInteger(20, unsigned = True),
> primary_key=True, autoincrement = True)
>     detail = Column(mysql.MSLongText, default = '0')
>     ticket = relation(cp_ticket, uselist=False)
>
>     def __init__(self, detail, ticket):
>         self.detail = detail
>         self.ticket = ticket
>
> controller:
>
>         ticket = cp_ticket(client_id=get_client_id(),
> subject=request.params['subject'])
>         ticket_detail =
> cp_ticket_detail(request.params['detail'],ticket)
>         ticket.ticket_detail.append(ticket_detail)
>         meta.Session.add(ticket)
>         meta.Session.flush()
>
> ticket_detail receives a parameter + the ticket object.
> ticket.ticket_detail.append(ticket_detail) relates the record.  I
> think this is what you are trying to do.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to