What about the following patches:
- One patch to add a get method to Entity
- Another patch to make Elixir use scoped_session instead of
deprecated SessionContext
- Last patch to make TurboGears not use ActiveMapper at all because it
was initializing sqlalchemy.objectstore to its own objectstore. Made
it use Elixir instead.

Also, is there a ticket for adding Elixir support in TG that I can
refer to?

Appreciate your feedback,
    --Renier

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)
+
     # DEPRECATED LAND
     def select(cls, *args, **kwargs):
         warnings.warn("The select method on the class is deprecated."
metaxa site-packages $ diff -u Elixir-0.4.0-py2.5.egg/elixir/
__init__.py.orig Elixir-0.4.0-py2.5.egg/elixir/__init__.py
--- Elixir-0.4.0-py2.5.egg/elixir/__init__.py.orig      2007-09-10
13:39:10.000000000 -0400
+++ 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()

metaxa site-packages $ diff -u TurboGears-1.0.3.2dev_r3487-py2.5.egg/
turbogears/database.py.orig TurboGears-1.0.3.2dev_r3487-py2.5.egg/
turbogears/database.py
--- 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()


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