Re: Renaming apps.has_app

2014-01-06 Thread Andre Terra
On Sun, Jan 5, 2014 at 7:38 PM, Raffaele Salmaso wrote:

> On Sun, Jan 5, 2014 at 10:11 PM, Aymeric Augustin
>  wrote:
> > `apps.has_app(...)` is technically correct but I think we can find a
> better name. My current favorite is `apps.installed(…)`. It’s quite short
> and it’s reminiscent of INSTALLED_APPS. That makes (some) sense since the
> method tests if its argument is in INSTALLED_APPS, accounting for
> AppConfigs.
> >
> > Since I’m awful at picking names, I’d like to hear your suggestions and
> arguments before making a decision.
> apps.is_installed('django.contrib.sites') ?
>
> Should it takes a list of apps, just to replace
> apps.is_installed('djagno.contrib.sites') and
> apps.is_installed('django.contrib.admin') and ...
> with
> apps.is_installed('django.contrib.sites', 'django.contrib.admin',...)
> ?


The only issue I see with this solution is that it's not clear at first
whether this is an AND or OR match, plural agreement notwithstanding.



Cheers,
AT

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAKBiv3z8K_t-shTV4OPvyLM3GSD%2BV%2BFpwG%3DnQAmgWUOGysiMuA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-06 Thread German Larrain
+1 for is_installed

Aymeric, thanks for your work

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/04aa7e6b-75d0-45dd-89cf-78e8ff83b3c3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Luc Saffre
On 06/01/14 00:26, Aymeric Augustin wrote:
> On 5 janv. 2014, at 22:54, Shai Berger  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

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/52CA1044.9010708%40gmx.net.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Russell Keith-Magee
On Mon, Jan 6, 2014 at 5:47 AM, Aymeric Augustin <
aymeric.augus...@polytechnique.org> wrote:

> On 5 janv. 2014, at 22:27, Josh Smeaton  wrote:
>
> > The only thing I have against it is that it may sound like it can take
> an iterable of app names, where has_app() does not have that problem.
>
> What about is_installed?
>

is_installed() works for me.

Russ %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAJxq84-gKyiyh5rDifk6VBRTWHsx3hhbEJw_dkO1qwKwOQxjXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Jorge Cardoso Leitão
Hi.

First of all, a hug to Aymeric for this, very nice work!

My first thought was also on "is_installed", which seems natural.

But, on my second thought, the "has_app" is not that bad because it is a
method of the "app loading"; i.e. the apps "having" something makes sense
than "being" something. The is_installed would make sense if we were
picking a specific app and asking if it was installed: "app.is_installed()".

That said, what about "apps.has_installed(app_name)"?

("has" because methods are normally applied to singular instances, but
since "apps" is a plural name, "have_installed" would actually make more
sense).

Cheers,
Jorge




On Sun, Jan 5, 2014 at 11:26 PM, Aymeric Augustin <
aymeric.augus...@polytechnique.org> wrote:

> On 5 janv. 2014, at 22:54, Shai Berger  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.
>
> --
> Aymeric.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/A2964B6C-66B2-4023-A3CE-34BBC812D025%40polytechnique.org
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAOYPqDBPA98fzxVcNvZpMqFsgt1xEqNNpQfdJKNV3fO-gLA_vg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Curtis Maloney
On 6 January 2014 10:11, Shai Berger  wrote:

> On Sunday 05 January 2014 23:26:12 Aymeric Augustin wrote:
> > 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.
>
> That's a little odd. You noted that names are better keys, which is why
> they
> are used in has_app(). Why would labels be preferable for dictionary
> access?
>
> That being said, keeping the freedom for later does make sense.
>

Is the purpose to test if a particular name is installed, or a particular
module?  The distinction could be important now that the two are not
directly related.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAG_XiSALk3eU4idrpi%2BP5OqixCwb1VhzBrC97D0FZT5n1xLN%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Shai Berger
On Sunday 05 January 2014 23:26:12 Aymeric Augustin wrote:
> On 5 janv. 2014, at 22:54, Shai Berger  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.

That's a little odd. You noted that names are better keys, which is why they 
are used in has_app(). Why would labels be preferable for dictionary access?

That being said, keeping the freedom for later does make sense.

Shai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2425524.ZYPVssT59k%40deblack.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Aymeric Augustin
On 5 janv. 2014, at 22:54, Shai Berger  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.

-- 
Aymeric.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/A2964B6C-66B2-4023-A3CE-34BBC812D025%40polytechnique.org.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Kevin Christopher Henry
+1 for "is_installed"

I don't find the grammar objectionable here, just think of it as "is_(each 
one of these apps)_installed"


On Sunday, January 5, 2014 3:50:45 PM UTC-6, Aymeric Augustin wrote:
>
> On 5 janv. 2014, at 22:38, Raffaele Salmaso 
>  
> wrote: 
>
> > Should it takes a list of apps, just to replace 
> > apps.is_installed('djagno.contrib.sites') and 
> > apps.is_installed('django.contrib.admin') and ... 
> > with 
> > apps.is_installed('django.contrib.sites', 'django.contrib.admin',...) 
> > ? 
>
> That’s an interesting suggestion. But I don’t think it’s compatible with 
> the singular “is_installed”. It could work with just “installed”, though. 
>
> -- 
> Aymeric. 
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/8afb0a25-0482-46a6-87fb-7bca34af2366%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Shai Berger
On Sunday 05 January 2014 22:47:22 Aymeric Augustin wrote:
> On 5 janv. 2014, at 22:27, Josh Smeaton  wrote:
> > The only thing I have against it is that it may sound like it can take an
> > iterable of app names, where has_app() does not have that problem.
> What about is_installed?

