As I said already, sorry for the slow answer to all your posts...
On 9/10/07, renier <[EMAIL PROTECTED]> wrote:
> metaxa site-packages $ diff -u Elixir-0.4.0-py2.5.egg/elixir/
> entity.py.orig Elixir-0.4.0-py2.5.egg/elixir/entity.py
> --- Elixir-0.4.0-py2.5.egg/elixir/entity.py.orig 2007-09-10
> 15:19:43.000000000 -0400
> +++ Elixir-0.4.0-py2.5.egg/elixir/entity.py 2007-09-10
> 16:11:42.000000000 -0400
> @@ -641,6 +641,18 @@
> return cls.query().filter_by(*args, **kwargs).first()
> get_by = classmethod(get_by)
>
> + def get(cls, id):
> + for field in cls._descriptor.fields.values():
> + if field.primary_key:
> + idname = field.colname
> + break
> + else:
> + idname = 'id'
> +
> + idarg = { idname: id }
> + return cls.query().filter_by(**idarg).first()
> + get = classmethod(get)
You're correct to think we need to re-add a get method, though there
is a simpler way to do so:
def get(cls, *args, **kwargs):
return cls._descriptor.objectstore.session.get(*args, **kwargs)
get = classmethod(get)
This is now commited to trunk.
> +++ Elixir-0.4.0-py2.5.egg/elixir/__init__.py 2007-09-10
> 13:40:26.000000000 -0400
> @@ -18,7 +18,7 @@
>
> import sqlalchemy
>
> -from sqlalchemy.ext.sessioncontext import SessionContext
> +from sqlalchemy.orm import scoped_session
> from sqlalchemy.types import *
>
> from elixir.options import using_options, using_table_options, \
> @@ -58,7 +58,7 @@
> # this only happens when the threadlocal extension is used
> objectstore = sqlalchemy.objectstore
> except AttributeError:
> - objectstore =
> Objectstore(SessionContext(sqlalchemy.orm.create_session))
> + objectstore =
> Objectstore(scoped_session(sqlalchemy.orm.create_session))
>
> metadatas = set()
This would be fine for people using SA 0.4 but would break on SA
0.3.10 and earlier. The goal is to support both SA 0.4 and SA 0.3.10
at the same time.
> --- TurboGears-1.0.3.2dev_r3487-py2.5.egg/turbogears/
> database.py.orig 2007-09-10 16:43:39.000000000 -0400
> +++ TurboGears-1.0.3.2dev_r3487-py2.5.egg/turbogears/
> database.py 2007-09-10 16:45:37.000000000 -0400
> @@ -27,7 +27,7 @@
> # Provide support for sqlalchemy
> try:
> import sqlalchemy
> - from sqlalchemy.ext import activemapper, sessioncontext
> + import elixir
> from sqlalchemy.exceptions import InvalidRequestError
>
> def get_engine():
> @@ -58,9 +58,8 @@
>
> return sqlalchemy.orm.create_session()
>
> - metadata = activemapper.metadata
> - session = activemapper.Objectstore(create_session)
> - activemapper.objectstore = session
> + metadata = elixir.metadata
> + session = elixir.objectstore
>
> def bind_meta_data():
> get_engine()
I guess you can't just replace ActiveMapper with Elixir, as people
still using ActiveMapper would complain. If you go down that route
anyway, you could simplify the database.py further as with the latest
versions of Elixir (>= 0.3), you don't need to connect the metadata in
each thread.
Btw: thanks for your efforts in trying to fix those issues. I really
appreciate it.
--
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
-~----------~----~----~----~------~----~------~--~---