--- a/server/__init__.py Tue Aug 18 08:53:03 2009 +0200
+++ b/server/__init__.py Tue Aug 18 11:11:59 2009 +0200
@@ -227,7 +227,7 @@
for path in reversed(paths):
mhandler.exec_event_script('pre%s' % event, path)
# enter instance'schema into the database
- serialize_schema(mhandler.rqlcursor, schema)
+ serialize_schema(mhandler.session, schema)
# execute cubicweb's post<event> script
mhandler.exec_event_script('post%s' % event)
# execute cubes'post<event> script if any
--- a/server/migractions.py Tue Aug 18 08:53:03 2009 +0200
+++ b/server/migractions.py Tue Aug 18 11:11:59 2009 +0200
@@ -220,15 +220,6 @@
def session(self):
return self.repo._get_session(self.cnx.sessionid)
- @property
- @cached
- def rqlcursor(self):
- """lazy rql cursor"""
- # should not give session as cnx.cursor(), else we may try to execute
- # some query while no pool is set on the session (eg on entity attribute
- # access for instance)
- return self.cnx.cursor()
-
def commit(self):
if hasattr(self, '_cnx'):
self._cnx.commit()
@@ -262,7 +253,8 @@
@cached
def group_mapping(self):
"""cached group mapping"""
- return ss.group_mapping(self.rqlcursor)
+ self.session.set_pool()
+ return ss.group_mapping(self.session)
def exec_event_script(self, event, cubepath=None, funcname=None,
*args, **kwargs):
@@ -1055,6 +1047,7 @@
if not isinstance(rql, (tuple, list)):
rql = ( (rql, kwargs), )
res = None
+ self.session.set_pool()
for rql, kwargs in rql:
if kwargs:
msg = '%s (%s)' % (rql, kwargs)
@@ -1062,7 +1055,7 @@
msg = rql
if not ask_confirm or self.confirm('execute rql: %s ?' % msg):
try:
- res = self.rqlcursor.execute(rql, kwargs, cachekey)
+ res = self.session.execute(rql, kwargs, cachekey)
except Exception, ex:
if self.confirm('error: %s\nabort?' % ex):
raise
@@ -1151,8 +1144,9 @@
if self.ask_confirm:
if not self._h.confirm('execute rql: %s ?' % msg):
raise StopIteration
+ self._h.session.set_pool()
try:
- rset = self._h.rqlcursor.execute(rql, kwargs)
+ rset = self._h.session.execute(rql, kwargs)
except Exception, ex:
if self._h.confirm('error: %s\nabort?' % ex):
raise
--- a/server/test/unittest_migractions.py Tue Aug 18 08:53:03 2009 +0200
+++ b/server/test/unittest_migractions.py Tue Aug 18 11:11:59 2009 +0200
@@ -258,7 +258,7 @@
fulltextindexed=False)
def test_sync_schema_props_perms(self):
- cursor = self.mh.rqlcursor
+ cursor = self.mh.session
nbrqlexpr_start = len(cursor.execute('RQLExpression X'))
migrschema['titre']._rproperties[('Personne', 'String')]['order'] = 7
migrschema['adel']._rproperties[('Personne', 'String')]['order'] = 6
@@ -337,14 +337,14 @@
def _erqlexpr_rset(self, action, ertype):
rql = 'RQLExpression X WHERE ET is CWEType, ET %s_permission X, ET name %%(name)s' % action
- return self.mh.rqlcursor.execute(rql, {'name': ertype})
+ return self.mh.session.execute(rql, {'name': ertype})
def _erqlexpr_entity(self, action, ertype):
rset = self._erqlexpr_rset(action, ertype)
self.assertEquals(len(rset), 1)
return rset.get_entity(0, 0)
def _rrqlexpr_rset(self, action, ertype):
rql = 'RQLExpression X WHERE ET is CWRType, ET %s_permission X, ET name %%(name)s' % action
- return self.mh.rqlcursor.execute(rql, {'name': ertype})
+ return self.mh.session.execute(rql, {'name': ertype})
def _rrqlexpr_entity(self, action, ertype):
rset = self._rrqlexpr_rset(action, ertype)
self.assertEquals(len(rset), 1)