I'd go for __contains__: 

if "django.contrib.auth" in apps:

Shai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/1956512.opNIWBmIq8%40deblack.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Aymeric Augustin
On 5 janv. 2014, at 22:38, Raffaele Salmaso  wrote:

> Should it takes a list of apps, just to replace
> apps.is_installed('djagno.contrib.sites') and
> apps.is_installed('django.contrib.admin') and ...
> with
> apps.is_installed('django.contrib.sites', 'django.contrib.admin',...)
> ?

That’s an interesting suggestion. But I don’t think it’s compatible with the 
singular “is_installed”. It could work with just “installed”, though.

-- 
Aymeric.




-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/528491AB-B1C1-4313-A837-F12C143BAB93%40polytechnique.org.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Raffaele Salmaso
On Sun, Jan 5, 2014 at 10:11 PM, Aymeric Augustin
 wrote:
> `apps.has_app(...)` is technically correct but I think we can find a better 
> name. My current favorite is `apps.installed(…)`. It’s quite short and it’s 
> reminiscent of INSTALLED_APPS. That makes (some) sense since the method tests 
> if its argument is in INSTALLED_APPS, accounting for AppConfigs.
>
> Since I’m awful at picking names, I’d like to hear your suggestions and 
> arguments before making a decision.
apps.is_installed('django.contrib.sites') ?

Should it takes a list of apps, just to replace
apps.is_installed('djagno.contrib.sites') and
apps.is_installed('django.contrib.admin') and ...
with
apps.is_installed('django.contrib.sites', 'django.contrib.admin',...)
?

-- 
| Raffaele Salmaso
| http://salmaso.org
| https://bitbucket.org/rsalmaso
| http://gnammo.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CABgH4JsyoWxVUjVKdP9RO%3DL65UBC0VFbqKHFWwiEWFozVD19sA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Aymeric Augustin
On 5 janv. 2014, at 22:27, Josh Smeaton  wrote:

> The only thing I have against it is that it may sound like it can take an 
> iterable of app names, where has_app() does not have that problem.

What about is_installed?

-- 
Aymeric.




-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/95123FF0-7760-4631-9499-D102B91D74D2%40polytechnique.org.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Josh Smeaton
+1 on .installed() as it reads quite well. The only thing I have against it 
is that it may sound like it can take an iterable of app names, where 
has_app() does not have that problem. app_installed() is more accurate but 
is longer and less nice to read. My 2 cents.

Cheers,

Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/4efcd847-76b5-41a1-871b-8dddab1c07ae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Renaming apps.has_app

2014-01-05 Thread Jannis Leidel

On 05.01.2014, at 22:11, Aymeric Augustin  
wrote:

> Hello,
> 
> During the app_loading refactor, I introduced a method to test if a given 
> application is enabled, and I named it `has_app`.
> 
> Its main uses are detecting misconfigurations:
> 
>if not apps.has_app('django.contrib.admin'):
>raise ImproperlyConfigured("Put 'django.contrib.admin' in your "
>"INSTALLED_APPS setting in order to use the admin 
> application.")
> 
> and skipping tests:
> 
> @skipUnless(apps.has_app('django.contrib.sites'),
> "django.contrib.sites app not installed.")
> 
> That method takes an application name like “django.contrib.admin” rather than 
> a label for two reasons: name conflicts are less likely than label conflicts 
> (but they’re still possible) and unlike labels names cannot be changed.
> 
> `apps.has_app(...)` is technically correct but I think we can find a better 
> name. My current favorite is `apps.installed(…)`. It’s quite short and it’s 
> reminiscent of INSTALLED_APPS. That makes (some) sense since the method tests 
> if its argument is in INSTALLED_APPS, accounting for AppConfigs.
> 
> Since I’m awful at picking names, I’d like to hear your suggestions and 
> arguments before making a decision.

+1 on apps.installed(..)

Jannis



signature.asc
Description: Message signed with OpenPGP using GPGMail


Renaming apps.has_app

2014-01-05 Thread Aymeric Augustin
Hello,

During the app_loading refactor, I introduced a method to test if a given 
application is enabled, and I named it `has_app`.

Its main uses are detecting misconfigurations:

if not apps.has_app('django.contrib.admin'):
raise ImproperlyConfigured("Put 'django.contrib.admin' in your "
"INSTALLED_APPS setting in order to use the admin application.")

and skipping tests:

 @skipUnless(apps.has_app('django.contrib.sites'),
 "django.contrib.sites app not installed.")

That method takes an application name like “django.contrib.admin” rather than a 
label for two reasons: name conflicts are less likely than label conflicts (but 
they’re still possible) and unlike labels names cannot be changed.

`apps.has_app(...)` is technically correct but I think we can find a better 
name. My current favorite is `apps.installed(…)`. It’s quite short and it’s 
reminiscent of INSTALLED_APPS. That makes (some) sense since the method tests 
if its argument is in INSTALLED_APPS, accounting for AppConfigs.

Since I’m awful at picking names, I’d like to hear your suggestions and 
arguments before making a decision.

Thank you,

-- 
Aymeric.



-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/4DDB6F03-811A-4381-9D0F-CB1BD9773CA7%40polytechnique.org.
For more options, visit https://groups.google.com/groups/opt_out.