server/__init__.py
changeset 9340 b1e933b0e850
parent 9148 1b549c1acd4f
parent 9333 22423634d06d
child 9402 2c48c091b6a2
equal deleted inserted replaced
9322:2dae5bf5ea68 9340:b1e933b0e850
   147 class debugged(object):
   147 class debugged(object):
   148     """Context manager and decorator to help debug the repository.
   148     """Context manager and decorator to help debug the repository.
   149 
   149 
   150     It can be used either as a context manager:
   150     It can be used either as a context manager:
   151 
   151 
   152     >>> with debugged(server.DBG_RQL | server.DBG_REPO):
   152     >>> with debugged('DBG_RQL | DBG_REPO'):
   153     ...     # some code in which you want to debug repository activity,
   153     ...     # some code in which you want to debug repository activity,
   154     ...     # seing information about RQL being executed an repository events.
   154     ...     # seing information about RQL being executed an repository events.
   155 
   155 
   156     or as a function decorator:
   156     or as a function decorator:
   157 
   157 
   158     >>> @debugged(server.DBG_RQL | server.DBG_REPO)
   158     >>> @debugged('DBG_RQL | DBG_REPO')
   159     ... def some_function():
   159     ... def some_function():
   160     ...     # some code in which you want to debug repository activity,
   160     ...     # some code in which you want to debug repository activity,
   161     ...     # seing information about RQL being executed an repository events
   161     ...     # seing information about RQL being executed an repository events
   162 
   162 
   163     The debug mode will be reset to its original value when leaving the "with"
   163     The debug mode will be reset to its original value when leaving the "with"
   247     # they are used sometimes by generated sql. Keeping them empty is much
   247     # they are used sometimes by generated sql. Keeping them empty is much
   248     # simpler than fixing this...
   248     # simpler than fixing this...
   249     schemasql = sqlschema(schema, driver)
   249     schemasql = sqlschema(schema, driver)
   250     #skip_entities=[str(e) for e in schema.entities()
   250     #skip_entities=[str(e) for e in schema.entities()
   251     #               if not repo.system_source.support_entity(str(e))])
   251     #               if not repo.system_source.support_entity(str(e))])
   252     sqlexec(schemasql, execute, pbtitle=_title, delimiter=';;')
   252     failed = sqlexec(schemasql, execute, pbtitle=_title, delimiter=';;')
       
   253     if failed:
       
   254         print 'The following SQL statements failed. You should check your schema.'
       
   255         print failed
       
   256         raise Exception('execution of the sql schema failed, you should check your schema')
   253     sqlcursor.close()
   257     sqlcursor.close()
   254     sqlcnx.commit()
   258     sqlcnx.commit()
   255     sqlcnx.close()
   259     sqlcnx.close()
   256     session = repo.internal_session()
   260     session = repo.internal_session()
   257     # insert entity representing the system source
   261     # insert entity representing the system source