Changeset 5653
- Timestamp:
- 07/12/07 00:28:04 (2 years ago)
- Files:
-
- django/trunk/django/contrib/sites/models.py (modified) (1 diff)
- django/trunk/docs/sites.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/sites/models.py
r5652 r5653 27 27 def __unicode__(self): 28 28 return self.domain 29 30 class RequestSite(object): 31 """ 32 A class that shares the primary interface of Site (i.e., it has 33 ``domain`` and ``name`` attributes) but gets its data from a Django 34 HttpRequest object rather than from a database. 35 36 The save() and delete() methods raise NotImplementedError. 37 """ 38 def __init__(self, request): 39 self.domain = self.name = request.META['SERVER_NAME'] 40 41 def save(self): 42 raise NotImplementedError('RequestSite cannot be saved.') 43 44 def delete(self): 45 raise NotImplementedError('RequestSite cannot be deleted.') django/trunk/docs/sites.txt
r5064 r5653 321 321 .. _syndication framework: ../syndication/ 322 322 .. _authentication framework: ../authentication/ 323 324 ``RequestSite`` objects 325 ======================= 326 327 **New in Django development version** 328 329 Some ``django.contrib`` applications take advantage of the sites framework but 330 are architected in a way that doesn't *require* the sites framework to be 331 installed in your database. (Some people don't want to, or just aren't *able* 332 to install the extra database table that the sites framework requires.) For 333 those cases, the framework provides a ``RequestSite`` class, which can be used 334 as a fallback when the database-backed sites framework is not available. 335 336 A ``RequestSite`` object has a similar interface to a normal ``Site`` object, 337 except its ``__init__()`` method takes an ``HttpRequest`` object. It's able to 338 deduce the ``domain`` and ``name`` by looking at the request's domain. It has 339 ``save()`` and ``delete()`` methods to match the interface of ``Site``, but 340 the methods raise ``NotImplementedError``.
