clement / django-wurfl Goto Github PK
View Code? Open in Web Editor NEWEquivalent to tera-wurfl for python and django web framework
License: Other
Equivalent to tera-wurfl for python and django web framework
License: Other
Reference the following Django trac:
http://code.djangoproject.com/ticket/13526
Current master of this repo imports JSONEncoder and JSONDecoder directly which results in an error that the JSONDecoder object has no attribute object_pairs_hook.
Modifying models.py and parser.py according to the example code in the Django ticket resolves this issue.
DevBook:mobile admin$ ./manage.py wurfl-load /Users/admin/Projects/example-mobile/src/mobile/wurfl-latest.xml
/Users/admin/Projects/example-mobile/src/mobile/wurfl/models.py:10: DeprecationWarning: the md5 module is deprecated; use hashlib instead
from md5 import new as md5
Error: sequence item 0: expected string, OperationalError found
What kind of bug is this sequence item 0: .. I must be doing something wrong...
An updated iPad (1) user-agent reports as: Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5
The latest-and-greatest wurfl.xml (http://sourceforge.net/projects/wurfl/files/WURFL/) does not have that exact user-agent; however the official API (Tera-WURFL for the DB implementation, or really any of them) can still match this against the iPad (listed in wurfl.xml as Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7D11) because of the way it does partial matches - in the newest Tera-WURFL this can be found in UserAgentMatchers/AppleUserAgentMatcher.php public function recoveryMatch() - notice it doesn't simply try to do a match against the beginning of the string but rather checks for certain key elements.
django-wurfl on the other hand tries to do a match against a third of the UA string and then uses Levenshtein distance to determine which match is the best to use. In this case, a third of the iPad UA string is "Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS" which still doesn't match anything (I was able to get a match by making it fallback to a sixth of the UA string, e.g., "Mozilla/5.0 (iPad; U; C").
The fix is unfortunately non-trivial - the official WURFL APIs solve this by having per-user-agent classes that handle the attempts at matching, instead of just trying to match against a fragment of the UA string. If django-wurfl is to be an actual replacement for the official WURFL APIs, however, this problem needs to be addressed.
Even though you have very good documentation, It would be nice if you could add a simple "hello world" project.
Much appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.