Vince Spicer <vinces1...@gmail.com> added the comment:

Fixed typo in diff

----------
status: unread -> chatting

__________________________________
Repoze Bugs <b...@bugs.repoze.org>
<http://bugs.repoze.org/issue154>
__________________________________
Index: repoze/what/plugins/sql/adapters.py
===================================================================
--- repoze/what/plugins/sql/adapters.py	(revision 9728)
+++ repoze/what/plugins/sql/adapters.py	(working copy)
@@ -62,7 +62,7 @@
 
 from sqlalchemy.exceptions import SQLAlchemyError
 from sqlalchemy.orm.exc import NoResultFound
-from sqlalchemy.orm import eagerload
+from sqlalchemy.orm import eagerload, lazyload
 
 from repoze.what.adapters import BaseSourceAdapter, SourceError
 
@@ -194,7 +194,12 @@
         # "field" usually equals to {tg_package}.model.User.user_name
         # or {tg_package}.model.Group.group_name
         field = getattr(self.children_class, self.translations['item_name'])
-        query = self.dbsession.query(self.children_class).options(eagerload(self.translations['sections']))
+        relation = getattr(self.children_class, self.translations['sections'])
+        if relation.property.lazy == 'dynamic':
+            joinload = lazyload(relation)
+        else:
+            joinload = eagerload(relation)
+        query = self.dbsession.query(self.children_class).options(joinload)
         try:
             item_as_row = query.filter(field==item_name).one()
         except NoResultFound:
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to