their_h = getattr(sys.modules[package_name + '.lib.base'], 'h', None) if isinstance(their_h, types.ModuleType): # lib.base.h is a module (and thus not pylons.h) -- assume lib.base # uses new style (self contained) helpers via: # import ${package}.lib.helpers as h return their_h # Assume lib.base.h is a StackedObjectProxy -- lib.base is using pre 0.9.2 # style helpers via: # from pylons import h helpers_name = package_name + '.lib.helpers' __import__(helpers_name) return sys.modules[helpers_name] jsonify = deprecated(pylons.decorators.jsonify, func_move('pylons.jsonify', moved_to='pylons.decorators.jsonify')) class DeprecatedStackedObjectProxy(StackedObjectProxy): def __init__(self, *args, **kwargs): self.__dict__['__warning'] = kwargs.pop('warning') StackedObjectProxy.__init__(self, *args, **kwargs) def _current_obj(self, *args, **kwargs): warnings.warn(self.__dict__['__warning'], DeprecationWarning, 3) return StackedObjectProxy._current_obj(self, *args, **kwargs) h = DeprecatedStackedObjectProxy(name="h", warning=pylons_h_warning) c = DeprecatedStackedObjectProxy(name="tmpl_context", warning=pylons_c_warning) g = DeprecatedStackedObjectProxy(name="app_globals", warning=pylons_g_warning) buffet = DeprecatedStackedObjectProxy(name="buffet", warning=pylons_buffet_warning)
"""Deprecated: This module has moved to pylons.controllers.util""" import warnings import pylons import pylons.controllers.util import pylons.legacy from pylons.util import deprecated, func_move __all__ = ['abort', 'etag_cache', 'log', 'redirect_to'] warnings.warn('The pylons.helper module has moved to pylons.controllers.util; ' 'please update your imports.', DeprecationWarning, 2) def log(msg): """Deprecated: Use the logging module instead. Log a message to the output log. """ warnings.warn(pylons.legacy.log_warning, DeprecationWarning, 2) pylons.request.environ['wsgi.errors'].write('=> %s\n' % str(msg)) abort = deprecated(pylons.controllers.util.abort, func_move('abort', 'pylons.controllers.util')) etag_cache = deprecated(pylons.controllers.util.etag_cache, func_move('etag_cache', 'pylons.controllers.util')) redirect_to = deprecated(pylons.controllers.util.redirect_to, func_move('redirect_to', 'pylons.controllers.util'))
if isinstance(their_h, types.ModuleType): # lib.base.h is a module (and thus not pylons.h) -- assume lib.base # uses new style (self contained) helpers via: # import ${package}.lib.helpers as h return their_h # Assume lib.base.h is a StackedObjectProxy -- lib.base is using pre 0.9.2 # style helpers via: # from pylons import h helpers_name = package_name + '.lib.helpers' __import__(helpers_name) return sys.modules[helpers_name] jsonify = deprecated( pylons.decorators.jsonify, func_move('pylons.jsonify', moved_to='pylons.decorators.jsonify')) class DeprecatedStackedObjectProxy(StackedObjectProxy): def __init__(self, *args, **kwargs): self.__dict__['__warning'] = kwargs.pop('warning') StackedObjectProxy.__init__(self, *args, **kwargs) def _current_obj(self, *args, **kwargs): warnings.warn(self.__dict__['__warning'], DeprecationWarning, 3) return StackedObjectProxy._current_obj(self, *args, **kwargs) h = DeprecatedStackedObjectProxy(name="h", warning=pylons_h_warning) c = DeprecatedStackedObjectProxy(name="tmpl_context", warning=pylons_c_warning)
"""Deprecated: This module has moved to pylons.controllers.util""" import warnings import pylons import pylons.controllers.util import pylons.legacy from pylons.util import deprecated, func_move __all__ = ['abort', 'etag_cache', 'log', 'redirect_to'] warnings.warn( 'The pylons.helper module has moved to pylons.controllers.util; ' 'please update your imports.', DeprecationWarning, 2) def log(msg): """Deprecated: Use the logging module instead. Log a message to the output log. """ warnings.warn(pylons.legacy.log_warning, DeprecationWarning, 2) pylons.request.environ['wsgi.errors'].write('=> %s\n' % str(msg)) abort = deprecated(pylons.controllers.util.abort, func_move('abort', 'pylons.controllers.util')) etag_cache = deprecated(pylons.controllers.util.etag_cache, func_move('etag_cache', 'pylons.controllers.util')) redirect_to = deprecated(pylons.controllers.util.redirect_to, func_move('redirect_to', 'pylons.controllers.util'))