New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iteration feature #4
Conversation
This brings its behaviour closer to real dicts. Iteration abilities are useful if you want to expose all the exported settings in your template.
Cool, will do. I also noticed that Travis isn't set up to test with Django >= 1.8 ATM, you might want to change that :-) |
@rivol great, thanks. There's also Django without version which installs the latest version from PyPi. But sure, we could also include the ones between |
I'm trying to port my tests to work with your change, but it's problematic. I still can't use Django first tries dict lookup and relies on specific exceptions being raised if the key is absent from the dict (specifically one of I don't have any good ideas for solving this. Special cases could be added to |
@rivol right, didn't realize this. So let's drop the option to access the values via attributes, It's not actually even needed. These steps should do the trick:
Thanks! |
…that won't actually be enough since it tries key access first, hold on |
The last missing step (hopefully):
try:
return super(ExportedSettings, self).__getitem__(item)
except KeyError:
+ if hasattr(self, item):
+ raise
raise UnexportedSettingError( |
Also fix a test that had broken after the merge.
1 similar comment
Fails on Python 3. AFAICT |
@rivol true, but
|
@jkbrzt nope, if I remove |
Please read the whole comment — I'm suggesting there dropping attribute access altogether :) |
Oh, right, I missed that part :-P Thanks for sorting this out. |
@rivol done, thanks for you help |
AddedExportedSettings.items() that can be used to iterate over all exported settings.
Iteration abilities are useful if you want to expose all the exported settings in your template.
Also ported the demo app to Django 1.10.