comparison examples/tutorial/geddit/controller.py @ 664:19e8a05adc86

Fix compatibility of tutorial code with CherryPy 3.1. Closes #159.
author cmlenz
date Wed, 05 Dec 2007 23:16:50 +0000
parents c5e5801c32ac
children
comparison
equal deleted inserted replaced
663:641d76ae430c 664:19e8a05adc86
109 fileobj = open(filename, 'wb') 109 fileobj = open(filename, 'wb')
110 try: 110 try:
111 pickle.dump(data, fileobj) 111 pickle.dump(data, fileobj)
112 finally: 112 finally:
113 fileobj.close() 113 fileobj.close()
114 cherrypy.engine.on_stop_engine_list.append(_save_data) 114 if hasattr(cherrypy.engine, 'subscribe'): # CherryPy >= 3.1
115 cherrypy.engine.subscribe('stop', _save_data)
116 else:
117 cherrypy.engine.on_stop_engine_list.append(_save_data)
115 118
116 # Some global configuration; note that this could be moved into a 119 # Some global configuration; note that this could be moved into a
117 # configuration file 120 # configuration file
118 cherrypy.config.update({ 121 cherrypy.config.update({
119 'tools.encode.on': True, 'tools.encode.encoding': 'utf-8', 122 'tools.encode.on': True, 'tools.encode.encoding': 'utf-8',
Copyright (C) 2012-2017 Edgewall Software