def init(): # Make TG's run_with_transaction a no-op, we manage the transaction here # through Flask instead. import turbogears.database def run_with_transaction_noop(func, *args, **kwargs): return func(*args, **kwargs) turbogears.database.run_with_transaction = run_with_transaction_noop class EndTransactionsFilterNoop(BaseFilter): pass turbogears.database.EndTransactionsFilter = EndTransactionsFilterNoop turbogears.startup.EndTransactionsFilter = EndTransactionsFilterNoop # Make TG's restart_transaction not call session.close(). We are # responsible for calling session.close() here at the very end of the # Flask request, and if TG does it during its validation error handling, it # will break identity. def restart_transaction_patched(args): session.rollback() session.begin() turbogears.database.restart_transaction = restart_transaction_patched # Set up old CherryPy stuff. import bkr.server.controllers cherrypy.root = bkr.server.controllers.Root() cherrypy.server.start(init_only=True, server_class=None) # If rlimit_as is defined in the config file then set the limit here. if config.get('rlimit_as'): import resource resource.setrlimit(resource.RLIMIT_AS, (config.get('rlimit_as'), config.get('rlimit_as'))) # Build assets. If assets.auto_build is True in the config, this will also # happen on page request. Otherwise, it only happens once at startup here. assets.build_assets() # workaround for TGMochiKit initialisation # https://sourceforge.net/p/turbogears1/tickets/34/ import tgmochikit from turbogears.widgets.base import register_static_directory tgmochikit.init(register_static_directory, config) # Global device class list... a terrible hack, desperately needs deleting from bkr.server import model with session.begin(): model.device_classes = [ c.device_class for c in model.DeviceClass.query ] log.debug('Application initialised')
def retrieve_javascript(self): tgmochikit.init(register_static_directory, config) if config.get('tg.mochikit_suppress', False): if 'turbogears.mochikit' in config.get('tg.include_widgets', []): warnings.warn("""\ tg.mochikit_suppress == True, but 'turbogears.mochikit' is to be included via 'tg.include_widgets'. This is a contradiction, and mochikit_suppress overrides the inclusion to prevent subtle errors due to version mixing of MochiKit.""") return [] javascripts = [JSLink("tgmochikit", path) for path in tgmochikit.get_paths()] return javascripts
def init(): # Make TG's run_with_transaction a no-op, we manage the transaction here # through Flask instead. import turbogears.database def run_with_transaction_noop(func, *args, **kwargs): return func(*args, **kwargs) turbogears.database.run_with_transaction = run_with_transaction_noop class EndTransactionsFilterNoop(BaseFilter): pass turbogears.database.EndTransactionsFilter = EndTransactionsFilterNoop turbogears.startup.EndTransactionsFilter = EndTransactionsFilterNoop # Make TG's restart_transaction not call session.close(). We are # responsible for calling session.close() here at the very end of the # Flask request, and if TG does it during its validation error handling, it # will break identity. def restart_transaction_patched(args): session.rollback() session.begin() turbogears.database.restart_transaction = restart_transaction_patched # Set up old CherryPy stuff. import bkr.server.controllers cherrypy.root = bkr.server.controllers.Root() cherrypy.server.start(init_only=True, server_class=None) # If rlimit_as is defined in the config file then set the limit here. if config.get('rlimit_as'): import resource resource.setrlimit(resource.RLIMIT_AS, (config.get('rlimit_as'), config.get('rlimit_as'))) # Build assets. If assets.auto_build is True in the config, this will also # happen on page request. Otherwise, it only happens once at startup here. assets.build_assets() # workaround for TGMochiKit initialisation # https://sourceforge.net/p/turbogears1/tickets/34/ import tgmochikit from turbogears.widgets.base import register_static_directory tgmochikit.init(register_static_directory, config) # Global device class list... a terrible hack, desperately needs deleting from bkr.server import model with session.begin(): model.device_classes = [c.device_class for c in model.DeviceClass.query] log.debug('Application initialised')
def init(): # Make TG's run_with_transaction a no-op, we manage the transaction here # through Flask instead. import turbogears.database def run_with_transaction_noop(func, *args, **kwargs): return func(*args, **kwargs) turbogears.database.run_with_transaction = run_with_transaction_noop class EndTransactionsFilterNoop(BaseFilter): pass turbogears.database.EndTransactionsFilter = EndTransactionsFilterNoop turbogears.startup.EndTransactionsFilter = EndTransactionsFilterNoop # Make TG's restart_transaction not call session.close(). We are # responsible for calling session.close() here at the very end of the # Flask request, and if TG does it during its validation error handling, it # will break identity. def restart_transaction_patched(args): session.rollback() session.begin() turbogears.database.restart_transaction = restart_transaction_patched # Set up old CherryPy stuff. import bkr.server.controllers cherrypy.root = bkr.server.controllers.Root() cherrypy.server.start(init_only=True, server_class=None) # If rlimit_as is defined in the config file then set the limit here. if config.get('rlimit_as'): import resource resource.setrlimit(resource.RLIMIT_AS, (config.get('rlimit_as'), config.get('rlimit_as'))) # workaround for TGMochiKit initialisation # https://sourceforge.net/p/turbogears1/tickets/34/ import tgmochikit from turbogears.widgets.base import register_static_directory tgmochikit.init(register_static_directory, config) log.debug('Application initialised')