Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#14385 closed (duplicate)

Standardize Site/RequestSite access; looser coupling of sites framework in contrib

Reported by: Gabriel Hurley Owned by: Gabriel Hurley
Component: Contrib apps Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A few days ago I started this thread on the Django Developers list in order to solve a number of tickets at the same time. The gist:

All of these tickets relate to needing access to the current domain, whether that's through a Site instance, or through a RequestSite instance. To facilitate this, the provided patch adds a utility function, django.contrib.sites.models.get_current_site which takes a request as an argument and returns either a Site or RequestSite instance.

Using that utility function, a lot of repetitious code could be removed and streamlined, and several tickets were trivial to resolve.

Included in this patch:

  • Adds the django.contrib.sites.models.get_current_site function.
  • Provides a note in the contrib.sites docs regarding the function.
  • Converts to contrib.sites tests from doctests to unit tests and adds a test for get_current_site
  • Resolves #8960 by allowing django.contrib.contenttypes.views.shortcut to use either a Site or RequesSite object.
  • Converts contrib.contenttypes tests from doctests to unit tests and adds a test for #8960.
  • Resolves #10235 and #10909 by using get_current_site in the Sitemaps framework.
  • Adds test case for #10235/#10909.
  • Updates django.contrib.syndication.views to use `get_current_site.
  • Updates django.contrib.gis.sitemaps.views to use get_current_site as per #10608.
  • Updates django.contrib.auth.views.login to use get_current_site.

The patch passes the full test suite under WinXP/Py2.6/SQLite.

This patch would completely fix #8960, #10235, and #10909. The remainder of #10608 is actually invalid, because the remaining places where contrib apps rely on contrib.sites the model has a direct relation to Site, or there is no way to access a request object to use RequestSite. Any further decoupling in contrib would require backwards-incompatible rewrites.

Change History (2)

comment:1 by Gabriel Hurley, 14 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #14386... Trac is being buggy at the moment :-/

comment:2 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top