def dump_state(self): """Dump the state of the application to the output, this method is triggered by pressing :kbd:`Ctrl-Alt-D` in the GUI""" from camelot.view.model_thread import post from camelot.view.register import dump_register from camelot.view.proxy.collection_proxy import CollectionProxy import gc gc.collect() dump_register() def dump_session_state(): import collections from camelot.model.authentication import Person print '======= begin session ==============' type_counter = collections.defaultdict(int) for o in Person.query.session: type_counter[type(o).__name__] += 1 for k,v in type_counter.items(): print k,v print '====== end session ==============' post( dump_session_state ) for o in gc.get_objects(): if isinstance(o, CollectionProxy): print o for r in gc.get_referrers(o): print ' ', type(r).__name__ for rr in gc.get_referrers(r): print ' ', type(rr).__name__
def model_run( self, model_context ): import collections import gc from camelot.core.orm import Session from camelot.view import action_steps from camelot.view.register import dump_register from camelot.view.proxy.collection_proxy import CollectionProxy dump_logger = LOGGER.getChild('dump_state') session = Session() type_counter = collections.defaultdict(int) yield action_steps.UpdateProgress( text = _('Dumping session state') ) gc.collect() dump_logger.warn( '======= begin register dump =============' ) dump_register( dump_logger ) dump_logger.warn( '======= end register dump ===============' ) for o in session: type_counter[type(o).__name__] += 1 dump_logger.warn( '======= begin session dump ==============' ) for k,v in type_counter.items(): dump_logger.warn( '%s : %s'%(k,v) ) dump_logger.warn( '======= end session dump ==============' ) yield action_steps.UpdateProgress( text = _('Dumping item model state') ) dump_logger.warn( '======= begin item model dump =========' ) for o in gc.get_objects(): if isinstance(o, CollectionProxy): dump_logger.warn( '%s is used by :'%unicode( o ) ) for r in gc.get_referrers(o): dump_logger.warn( ' ' + type(r).__name__ ) for rr in gc.get_referrers(r): dump_logger.warn( ' ' + type(rr).__name__ ) dump_logger.warn( '======= end item model dump ===========' )
def model_run(self, model_context): import collections import gc from camelot.core.orm import Session from camelot.view import action_steps from camelot.view.register import dump_register from camelot.view.proxy.collection_proxy import CollectionProxy dump_logger = LOGGER.getChild('dump_state') session = Session() type_counter = collections.defaultdict(int) yield action_steps.UpdateProgress(text=_('Dumping session state')) gc.collect() dump_logger.warn('======= begin register dump =============') dump_register(dump_logger) dump_logger.warn('======= end register dump ===============') for o in session: type_counter[type(o).__name__] += 1 dump_logger.warn('======= begin session dump ==============') for k, v in six.iteritems(type_counter): dump_logger.warn('%s : %s' % (k, v)) dump_logger.warn('======= end session dump ==============') yield action_steps.UpdateProgress(text=_('Dumping item model state')) dump_logger.warn('======= begin item model dump =========') for o in gc.get_objects(): if isinstance(o, CollectionProxy): dump_logger.warn('%s is used by :' % (six.text_type(o))) for r in gc.get_referrers(o): dump_logger.warn(' ' + type(r).__name__) for rr in gc.get_referrers(r): dump_logger.warn(' ' + type(rr).__name__) dump_logger.warn('======= end item model dump ===========')