[dbapi] fallback to Entity when etypes registry isn't initialized (weird we haven't catchi this pb before)
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 19 Apr 2010 12:42:01 +0200
changeset 5321 6bdca255985a
parent 5302 dfd147de06b2
child 5322 c0b7687bce3d
[dbapi] fallback to Entity when etypes registry isn't initialized (weird we haven't catchi this pb before)
dbapi.py
--- a/dbapi.py	Thu Apr 15 19:39:55 2010 +0200
+++ b/dbapi.py	Mon Apr 19 12:42:01 2010 +0200
@@ -560,9 +560,13 @@
         if req is None:
             req = self.request()
         rset = req.eid_rset(eid, 'CWUser')
-        user = self.vreg['etypes'].etype_class('CWUser')(req, rset, row=0,
-                                                         groups=groups,
-                                                         properties=properties)
+        if 'etypes' in self.vreg:
+            user = self.vreg['etypes'].etype_class('CWUser')(req, rset, row=0,
+                                                             groups=groups,
+                                                             properties=properties)
+        else:
+            from cubicweb.entity import Entity
+            user = Entity(req, rset, row=0)
         user['login'] = login # cache login
         return user