Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
django-modeldict-yplan
Advanced tools
.. image:: https://img.shields.io/pypi/v/django-modeldict-yplan.svg :target: https://pypi.python.org/pypi/django-modeldict-yplan
.. image:: https://travis-ci.org/adamchainz/django-modeldict.svg?branch=master :target: https://travis-ci.org/adamchainz/django-modeldict
Retired: this project is no longer maintained. I (Adam Johnson) no longer
have time to continue maintaining this. I was doing so to support
gargoyle-yplan <https://github.com/adamchainz/gargoyle>
__, a fork for my
ex-employer YPlan. If you'd like to sponsor ongoing maintenance or take it over
yourself, please contact me@adamj.eu.
ModelDict
is a very efficient way to store things like settings in your database. The entire model is transformed into a dictionary (lazily) as well as stored in your cache. It's invalidated only when it needs to be (both in process and based on CACHE_BACKEND
).
It was originally created by Disqus <https://github.com/disqus/django-modeldict>
_, but due to the inactivity we at YPlan have taken over maintenance on this fork.
Tested with all combinations of:
Python 3.4+ supported.
Install it with pip:
.. code-block:: bash
pip install django-modeldict-yplan
Make sure you pip uninstall django-modeldict
first if you're upgrading from the original to this fork - the packages clash.
.. code-block:: python
# You'll need a model with fields to use as key and value in the dict
class Setting(models.Model):
key = models.CharField(max_length=32)
value = models.CharField(max_length=200)
# Create the ModelDict...
settings = ModelDict(Setting, key='key', value='value', instances=False)
# And you can treat it like a normal dict:
# Missing values = KeyError
settings['foo']
>>> KeyError
# Sets supported
settings['foo'] = 'hello'
# Fetch the current value using normal dictionary access
settings['foo']
>>> 'hello'
# ...or by normal model queries
Setting.objects.get(key='foo').value
>>> 'hello'
.. Add new release notes below here
gargoyle-yplan <https://github.com/adamchainz/gargoyle>
__, a fork for my
ex-employer YPlan. If you'd like to sponsor ongoing maintenance or take it
over yourself, please contact me@adamj.eu.This version is due to be pulled from PyPI, please use version 2.0.1 as per its above release note.
iteritems()
, iterkeys()
, and itervalues()
methods from
ModelDict
, and move items()
, keys()
, and values()
to Python 3
semantics, returning iterators rather than lists.time.time()
down to the nearest integer, so we are more fine grained around expiration. It might
also fix a subtle timing bug around re-fetching the remote cache unnecessarily._local_last_updated
could be set even when it
wasn't updatedCachedDict.__repr__
so it works for other subclasses of
CachedDict
than ModelDict
(don't assume self.model
exists)cache.set_many
for more efficient storage.setdefault()
to return the value that was set/found, as per normal dict semantics. Thanks @olevinsky.FAQs
Stores a model as a dictionary
We found that django-modeldict-yplan demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.