On Wed, Nov 26, 2008 at 15:57, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:

> the subject pretty much says it all. We just discovered that when trying to
> implement a backoffice system that requires objects to be shared between
> threads.
>
> Yes, we are aware of the dangers that imposes.
>
> Yet we need this to keep data around & occasionally update. The  updating is
> then governed by a lock to prevent any MT-related troubles.
>
> However, using Entity & setup_all puked on us, the error message being
>
> Exception: Failed to map entity 'Test' with its table or selectable. The code
> is below.
>
> Changing the session to a scoped session makes the test pass.
>
> This however is *not* a limitation imposed by SA! We switched to declarative
> mapping for this project - and it works.

It's not a limitation of Elixir either...

> Now - are there any technical reasons for Elixir behaving like this, or is it
> just an oversight? Would a patch be accepted?

AFAIK, it only makes sense to bind a *class* to scoped session.
Otherwise, you should use manual session management (which *is*
supported by Elixir).

> import elixir
> from sqlalchemy.orm import sessionmaker
> from sqlalchemy import create_engine
> from elixir import Unicode, Entity, Field, using_table_options, using_options
>
> engine = create_engine("sqlite:////tmp/test.dat")
> elixir.metadata.bind = engine
>
>
> class Test(Entity):

      using_options(session=None)  # <---- this makes your test work

>    name = Field(Unicode(length=100))
>
>
> elixir.setup_all()
> elixir.create_all()

Hope it helps,

-- 
Gaƫtan de Menten
http://openhex.org

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

Reply via email to