def mobilized(normal_fn):
def decorator(mobile_fn):<EOL><INDENT>@functools.wraps(mobile_fn)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>ctx = stack.top<EOL>if ctx is not None and hasattr(ctx, '<STR_LIT>'):<EOL><INDENT>request = ctx.request<EOL>if not request.MOBILE:<EOL><INDENT>return normal_fn(*args, **kwargs)<EOL><DEDENT><DEDENT>return mobile_fn(*args, **kwargs)<EOL><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
Replace a view function with a normal and mobile view.

For example::

    def view():
        ...

    @mobilized(view)
    def view():
        ...


The second function is the mobile version of view. The original
function is overwritten, and the decorator will choose the correct
function based on ``request.MOBILE``.