Questions we need to be able to determine for each user include (1) What country store should they be visiting? and (2) What language should the pages be in? We allow people to choose their own country stores if they would like but we should have appropriate defaults for the 99.x% of people who don't need to visit another store. I've written pseudocode to help make it more clear: > # What store are you in? > if cookies[store] and store_is_valid(cookies[store]): > store = cookies[store] > else > store = geolocate_user() > cookies[store] = store > > if cookies[language] and language_is_valid(cookies[language]): > language = cookies[language] > else: > for i in pull_languages_from_accept_headers(): > if language_is_valid(i): > language = i > break > if not language: > language = store['default_language'] I think everything in the above code is self explanatory except for geolocate_user(). That's a little bonus that glosses over a bit of logic. :) Our geolocation solution is a binary database file. You should put a constant in our settings file to point to a file on disk so we don't have to check it in to the repo. You can get a free demo file here (http://www.maxmind.com/app/geolite). We also own (purchased) the full file and once we deploy we'll flip to using that. Anyway, MaxMind has a library for python (http://www.maxmind.com/app/python) which sounds like a pain in the ass, but they also link to https://github.com/appliedsec/pygeoip which sounds way friendlier for deployment (pure python). Please use that library and hook it up to the geo-database file. Once you have a response from the geo-ip db check if the store exists on marketplace, otherwise they are sent to the generic store.  Alright, so you're all excited to get going and you found out the full geoip db is a few hundred MB. Yeah, I'm not excited about opening that file for every visitor to the store either but metrics says that it is very fast lookups. The MMAP_CACHE flag when opening it will let us not load the whole thing into memory which I think will work fine for us. If not, we can experiment but this is a place to start. Spec: https://wiki.mozilla.org/Marketplace/Features/Country_Stores
Assignee: nobody → cvan
Target Milestone: --- → 2012-07-12
https://github.com/mozilla/zamboni/commit/a742702 DONE: * Removed /<locale>/ prefixed URLs and associated redirects. * Added cookie-based locale detection (via `Accept-Language` or user choice). * Added cookie-based region store detection (via `Accept-Language` or user choice). TO DO: * Do IP-based geolocation. (Scared!)
I reverted b/c this removes `request.APP`, which breaks lots of templates and template helpers. The dev hub and reviewers were throwing 500 errors.
Target Milestone: 2012-07-12 → 2012-07-19
Geolocation is now bug 774746
Closed. Do IP-based geolocation lookups in bug 774746.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: 2012-07-19 → 2012-07-12
You need to log in before you can comment on or make changes to this bug.