equal
deleted
inserted
replaced
202 CWCTL.run(['db-create', '--config-level', str(inputlevel), |
202 CWCTL.run(['db-create', '--config-level', str(inputlevel), |
203 self.config.appid]) |
203 self.config.appid]) |
204 else: |
204 else: |
205 print ('-> nevermind, you can do it later with ' |
205 print ('-> nevermind, you can do it later with ' |
206 '"cubicweb-ctl db-create %s".' % self.config.appid) |
206 '"cubicweb-ctl db-create %s".' % self.config.appid) |
|
207 |
|
208 |
|
209 @contextmanager |
|
210 def db_transaction(source, privilege): |
|
211 """Open a transaction to the instance database""" |
|
212 cnx = system_source_cnx(source, special_privs=privilege) |
|
213 cursor = cnx.cursor() |
|
214 try: |
|
215 yield cursor |
|
216 except: |
|
217 cnx.rollback() |
|
218 cnx.close() |
|
219 raise |
|
220 else: |
|
221 cnx.commit() |
|
222 cnx.close() |
207 |
223 |
208 |
224 |
209 @contextmanager |
225 @contextmanager |
210 def db_sys_transaction(source, privilege): |
226 def db_sys_transaction(source, privilege): |
211 """Open a transaction to the system database""" |
227 """Open a transaction to the system database""" |