Begins a transaction and calls the given DAO method. If the method executes successfully the transaction is commited. If the method fails, the transaction is rolled back. @type method: callable @param method: Bound method of this class or one of its subcl
(self, method, *argv, **argd)
| 288 | self._session = session |
| 289 | |
| 290 | def _transactional(self, method, *argv, **argd): |
| 291 | """ |
| 292 | Begins a transaction and calls the given DAO method. |
| 293 | |
| 294 | If the method executes successfully the transaction is commited. |
| 295 | |
| 296 | If the method fails, the transaction is rolled back. |
| 297 | |
| 298 | @type method: callable |
| 299 | @param method: Bound method of this class or one of its subclasses. |
| 300 | The first argument will always be C{self}. |
| 301 | |
| 302 | @return: The return value of the method call. |
| 303 | |
| 304 | @raise Exception: Any exception raised by the method. |
| 305 | """ |
| 306 | self._session.begin(subtransactions=True) |
| 307 | try: |
| 308 | result = method(self, *argv, **argd) |
| 309 | self._session.commit() |
| 310 | return result |
| 311 | except: |
| 312 | self._session.rollback() |
| 313 | raise |
| 314 | |
| 315 | |
| 316 | # ------------------------------------------------------------------------------ |
no test coverage detected