#26079: add prefered/default protocol in the sites framework
--------------------------------+--------------------------------------
     Reporter:  xblitz          |                    Owner:  xblitz
         Type:  New feature     |                   Status:  assigned
    Component:  contrib.sites   |                  Version:  master
     Severity:  Normal          |               Resolution:
     Keywords:  sites protocol  |             Triage Stage:  Unreviewed
    Has patch:  0               |      Needs documentation:  0
  Needs tests:  1               |  Patch needs improvement:  1
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+--------------------------------------

Old description:

> I think adding a prefered/default protocol in the sites framework would
> be a great addition for generating full url's to django websites.
>
> specially when generating url from action not coming from a request like
> the sitemaps
> [https://github.com/django/django/blob/master/django/contrib/sitemaps/__init__.py#L42
> ping_google] that assumes the protocol to be http:
> {{{
>     current_site = Site.objects.get_current()
>     url = "http://%s%s"; % (current_site.domain, sitemap_url)
> }}}
> so we could have something like this instead:
> {{{
>     current_site = Site.objects.get_current()
>     url = "%s://%s%s" % (current_site.protocol, current_site.domain,
> sitemap_url)
> }}}
> and maybe even add a shortcut for the site's base url

New description:

 I think adding a preferred/default protocol in the sites framework would
 be a great addition for generating full url's to django websites.

 specially when generating url from action not coming from a request like
 the sitemaps
 
[https://github.com/django/django/blob/master/django/contrib/sitemaps/__init__.py#L42
 ping_google] that assumes the protocol to be http:
 {{{
     current_site = Site.objects.get_current()
     url = "http://%s%s"; % (current_site.domain, sitemap_url)
 }}}
 so we could have something like this instead:
 {{{
     current_site = Site.objects.get_current()
     url = "%s://%s%s" % (current_site.protocol, current_site.domain,
 sitemap_url)
 }}}
 and maybe even add a shortcut for the site's base url

--

Comment (by timgraham):

 I'm not immediately convinced that a database field is the way to go for a
 couple reasons:

 1. It would make data less portable between development (where SSL is
 often not in use) and production.
 2. I'm not sure it's a common case that only some sites would use SSL but
 not others.

 A third-party library called django-hosts, which djangoproject.com uses,
 adds a setting called [http://django-
 hosts.readthedocs.org/en/latest/#django.conf.settings.HOST_SCHEME
 HOSTS_SCHEME] to solve this. I think there's been some discussion about
 merging at least parts of this library into core since it solves common
 problems.

 See also #10944 (we might close this ticket as a duplicate of that one)
 and #23829 (about customizing `ping_google` to allow https). I think the
 best course of action would be to consider this feedback and write to the
 DevelopersMailingList with your proposal. Either solution of a new setting
 or a new database field need feedback from a wider audience. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/26079#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.b1b2fbde21a8ae0edd920dafe6cc411e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to