Hi,
I have tried to test the user_agent_parser. At the top of default.py there
is
from gluon.contrib import user_agent_parser
@mobilize
def m():
ua = request.user_agent()
if ua.is_mobile():
return dict(a='MOBILE')
else:
return dict(a='FIX')
And I got:
Traceback (most recent call last):
File "/home/web2py-trunk/public_html/gluon/restricted.py", line 194,
in restricted
exec ccode in environment
File
"/home/web2py-trunk/public_html/applications/welcome/controllers/default.py"
<https://web2py-trunk.fluxflex.com/admin/default/edit/welcome/controllers/default.py>,
line 14, in <module>
@mobilize
NameError: name 'mobilize' is not defined
Version 1.99.0 (2011-09-13 04:16:50) I have checked it, in the source code
there is:
class mobilize(object):
def __init__(self, func):
self.func = func
def __call__(self):
from gluon import current
if current.session._user_agent and
current.session._user_agent.is_mobile:
items = current.response.view.split('.')
items.insert(-1,'mobile')
current.response.view = '.'.join(items)
return self.func()
Without @mobilize the program detects my Android phone - no errors. Maybe
there is only a small error, but I cannot find it.
Regards, Martin