If I understand the docs correctly, Turbogears commits my transaction
automatically if I use the ORM in my controller.

This is used in this example: 
http://turbogears.org/2.1/docs/main/Wiki20/wiki20.html

    @expose("wiki20.templates.edit")
    def notfound(self, pagename):
        page = Page(pagename=pagename, data="")
        DBSession.add(page)
        return dict(wikipage=page)

Which works.

However, if I have a model with references to another one (here with
elixir),

class Article(Entity):
        contents = Field(Text(convert_unicode=True))
        topic = ManyToOne('Topic', inverse='articles')

it stops working.
After creating an a=Article() and using sometopic.articles.append(a),
I have to call DBSession.flush(). Otherwise, the topic is saved as
None and sometopic.articles does not grow.

It would be nice to understand why.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.

Reply via email to