Hi,

I'm using TurboGears 1.0.4b1 with Elixir. My problem is that data is not
committed in the database. "tg-admin sql create" worked perfectly (tables are
created). I assembled an easy "test case" [1].

How to reproduce:
- use the "test case" below [1]
- tg-admin sql create
- ./start-foobar.py
- go to http://localhost:8080
        displayed content: "item created"
- go to http://localhost:8080/list_items
        white page, no items shown

Googling revealed some posts with similar errors:
1. [2], adding "database.session.flush()" has no effect
        
2. [3], If I add "account.flush()" AND "user.flush()", the items are committed.
   But this can't be solution, calling "flush()" for every object created.

3. From plain Elixir, I knew "objectstore.flush()". This works but I think 
Elixir
    should work just like SQLObject with auto-commiting or do I miss something?


[1] http://www.felix-schwarz.name/files/misc/2007/foobar_elixir_commit.zip
[2] 
http://groups.google.com/group/sqlelixir/browse_thread/thread/2a75f950ad784c55/1f9d13b86bbb901c
[3] 
http://groups.google.com/group/turbogears/browse_thread/thread/59a783a61e82f3ee/c0a694bdf1e895b8

for your convenience, I attached model.py and controllers.py in this email.

thank you very much
fs

...............................................................................
model.py:
# -*- coding: UTF-8 -*-

from elixir import Entity, Unicode
from elixir import belongs_to, has_field, using_options

# metadata must be imported because tg-admin won't find this model otherwise.
from turbogears.database import metadata

class Account(Entity):
     has_field('userid', Unicode(30))
     using_options(tablename='account')

     def __repr__(self):
         return "%s %s" % (self.__class__.__name__, self.userid)

class User(Entity):
     has_field("name", Unicode(80))

     belongs_to('account', of_kind='Account', required=True)
     using_options(tablename='user')

     def __repr__(self):
         return "%s %s" % (self.__class__.__name__, self.name)
...............................................................................

...............................................................................
controllers.py:
# -*- coding: UTF-8 -*-

from turbogears import controllers, expose, database
from elixir import objectstore
from foobar.model import *

class Root(controllers.RootController):
     @expose()
     def index(self):
         account = Account(userid="4711")
         user = User(name="Foo Bar", account=account)
         #database.session.flush()
         #account.flush()
         #user.flush()
         #objectstore.flush()
         return "item created!"

     @expose()
     def list_items(self):
         items = []
         for i in Account.select():
             items.append(str(i))
         for i in User.select():
             items.append(str(i))
         return "<br>".join(items)
...............................................................................

--~--~---------~--~----~------------~-------~--~----~
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