On 06/01/14 00:26, Aymeric Augustin wrote:
> On 5 janv. 2014, at 22:54, Shai Berger <
sh...@platonix.com> wrote:
>
>> I'd go for __contains__:
>>
>> if "django.contrib.auth" in apps:
>
> I considered this one but I didn�t select it because it will restrict our freedom in the future.
>
> If I were to add magic methods on the app registry I�d probably make it a dict of app_label => app_config. This is the most common use case.
>
> Then it would be inconsistent to support `if "django.contrib.auth" in apps` and `apps['admin']` at the same time.
>
+1 for is_installed.
And I like your plan to make apps behave as a dict of app_label =>
AppConfig instances. When you want to test for a full app name, use
if apps.is_installed('django.contrib.admin'): ...
If you don't care about the full path and want to test for the
app_label, then use
if "admin" in apps: ...
Aymeric, you are really talented! Thanks for your work!
Luc