Package: django-mozilla-product-details
Mozilla Product Detailsis alibrarycontaining information about the latest versions, localizations, etc. ofMozillaproducts (most notably Firefox,
Firefox for mobile, and Thunderbird).From the originalREADME
file:This library holds information about the current builds of Firefox and
Thunderbird that Mozilla ships including:

- Latest version numbers for all builds
- English and Native names for all languages we supportThis is aDjangoapp allowing this
data to be used in Django projects. A Django management command can be
used as a cron job or called manually to keep the data in sync with
Mozilla.Why?Thedata sourceof
Mozilla Product Details is a PHP library kept on the Mozilla SVN server,
and was originally written so it could be included into PHP projects via
anSVN external. A
simplesvn upwould fetch the latest data when it became available.In the meantime, the Product Details library received an additional JSON
feed, allowing non-PHP projects to consume the data. If, however, the
consumer is not kept in SVN like the library is, there is no easy way to
keep the data up to date.For Django projects, this app solves that problem.Getting StartedInstallingInstall this library usingpip:pip install django-mozilla-product-details… or by downloading theproduct_detailsdirectory and dropping it
into your django project.Addproduct_detailsto yourINSTALLED_APPSto enable the
management commands.ConfigurationNo configuration should be necessary. However, you can add the
following settings to yoursettings.pyfile if you disagree with the
defaults:PROD_DETAILS_URLdefaults to the JSON directory on the Mozilla
SVN server. If you have a secondary mirror at hand, or you want this
tool to download completely unrelated JSON files from somewhere else,
adjust this setting. Include a trailing slash.PROD_DETAILS_DIRis the target directory for the JSON files. It
needs to be writable by the user that’ll execute the management
command, and readable by the user running the Django project.
Defaults to:.../install_dir_of_this_app/product_details/json/(only for use withPDFileStoragebackend (see below)).You can further decide where the JSON data should be stored by using
a storage backend class. There are 2 provided in the app currently, but
it should be easy to create a subclass ofproduct_details.storage.ProductDetailsStorageand store them wherever
you like. The two provided are for the filesystem (the default) and
the database. To configure which backend it uses set the following:PROD_DETAILS_STORAGEa string of the dotted path to a storage
class (like in MIDDLEWARE_CLASSES). Available classes included with
the app areproduct_details.storage.PDFileStorage(default) andproduct_details.storage.PDDatabaseStorage. To use the database
storage class you should run migrations (./manage.py migrate) which
will create the database table required to store the data and populate
the table with the JSON data included with the library (or the data
in the configured data directory). You can then keep the data updated
via theupdate_product_detailsmanagement command just like normal.This app uses Django’s cache framework to store the product data so that
the data can be updated on the site without requiring a server restart.
The following settings will allow you to control how this works.PROD_DETAILS_CACHE_NAMEdefaults to the cache in yourCACHESsetting calleddefault(django provides an in-memory cache here
by default). If you provide a name of a cache configured in the
Django configurationCACHES, it will use that cache to store the
file data instead.PROD_DETAILS_CACHE_TIMEOUTIf set to an integer, it represents
the number of seconds the cached data should be kept per file.
Defaults to 12 hours.Updating the feedTo update the data, execute this:./manage.py update_product_detailsYou want to run this once manually after installing the app. To
periodically pull in new data, you can make this a cron job.Note:Please be considerate of the server when adding a cron job.
The data does not change often enough to warrant an update every minute
or so. Most applications will run perfectly fine if you pull new data
once a day or even less frequently. When in doubt, contact the author of
this library.Using the dataTo use the data, just import the library:from product_details import product_detailsThe library turns all imported JSON files automatically into Python
objects. The contents are perhaps best inspected usingIPython.Version CompareProduct details comes with an implementation of version comparison code
for Mozilla-style product versions. Use it like this:>>> from product_details.version_compare import Version
>>> v1 = Version('4.0b10')
>>> v2 = Version('4.0b10pre')
>>> v1 < v2
FalseThe second useful part of the version compare code is generating a list
of unique versions, sorted by their release date, like this:>>> from product_details import product_details
>>> from product_details.version_compare import version_list
>>> version_list(product_details.firefox_history_development_releases)
['3.6.4', '3.6.3', '3.6', '3.6b5', '3.6b4', '3.6b3', '3.6b2', ... ]Caveats / Known IssuesWhile the management task will not overwrite existing files if the
server returns bogus data (i.e., an empty document or unparseable
JSON data), this library will alsonever deletea JSON file that
was completely removed from the server. This is unlikely to happen
very often, though.You don’t want toimport product_detailsinsettings.pyas
that would cause an import loop (since product_details itself
importsdjango.conf.settings). However, if you must, you can
lazily wrap the import like this, mitigating the problem:from django.utils.functional import lazy

MY_LANGUAGES = ('en-US', 'de')
class LazyLangs(list):
    def __new__(self):
        from product_details import product_details
        return [(lang.lower(), product_details.languages[lang]['native'])
                for lang in MY_LANGUAGES]
LANGUAGES = lazy(LazyLangs, list)()Using product_details before Django has finished initializing, e.g. in your
app’s__init__.pyit may raise adjango.core.exceptions.AppRegistryNotReadyexception. The lazy loading
example from above should help you overcome this issue.DevelopmentPatches are welcome.To run tests, installtoxand runtoxfrom the project root.
This will run the tests in Python 3.7, 3.8 and 3.9 against
various appropriate Django versions. If you don’t havetoxand/or all the
versions of Python available, installnose,mock,requests,responsesandDjango(seetox.ini’sdeps) and run the
tests in your current Python version by running./runtests.py.ReleasingUpdate the version number inproduct_details/__init__.py.Add an entry to the change log in the README file.Tag the commit where you changed the above with the version number: e.g.0.14.1.Push the commit and tag to the github repo.Github will build and release the package to PyPI.Change Log1.0.3 - 2022-03-08Previous release(s) did not contain product-details data. This release does include a copy of the data.1.0.2 - 2022-01-31Move CI to Github Actions. Thanks stevejalim!1.0.1 - 2022-01-13Updates to be able to handle Firefox versions over 100. Thanks robhudson!1.0.0 - 2022-01-07Drop Python 2 support.Covert codebase to use black formatting.Update the tox testing configuration to add new Django and Python releases.Thanks to stevejalim and tasos for these improvements.0.14.1 - 2019-06-03Add back last-modified data for directory lists in the data to avoid migration failure.0.14 - 2019-05-28Remove the last-modified check for directory lists. Fixes #72. Thanks pmac!0.13.1 - 2019-03-03Tweak a migration to make Django 2+ under Python 3 happy. Fixes #68. Thanks peterbe!0.13 - 2017-08-30Lazily load the storage class to avoid import issues in Django 1.9+. Thanks Giorgos!0.12.1 - 2016-08-18Add –database option to management command to allow data to be updated
in a configured database other than “default”.0.12 - 2016-07-29Update caching strategy to cache all files in a single cache entry. The file contents
are interdependent, so caching separately caused errors when timeouts were staggered.Change the default data URL tohttps://product-details.mozilla.org/1.0/(bug 1282494).0.11.1 - 2016-04-08Include updated JSON data in the release. A problem with deployment in Travis resulted in 0.11
failing to include the data.0.11 - 2016-04-08Wrap the update of JSON data in a transaction when using the database storage backend
(bug 1254664).Avoid caching empty data (bug 1254664).Thanks to jgmize for both of these improvements!0.10 - 2016-01-25Use requests lib to fetch remote data for reliability and better Py3k compatibility.Update management command to avoid Django 1.9 deprecation warnings. Django 1.8 is now the minimum supported version.Thanks to Osmose for both of these improvements!0.9 - 2015-12-28Support for Python 3 and 2 simultaneously! Also provide a universal wheel package.Support for Django 1.9. Thanks Osmose!0.8.2 - 2015-12-22Use HTTPS by default to fetch JSON data. Thanks jvehent!Fix product_details.last_update property. It’s been broken since 0.8. Thanks for the report diox!0.8.1 - 2015-10-07Add a data migration that will import the included JSON file data into the database
table upon creation.0.8 - 2015-09-30Add configurable json data file storage backends.Add filesystem and database backends.0.7.1 - 2015-06-15Do not cache a file miss.Catch an attempt to parse a non-JSON or corrupt file.0.7 - 2015-05-22Use the Django cache framework to store product data, allowing data to be
updated without a server restart.Add and update tests, setup tox for testing across Python and Django versions,
and setup Travis for CI.0.6 - 2015-05-08Initial PyPI release. Prior to this it was released and installed via github.